From 6c02dbcfa137f40418fc56a0a85721b1fa0242ff Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 11 May 2024 09:14:16 -0700 Subject: [PATCH] handle recent ItemMeta changes in serialization logic --- .../server/1044-General-ItemMeta-fixes.patch | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/patches/server/1044-General-ItemMeta-fixes.patch b/patches/server/1044-General-ItemMeta-fixes.patch index a8c0ab60dd..d05a17dbe7 100644 --- a/patches/server/1044-General-ItemMeta-fixes.patch +++ b/patches/server/1044-General-ItemMeta-fixes.patch @@ -260,7 +260,7 @@ index 8e0dd4b7a7a25a8beb27b507047bc48d8227627c..cf5d27ccc2225bac3aa57912f444f95d @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index 0bc100430483f88bc7edf17645250b2862ccc1d5..c81d8e09c6f6ac4cec9cd57e9af41a9a60b24bb1 100644 +index 0bc100430483f88bc7edf17645250b2862ccc1d5..db3e74f22f555e3bb5b304af303cdd46a5377894 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -165,9 +165,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -296,6 +296,15 @@ index 0bc100430483f88bc7edf17645250b2862ccc1d5..c81d8e09c6f6ac4cec9cd57e9af41a9a CraftMetaItem.getOrEmpty(tag, CraftMetaItem.NAME).ifPresent((component) -> { this.displayName = component; }); +@@ -725,7 +731,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + Map mods = SerializableMeta.getObject(Map.class, map, key.BUKKIT, true); + Multimap result = LinkedHashMultimap.create(); + if (mods == null) { +- return result; ++ return null; // Paper - null is different from an empty map + } + + for (Object obj : mods.keySet()) { @@ -879,10 +885,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } @@ -386,6 +395,15 @@ index 0bc100430483f88bc7edf17645250b2862ccc1d5..c81d8e09c6f6ac4cec9cd57e9af41a9a clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers); } if (this.customTag != null) { +@@ -1787,7 +1795,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + } + + static void serializeModifiers(Multimap modifiers, ImmutableMap.Builder builder, ItemMetaKey key) { +- if (modifiers == null || modifiers.isEmpty()) { ++ if (modifiers == null/* || modifiers.isEmpty()*/) { // Paper - null and an empty map have different behaviors + return; + } + @@ -1869,7 +1877,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { // Paper start - improve checking handled tags @org.jetbrains.annotations.VisibleForTesting