mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixes #2810
This commit is contained in:
parent
9e83b4af00
commit
e47d0171cc
@ -35,6 +35,7 @@
|
||||
* Fixed #2794
|
||||
* Fixed #2793
|
||||
* Fixed #2809
|
||||
* Fixed #2810
|
||||
* Fixed a small exception which gets thrown when Slimefun is disabled due to an invalid environment
|
||||
|
||||
## Release Candidate 20 (30 Jan 2021)
|
||||
|
@ -157,7 +157,8 @@ public class LockedCategory extends Category {
|
||||
|
||||
for (Category category : parents) {
|
||||
for (SlimefunItem item : category.getItems()) {
|
||||
if (!item.canUse(p, false)) {
|
||||
// Check if the Player has researched every item (if the item is enabled)
|
||||
if (!item.isDisabledIn(p.getWorld()) && item.hasResearch() && !profile.hasUnlocked(item.getResearch())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
||||
|
||||
SlimefunItem sfitem = category.getItems().get(target);
|
||||
|
||||
if (Slimefun.isEnabled(p, sfitem, false)) {
|
||||
if (!sfitem.isDisabledIn(p.getWorld())) {
|
||||
displaySlimefunItem(menu, category, p, profile, sfitem, page, index);
|
||||
index++;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
/**
|
||||
* Represents a category, which structure multiple {@link SlimefunItem} in the {@link SlimefunGuide}.
|
||||
@ -258,7 +257,7 @@ public class Category implements Keyed {
|
||||
*/
|
||||
public boolean isHidden(@Nonnull Player p) {
|
||||
for (SlimefunItem slimefunItem : getItems()) {
|
||||
if (!slimefunItem.isHidden() && Slimefun.isEnabled(p, slimefunItem, false)) {
|
||||
if (!slimefunItem.isHidden() && !slimefunItem.isDisabledIn(p.getWorld())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -380,6 +380,26 @@ public class SlimefunItem implements Placeable {
|
||||
return state != ItemState.ENABLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether this {@link SlimefunItem} is disabled
|
||||
* for that specific {@link World}.
|
||||
* Note that if the item is disabled globally, this method will still return false.
|
||||
*
|
||||
* @param world
|
||||
* The {@link World} to check
|
||||
*
|
||||
* @return Whether this {@link SlimefunItem} is disabled in that world (or in general).
|
||||
*/
|
||||
public boolean isDisabledIn(@Nonnull World world) {
|
||||
if (state == ItemState.UNREGISTERED) {
|
||||
error("isDisabled(World) cannot be called before registering the item", new UnregisteredItemException(this));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the Item is disabled globally or in this specific world
|
||||
return isDisabled() || !SlimefunPlugin.getWorldSettingsService().isEnabled(world, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the {@link SlimefunAddon} that registered this
|
||||
* {@link SlimefunItem}. If this Item is from Slimefun itself, the current
|
||||
|
Loading…
Reference in New Issue
Block a user