From a00961b8c840627dcf7779a26d385f42aa08cc7d Mon Sep 17 00:00:00 2001 From: drXor Date: Fri, 15 Aug 2014 18:11:09 -0400 Subject: [PATCH] Remove uneeded validation diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index dafc1e60..cf9864dd 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -296,7 +296,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { this.customModelData = meta.customModelData; this.blockData = meta.blockData; - if (meta.hasEnchants()) { + if (meta.enchantments != null) { // Spigot this.enchantments = new LinkedHashMap(meta.enchantments); } @@ -675,7 +675,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } static void applyEnchantments(Map enchantments, NBTTagCompound tag, ItemMetaKey key) { - if (enchantments == null || enchantments.size() == 0) { + if (enchantments == null /*|| enchantments.size() == 0*/) { // Spigot - remove size check return; } @@ -814,7 +814,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { public boolean removeEnchant(Enchantment ench) { Validate.notNull(ench, "Enchantment cannot be null"); - return hasEnchants() && enchantments.remove(ench) != null; + // Spigot start + boolean b = hasEnchants() && enchantments.remove( ench ) != null; + if ( enchantments != null && enchantments.isEmpty() ) + { + this.enchantments = null; + } + return b; + // Spigot end } public boolean hasEnchants() { -- 2.20.1