mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
SPIGOT-4686: Enchantment ordering nondeterministic
This commit is contained in:
parent
4c8327f721
commit
0bf75bbde2
@ -64,6 +64,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -279,7 +280,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (meta.hasEnchants()) {
|
if (meta.hasEnchants()) {
|
||||||
this.enchantments = new HashMap<Enchantment, Integer>(meta.enchantments);
|
this.enchantments = new LinkedHashMap<Enchantment, Integer>(meta.enchantments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta.hasAttributeModifiers()) {
|
if (meta.hasAttributeModifiers()) {
|
||||||
@ -368,7 +369,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NBTTagList ench = tag.getList(key.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
|
NBTTagList ench = tag.getList(key.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
|
||||||
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>(ench.size());
|
Map<Enchantment, Integer> enchantments = new LinkedHashMap<Enchantment, Integer>(ench.size());
|
||||||
|
|
||||||
for (int i = 0; i < ench.size(); i++) {
|
for (int i = 0; i < ench.size(); i++) {
|
||||||
String id = ((NBTTagCompound) ench.get(i)).getString(ENCHANTMENTS_ID.NBT);
|
String id = ((NBTTagCompound) ench.get(i)).getString(ENCHANTMENTS_ID.NBT);
|
||||||
@ -516,7 +517,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>(ench.size());
|
Map<Enchantment, Integer> enchantments = new LinkedHashMap<Enchantment, Integer>(ench.size());
|
||||||
for (Map.Entry<?, ?> entry : ench.entrySet()) {
|
for (Map.Entry<?, ?> entry : ench.entrySet()) {
|
||||||
// Doctor older enchants
|
// Doctor older enchants
|
||||||
String enchantKey = entry.getKey().toString();
|
String enchantKey = entry.getKey().toString();
|
||||||
@ -757,7 +758,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
|||||||
public boolean addEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
|
public boolean addEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
|
||||||
Validate.notNull(ench, "Enchantment cannot be null");
|
Validate.notNull(ench, "Enchantment cannot be null");
|
||||||
if (enchantments == null) {
|
if (enchantments == null) {
|
||||||
enchantments = new HashMap<Enchantment, Integer>(4);
|
enchantments = new LinkedHashMap<Enchantment, Integer>(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) {
|
if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) {
|
||||||
@ -1077,7 +1078,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
|||||||
clone.lore = new ArrayList<String>(this.lore);
|
clone.lore = new ArrayList<String>(this.lore);
|
||||||
}
|
}
|
||||||
if (this.enchantments != null) {
|
if (this.enchantments != null) {
|
||||||
clone.enchantments = new HashMap<Enchantment, Integer>(this.enchantments);
|
clone.enchantments = new LinkedHashMap<Enchantment, Integer>(this.enchantments);
|
||||||
}
|
}
|
||||||
if (this.hasAttributeModifiers()) {
|
if (this.hasAttributeModifiers()) {
|
||||||
clone.attributeModifiers = HashMultimap.create(this.attributeModifiers);
|
clone.attributeModifiers = HashMultimap.create(this.attributeModifiers);
|
||||||
@ -1182,7 +1183,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, List<Object>> mods = new HashMap<>();
|
Map<String, List<Object>> mods = new LinkedHashMap<>();
|
||||||
for (Map.Entry<Attribute, AttributeModifier> entry : modifiers.entries()) {
|
for (Map.Entry<Attribute, AttributeModifier> entry : modifiers.entries()) {
|
||||||
if (entry.getKey() == null) {
|
if (entry.getKey() == null) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user