diff --git a/Changelog.txt b/Changelog.txt index 278a9f4d3..d45f0f9b3 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,9 +1,11 @@ Version 2.1.165 + Fixed a bug where Enchanted Books dropped by mcMMO (in Fishing) did not function correctly The mcMMO system which tracks player placed blocks has had some major rewrites (thanks t00thpick1) mcMMO will now be compatible with changes to world height (1.17 compatibility) Added missing cooldown locale message 'Commands.Database.Cooldown' NOTES: + Books dropped before this fix will not be usable and should just be chucked in lava, the broken books have blue names, the working books have yellow names. t00thpick1 has taken time to rewrite our block meta tracking system to be more efficient, easier to maintain, and support upcoming features such as world height changes This new system is compatible with the old one, it will convert old files to the new format as needed. This update shouldn't break anything as the API is the same diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 3e0ec850e..90e909525 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -37,6 +37,7 @@ import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.util.BoundingBox; @@ -466,11 +467,13 @@ public class FishingManager extends SkillManager { EnchantmentWrapper enchantmentWrapper = getRandomEnchantment(fishingTreasureBook.getLegalEnchantments()); ItemMeta itemMeta = itemStack.getItemMeta(); - if(itemMeta == null) + if(itemMeta == null) { return itemStack; + } - itemMeta.addEnchant(enchantmentWrapper.getEnchantment(), enchantmentWrapper.getEnchantmentLevel(), ExperienceConfig.getInstance().allowUnsafeEnchantments()); - itemStack.setItemMeta(itemMeta); + EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) itemMeta; + enchantmentStorageMeta.addStoredEnchant(enchantmentWrapper.getEnchantment(), enchantmentWrapper.getEnchantmentLevel(), ExperienceConfig.getInstance().allowUnsafeEnchantments()); + itemStack.setItemMeta(enchantmentStorageMeta); return itemStack; }