diff --git a/CHANGELOG.md b/CHANGELOG.md index d5e7bd87a..8fd5d8023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,9 @@ * Fixed "Lands" integration * Fixed #3133 * Fixed #3483 +* Fixed #3469 +* Fixed #3476 +* Fixed #3487 ## Release Candidate 30 (31 Dec 2021) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#30 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java index ec07e6143..9de395309 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java @@ -663,7 +663,8 @@ public class SlimefunItem implements Placeable { /** * Sets the recipe for this {@link SlimefunItem}. * - * @param recipe The recipe for this {@link ItemStack} + * @param recipe + * The recipe for this {@link ItemStack} */ public void setRecipe(@Nonnull ItemStack[] recipe) { if (recipe == null || recipe.length != 9) { @@ -676,7 +677,8 @@ public class SlimefunItem implements Placeable { /** * Sets the {@link RecipeType} for this {@link SlimefunItem}. * - * @param type The {@link RecipeType} for this {@link SlimefunItem} + * @param type + * The {@link RecipeType} for this {@link SlimefunItem} */ public void setRecipeType(@Nonnull RecipeType type) { Validate.notNull(type, "The RecipeType is not allowed to be null!"); @@ -1135,7 +1137,8 @@ public class SlimefunItem implements Placeable { /** * Retrieve a {@link SlimefunItem} by its id. * - * @param id The id of the {@link SlimefunItem} + * @param id + * The id of the {@link SlimefunItem} * @return The {@link SlimefunItem} associated with that id. Null if non-existent */ public static @Nullable SlimefunItem getById(@Nonnull String id) { @@ -1145,7 +1148,8 @@ public class SlimefunItem implements Placeable { /** * Retrieve a {@link SlimefunItem} from an {@link ItemStack}. * - * @param item The {@link ItemStack} to check + * @param item + * The {@link ItemStack} to check * @return The {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise null */ public static @Nullable SlimefunItem getByItem(@Nullable ItemStack item) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index 3ff27e619..047a696a6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -33,6 +33,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.groups.SubItemGroup; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.api.researches.Research; @@ -360,9 +361,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { break; } - boolean isItemGroupHidden = showHiddenItemGroupsInSearch || !slimefunItem.getItemGroup().isHidden(p); - - if (!slimefunItem.isHidden() && isItemGroupHidden && isSearchFilterApplicable(slimefunItem, searchTerm)) { + if (!slimefunItem.isHidden() && !isItemGroupHidden(p, slimefunItem) && isSearchFilterApplicable(slimefunItem, searchTerm)) { ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); @@ -391,6 +390,22 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { menu.open(p); } + @ParametersAreNonnullByDefault + private boolean isItemGroupHidden(Player p, SlimefunItem slimefunItem) { + if (showHiddenItemGroupsInSearch) { + return false; + } + + ItemGroup itemGroup = slimefunItem.getItemGroup(); + + // Fixes #3487 - SubItemGroups are "pseudo-hidden" + if (itemGroup instanceof SubItemGroup) { + return false; + } else { + return itemGroup.isHidden(p); + } + } + @ParametersAreNonnullByDefault private boolean isSearchFilterApplicable(SlimefunItem slimefunItem, String searchTerm) { String itemName = ChatColor.stripColor(slimefunItem.getItemName()).toLowerCase(Locale.ROOT); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 4187d19b6..30071db6f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -164,8 +164,8 @@ public class AncientAltarListener implements Listener { * Drop the item instead if the player's inventory is full and * no stack space left else add remaining items from the returned map value */ - Map remainingItemMap = p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); - + Map remainingItemMap = p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); + for (ItemStack item : remainingItemMap.values()) { p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), item.clone()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index 343c90ab3..b35d48292 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -1,7 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; -import java.util.Optional; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -16,10 +14,12 @@ import org.bukkit.event.inventory.InventoryType.SlotType; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; + import me.mrCookieSlime.Slimefun.api.BlockStorage; /** - * The {@link MiddleClickListener} is responsible for listening to the {@link InventoryCreativeEvent}. + * The {@link MiddleClickListener} is responsible for listening to + * the {@link InventoryCreativeEvent}. * * @author svr333 * @@ -30,7 +30,7 @@ public class MiddleClickListener implements Listener { plugin.getServer().getPluginManager().registerEvents(this, plugin); } - /* + /* * General Discloser: this event has really really really weird behavior on middle click. * Has been tested thoroughly to make sure it doesnt break anything else. */ @@ -58,8 +58,8 @@ public class MiddleClickListener implements Listener { if (sfItem == null) { return; } - - /* + + /* * Before giving the item to the user, check if you can swap * to the item instead (user already has item in hotbar). * This is sometimes bypassed by the client itself (not fixable though). @@ -85,7 +85,7 @@ public class MiddleClickListener implements Listener { * to the actual block that is middle clicked, while currentItem will be AIR. * * This check is really weird due to the weird nature of this event's behaviour. - * It checks if the block the player is looking at is of the same type as the cursor; + * It checks if the block the player is looking at is of the same type as the cursor, * after this we can make sure that it is a middle click outside of the inventory * currentItem should also be air, otherwise it is not outside of the inventory */