From 2a8b311dfb8a26d0aa33efb8b368bb29b62e85ab Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 16 Jul 2024 11:36:07 -0700 Subject: [PATCH] distinguish between null and empty map in API (#10829) --- patches/api/General-ItemMeta-fixes.patch | 16 ++++++++++++++++ patches/server/General-ItemMeta-fixes.patch | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/patches/api/General-ItemMeta-fixes.patch b/patches/api/General-ItemMeta-fixes.patch index dbb6f9c61f..a8609adc94 100644 --- a/patches/api/General-ItemMeta-fixes.patch +++ b/patches/api/General-ItemMeta-fixes.patch @@ -71,3 +71,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Checks to see if this item has a maximum amount of damage. * +diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java ++++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + + /** + * Set all {@link Attribute}s and their {@link AttributeModifier}s. +- * To clear all currently set Attributes and AttributeModifiers use +- * null or an empty Multimap. ++ * To clear all custom attribute modifiers, use {@code null}. To set ++ * no modifiers (which will override the default modifiers), use an ++ * empty map. + * If not null nor empty, this will filter all entries that are not-null + * and add them to the ItemStack. + * diff --git a/patches/server/General-ItemMeta-fixes.patch b/patches/server/General-ItemMeta-fixes.patch index 1b98caf488..79cb8e3839 100644 --- a/patches/server/General-ItemMeta-fixes.patch +++ b/patches/server/General-ItemMeta-fixes.patch @@ -954,7 +954,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return this.attributeModifiers.put(attribute, modifier); } -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + @Override + public void setAttributeModifiers(@Nullable Multimap attributeModifiers) { +- if (attributeModifiers == null || attributeModifiers.isEmpty()) { ++ // Paper start - distinguish between null and empty ++ if (attributeModifiers == null) { ++ this.attributeModifiers = null; ++ return; ++ } ++ if (attributeModifiers.isEmpty()) { ++ // Paper end - distinguish between null and empty + this.attributeModifiers = LinkedHashMultimap.create(); return; }