handle recent ItemMeta changes in serialization logic

This commit is contained in:
Jake Potrebic 2024-05-11 09:14:16 -07:00
parent c5fb79b218
commit b71a9db7ad

View file

@ -296,6 +296,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
CraftMetaItem.getOrEmpty(tag, CraftMetaItem.NAME).ifPresent((component) -> {
this.displayName = component;
});
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
Map<?, ?> mods = SerializableMeta.getObject(Map.class, map, key.BUKKIT, true);
Multimap<Attribute, AttributeModifier> result = LinkedHashMultimap.create();
if (mods == null) {
- return result;
+ return null; // Paper - null is different from an empty map
}
for (Object obj : mods.keySet()) {
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
}
@ -386,6 +395,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
}
if (this.customTag != null) {
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
}
static void serializeModifiers(Multimap<Attribute, AttributeModifier> modifiers, ImmutableMap.Builder<String, Object> builder, ItemMetaKey key) {
- if (modifiers == null || modifiers.isEmpty()) {
+ if (modifiers == null/* || modifiers.isEmpty()*/) { // Paper - null and an empty map have different behaviors
return;
}
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper start - improve checking handled tags
@org.jetbrains.annotations.VisibleForTesting