diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java index eae45fd7..cb12e13d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java @@ -77,8 +77,8 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin { return EnchantDisplay.displayEnchantments(itemStack, hideEnchants); }, 500, this.getPluginName())); + Display.registerRevertModule(EnchantDisplay::revertDisplay); - Display.registerFinalizeModule(EnchantDisplay::addV); this.getExtensionLoader().loadExtensions(); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java index 08b6d29c..2f6038c6 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -43,13 +43,6 @@ public class EnchantDisplay { */ public static final NamespacedKey KEY_SKIP = PLUGIN.getNamespacedKeyFactory().create("ecoenchantlore-skip"); - /** - * The meta key to notify the server that an item is from a villager trade. - *

- * Bit of a bodge - plan on making it better. - */ - public static final NamespacedKey KEY_V = PLUGIN.getNamespacedKeyFactory().create("ecoenchantlore-v"); - /** * The prefix for all enchantment lines to have in lore. */ @@ -69,25 +62,6 @@ public class EnchantDisplay { EnchantmentCache.update(); } - /** - * Bodge to fix hidden enchantments from villagers. - *

- * It isn't recommended to mess with this unless you really know your way around EcoEnchants. - * - * @param item The item to modify. - * @return The item, with KEY_V. - */ - public static ItemStack addV(@Nullable final ItemStack item) { - if (item == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType()) || item.getItemMeta() == null) { - return item; - } - - ItemMeta meta = item.getItemMeta(); - meta.getPersistentDataContainer().set(KEY_V, PersistentDataType.INTEGER, 1); - item.setItemMeta(meta); - return item; - } - /** * Revert display. * @@ -112,9 +86,6 @@ public class EnchantDisplay { itemLore = new ArrayList<>(); } - if (meta.getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER)) { - meta.getPersistentDataContainer().remove(KEY_V); - } itemLore.removeIf(s -> s.startsWith(PREFIX)); if (!meta.getPersistentDataContainer().has(KEY_SKIP, PersistentDataType.INTEGER)) { @@ -144,22 +115,15 @@ public class EnchantDisplay { * Show all enchantments in item lore. * * @param item The item to update. - * @param hideEnchants If enchantments should be hidden. + * @param hide If enchantments should be hidden. * @return The item, updated. */ public static ItemStack displayEnchantments(@Nullable final ItemStack item, - final boolean hideEnchants) { - boolean hide = hideEnchants; + final boolean hide) { if (item == null || item.getItemMeta() == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType())) { return item; } - if (item.getItemMeta().getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER) && hideEnchants) { - hide = false; - } - - revertDisplay(item); - ItemMeta meta = item.getItemMeta(); if (meta == null) { return item; @@ -203,9 +167,7 @@ public class EnchantDisplay { OPTIONS.getSorter().sortEnchantments(unsorted); enchantments.clear(); - unsorted.forEach(enchantment -> { - enchantments.put(enchantment, tempEnchantments.get(enchantment)); - }); + unsorted.forEach(enchantment -> enchantments.put(enchantment, tempEnchantments.get(enchantment))); enchantments.forEach((enchantment, level) -> { if (EcoEnchants.getFromEnchantment(enchantment) == null) { diff --git a/gradle.properties b/gradle.properties index 2d5980a1..d40f45c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 6.3.0 +version = 6.3.1 plugin-name = EcoEnchants \ No newline at end of file