From 2012f1e048773ef777a97dd3ebf138e20004f6c8 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 16 Aug 2019 20:57:49 +1000 Subject: [PATCH] SPIGOT-5269: Item attribute modifiers don't persist their order --- .../craftbukkit/inventory/CraftMetaItem.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index e1d9952d39..814dab0c57 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -2,10 +2,10 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.base.Preconditions; import com.google.common.base.Strings; -import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap; @@ -301,7 +301,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } if (meta.hasAttributeModifiers()) { - this.attributeModifiers = HashMultimap.create(meta.attributeModifiers); + this.attributeModifiers = LinkedHashMultimap.create(meta.attributeModifiers); } this.repairCost = meta.repairCost; @@ -415,7 +415,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } static Multimap buildModifiers(NBTTagCompound tag, ItemMetaKey key) { - Multimap modifiers = HashMultimap.create(); + Multimap modifiers = LinkedHashMultimap.create(); if (!tag.hasKeyOfType(key.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { return modifiers; } @@ -576,7 +576,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { static Multimap buildModifiers(Map map, ItemMetaKey key) { Map mods = SerializableMeta.getObject(Map.class, map, key.BUKKIT, true); - Multimap result = HashMultimap.create(); + Multimap result = LinkedHashMultimap.create(); if (mods == null) { return result; } @@ -960,14 +960,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { private void checkAttributeList() { if (attributeModifiers == null) { - attributeModifiers = HashMultimap.create(); + attributeModifiers = LinkedHashMultimap.create(); } } @Override public Multimap getAttributeModifiers(@Nullable EquipmentSlot slot) { checkAttributeList(); - SetMultimap result = HashMultimap.create(); + SetMultimap result = LinkedHashMultimap.create(); for (Map.Entry entry : attributeModifiers.entries()) { if (entry.getValue().getSlot() == null || entry.getValue().getSlot() == slot) { result.put(entry.getKey(), entry.getValue()); @@ -996,7 +996,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Override public void setAttributeModifiers(@Nullable Multimap attributeModifiers) { if (attributeModifiers == null || attributeModifiers.isEmpty()) { - this.attributeModifiers = HashMultimap.create(); + this.attributeModifiers = LinkedHashMultimap.create(); return; } @@ -1192,7 +1192,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { clone.enchantments = new LinkedHashMap(this.enchantments); } if (this.hasAttributeModifiers()) { - clone.attributeModifiers = HashMultimap.create(this.attributeModifiers); + clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers); } clone.hideFlag = this.hideFlag; clone.unbreakable = this.unbreakable;