Fix enchanted books not being created with the proper data

This commit is contained in:
nossr50 2020-12-31 13:21:55 -08:00
parent 006a7bf277
commit aed4cb87be
2 changed files with 8 additions and 3 deletions

View File

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

View File

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