From cac50e9c559e79e2b1d8a1de262e20947cbdccec Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 13 Mar 2022 06:58:41 +1100 Subject: [PATCH] SPIGOT-6961: Actually return a copy of the ItemMeta By: DerFrZocker --- .../bukkit/craftbukkit/inventory/CraftMetaArmorStand.java | 2 +- .../craftbukkit/inventory/CraftMetaAxolotlBucket.java | 2 +- .../bukkit/craftbukkit/inventory/CraftMetaBlockState.java | 2 +- .../bukkit/craftbukkit/inventory/CraftMetaEntityTag.java | 2 +- .../org/bukkit/craftbukkit/inventory/CraftMetaItem.java | 6 +++--- .../org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java | 2 +- .../craftbukkit/inventory/CraftMetaTropicalFishBucket.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java index 23dd7e15a5..d3d726c733 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java @@ -29,7 +29,7 @@ public class CraftMetaArmorStand extends CraftMetaItem { super(tag); if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); + entityTag = tag.getCompound(ENTITY_TAG.NBT).copy(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java index 1d0de7f864..30ba34f7e3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java @@ -39,7 +39,7 @@ public class CraftMetaAxolotlBucket extends CraftMetaItem implements AxolotlBuck } if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); + entityTag = tag.getCompound(ENTITY_TAG.NBT).copy(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index 1018ac70f5..b78b4ba1fc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -45,7 +45,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta this.material = material; if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - blockEntityTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT); + blockEntityTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT).copy(); } else { blockEntityTag = null; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java index 4cf62913f7..796bd6dcf9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java @@ -29,7 +29,7 @@ public class CraftMetaEntityTag extends CraftMetaItem { super(tag); if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); + entityTag = tag.getCompound(ENTITY_TAG.NBT).copy(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index b3ab8c56c6..92005c2df3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -349,7 +349,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { customModelData = tag.getInt(CUSTOM_MODEL_DATA.NBT); } if (tag.contains(BLOCK_DATA.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - blockData = tag.getCompound(BLOCK_DATA.NBT); + blockData = tag.getCompound(BLOCK_DATA.NBT).copy(); } this.enchantments = buildEnchantments(tag, ENCHANTMENTS); @@ -372,14 +372,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { NBTTagCompound compound = tag.getCompound(BUKKIT_CUSTOM_TAG.NBT); Set keys = compound.getAllKeys(); for (String key : keys) { - persistentDataContainer.put(key, compound.get(key)); + persistentDataContainer.put(key, compound.get(key).copy()); } } Set keys = tag.getAllKeys(); for (String key : keys) { if (!getHandledTags().contains(key)) { - unhandledTags.put(key, tag.get(key)); + unhandledTags.put(key, tag.get(key).copy()); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java index d47676e13f..7dbe9d9751 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java @@ -41,7 +41,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { super(tag); if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); + entityTag = tag.getCompound(ENTITY_TAG.NBT).copy(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java index c9e131614c..b90b1ef6a1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java @@ -42,7 +42,7 @@ class CraftMetaTropicalFishBucket extends CraftMetaItem implements TropicalFishB } if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); + entityTag = tag.getCompound(ENTITY_TAG.NBT).copy(); } }