From 1c6adc158776cd267a891529a781ac1daef4d721 Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 20 Dec 2011 00:30:54 +1100 Subject: [PATCH] Fix error when cloning enchanted ItemStacks. The existing method for cloning a Bukkit ItemStack fails to correctly copy the underlying enchantments. Fix this by overriding .clone() in CraftItemStack, cloning the underlying nms ItemStack correctly. Fixes BUKKIT-360 --- .../org/bukkit/craftbukkit/inventory/CraftItemStack.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index cd6212727f..c0854276d1 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -210,6 +210,11 @@ public class CraftItemStack extends ItemStack { return item; } + @Override + public CraftItemStack clone() { + return new CraftItemStack(this.item.cloneItemStack()); + } + public static net.minecraft.server.ItemStack createNMSItemStack(ItemStack original) { return new CraftItemStack(original).getHandle(); }