diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java index 6a303d56..73fa4bcd 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java @@ -1,5 +1,6 @@ package net.Indyuce.mmocore.api.util; +import com.google.common.collect.MultimapBuilder; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.gson.JsonArray; @@ -16,6 +17,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; @@ -116,6 +118,18 @@ public class MMOCoreUtils { return material == Material.PLAYER_HEAD || material == Material.PLAYER_WALL_HEAD; } + public static void addAllItemFlags(@NotNull ItemMeta meta) { + meta.addItemFlags(ItemFlag.values()); + + // Fix 1.20.6+ Paper bug that sucks. HIDE_ATTRIBUTES no longer works when item attribute list is empty + // TODO refactor with GUI update. + try { + meta.setAttributeModifiers(MultimapBuilder.hashKeys(0).hashSetValues(0).build()); + } catch (Exception exception) { + // Not needed + } + } + @NotNull public static ItemStack readIcon(String string) { final String[] split = string.split(":"); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java index 561a2ed3..d28fba32 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java @@ -21,7 +21,6 @@ import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; @@ -71,7 +70,7 @@ public class ClassSelect extends EditableInventory { public ItemStack display(ProfessSelectionInventory inv, int n) { ItemStack item = n == 0 ? playerClass.getIcon() : super.display(inv, n); ItemMeta meta = item.getItemMeta(); - if (hideFlags()) meta.addItemFlags(ItemFlag.values()); + if (hideFlags()) MMOCoreUtils.addAllItemFlags(meta); if (hideTooltip()) meta.setHideTooltip(true); meta.setDisplayName(MythicLib.plugin.parseColors(name).replace("{name}", playerClass.getName())); List lore = new ArrayList<>(this.lore); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java index 5db51182..6cf850d5 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java @@ -8,6 +8,7 @@ import net.Indyuce.mmocore.api.SoundEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.profess.ClassOption; import net.Indyuce.mmocore.api.player.profess.PlayerClass; +import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.InventoryClickContext; @@ -62,7 +63,7 @@ public class SubclassSelect extends EditableInventory { public ItemStack display(SubclassSelectionInventory inv, int n) { ItemStack item = n == 0 ? playerClass.getIcon() : super.display(inv, n); ItemMeta meta = item.getItemMeta(); - if (hideFlags()) meta.addItemFlags(ItemFlag.values()); + if (hideFlags()) MMOCoreUtils.addAllItemFlags(meta); if (hideTooltip()) meta.setHideTooltip(true); meta.setDisplayName(MythicLib.plugin.parseColors(name).replace("{name}", playerClass.getName())); List lore = new ArrayList<>(this.lore); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/WaypointViewer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/WaypointViewer.java index 821b84f4..91a20dfe 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/WaypointViewer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/WaypointViewer.java @@ -1,10 +1,10 @@ package net.Indyuce.mmocore.gui; -import io.lumine.mythic.lib.UtilityMethods; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.ConfigMessage; import net.Indyuce.mmocore.api.player.PlayerActivity; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.InventoryClickContext; @@ -14,12 +14,13 @@ import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.waypoint.Waypoint; import net.Indyuce.mmocore.waypoint.WaypointPath; import org.apache.commons.lang.Validate; -import org.bukkit.*; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.OfflinePlayer; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; import org.jetbrains.annotations.Nullable; @@ -151,7 +152,7 @@ public class WaypointViewer extends EditableInventory { if (hasName()) meta.setDisplayName(placeholders.apply(effectivePlayer, getName())); - if (hideFlags()) meta.addItemFlags(ItemFlag.values()); + if (hideFlags()) MMOCoreUtils.addAllItemFlags(meta); if (hideTooltip()) meta.setHideTooltip(true); // If a player can teleport to another waypoint given his location Waypoint waypoint = inv.waypoints.get(inv.page * inv.getEditable().getByFunction("waypoint").getSlots().size() + n); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java index b68188fc..f0ef7a8e 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java @@ -2,13 +2,13 @@ package net.Indyuce.mmocore.gui.api.item; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.UtilityMethods; +import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; @@ -157,8 +157,8 @@ public abstract class InventoryItem { if (hasName()) meta.setDisplayName(placeholders.apply(effectivePlayer, getName())); - if (hideFlags()) meta.addItemFlags(ItemFlag.values()); if (hideTooltip()) meta.setHideTooltip(true); + if (hideFlags()) MMOCoreUtils.addAllItemFlags(meta); if (hasLore()) { List lore = new ArrayList<>();