13
0
geforkt von Mirrors/Paper

SPIGOT-6716: Preserve the order of stored enchantments of enchanted books.

In some cases, differences in this order can result in item stack
comparisons to fails.

By: blablubbabc <lukas@wirsindwir.de>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2021-08-20 19:40:31 +10:00
Ursprung 973f763605
Commit 9c5dd3b837

Datei anzeigen

@ -2,7 +2,7 @@ package org.bukkit.craftbukkit.inventory;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import net.minecraft.nbt.NBTTagCompound;
import org.bukkit.Material;
@ -28,7 +28,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
CraftMetaEnchantedBook that = (CraftMetaEnchantedBook) meta;
if (that.hasEnchants()) {
this.enchantments = new HashMap<Enchantment, Integer>(that.enchantments);
this.enchantments = new LinkedHashMap<Enchantment, Integer>(that.enchantments);
}
}
@ -105,7 +105,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
CraftMetaEnchantedBook meta = (CraftMetaEnchantedBook) super.clone();
if (this.enchantments != null) {
meta.enchantments = new HashMap<Enchantment, Integer>(this.enchantments);
meta.enchantments = new LinkedHashMap<Enchantment, Integer>(this.enchantments);
}
return meta;
@ -146,7 +146,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
@Override
public boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
if (enchantments == null) {
enchantments = new HashMap<Enchantment, Integer>(4);
enchantments = new LinkedHashMap<Enchantment, Integer>(4);
}
if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) {