From b2be908fbb8a4cb9841c9ff6b61b86ca54f2d75b Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Sun, 28 Jul 2013 14:15:52 -0500 Subject: [PATCH] Fix NBT token for attribute names. Addresses BUKKIT-4483 --- .../org/bukkit/craftbukkit/inventory/CraftMetaItem.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index c22087d171..41ce35120a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -184,6 +184,8 @@ class CraftMetaItem implements ItemMeta, Repairable { @Specific(Specific.To.NBT) static final ItemMetaKey ATTRIBUTES = new ItemMetaKey("AttributeModifiers"); @Specific(Specific.To.NBT) + static final ItemMetaKey ATTRIBUTES_IDENTIFIER = new ItemMetaKey("AttributeName"); + @Specific(Specific.To.NBT) static final ItemMetaKey ATTRIBUTES_NAME = new ItemMetaKey("Name"); @Specific(Specific.To.NBT) static final ItemMetaKey ATTRIBUTES_VALUE = new ItemMetaKey("Amount"); @@ -262,7 +264,10 @@ class CraftMetaItem implements ItemMeta, Repairable { if (!(nbttagcompound.get(ATTRIBUTES_UUID_LOW.NBT) instanceof NBTTagLong)) { continue; } - if (!(nbttagcompound.get(ATTRIBUTES_NAME.NBT) instanceof NBTTagString) || !CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES.contains(nbttagcompound.getString(ATTRIBUTES_NAME.NBT))) { + if (!(nbttagcompound.get(ATTRIBUTES_IDENTIFIER.NBT) instanceof NBTTagString) || !CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES.contains(nbttagcompound.getString(ATTRIBUTES_IDENTIFIER.NBT))) { + continue; + } + if (!(nbttagcompound.get(ATTRIBUTES_NAME.NBT) instanceof NBTTagString) || nbttagcompound.getString(ATTRIBUTES_NAME.NBT).isEmpty()) { continue; } if (!(nbttagcompound.get(ATTRIBUTES_VALUE.NBT) instanceof NBTTagDouble)) { @@ -279,6 +284,7 @@ class CraftMetaItem implements ItemMeta, Repairable { NBTTagCompound entry = new NBTTagCompound(); entry.set(ATTRIBUTES_UUID_HIGH.NBT, nbttagcompound.get(ATTRIBUTES_UUID_HIGH.NBT)); entry.set(ATTRIBUTES_UUID_LOW.NBT, nbttagcompound.get(ATTRIBUTES_UUID_LOW.NBT)); + entry.set(ATTRIBUTES_IDENTIFIER.NBT, nbttagcompound.get(ATTRIBUTES_IDENTIFIER.NBT)); entry.set(ATTRIBUTES_NAME.NBT, nbttagcompound.get(ATTRIBUTES_NAME.NBT)); entry.set(ATTRIBUTES_VALUE.NBT, nbttagcompound.get(ATTRIBUTES_VALUE.NBT)); entry.set(ATTRIBUTES_TYPE.NBT, nbttagcompound.get(ATTRIBUTES_TYPE.NBT));