1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2021-02-07 12:30:55 +01:00
parent 9e83b4af00
commit e47d0171cc
5 changed files with 25 additions and 4 deletions

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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++;
}

View File

@ -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;
}
}

View File

@ -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