mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-25 01:31:29 +01:00
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>
This commit is contained in:
parent
973f763605
commit
9c5dd3b837
@ -2,7 +2,7 @@ package org.bukkit.craftbukkit.inventory;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
import java.util.HashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -28,7 +28,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
|
|||||||
CraftMetaEnchantedBook that = (CraftMetaEnchantedBook) meta;
|
CraftMetaEnchantedBook that = (CraftMetaEnchantedBook) meta;
|
||||||
|
|
||||||
if (that.hasEnchants()) {
|
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();
|
CraftMetaEnchantedBook meta = (CraftMetaEnchantedBook) super.clone();
|
||||||
|
|
||||||
if (this.enchantments != null) {
|
if (this.enchantments != null) {
|
||||||
meta.enchantments = new HashMap<Enchantment, Integer>(this.enchantments);
|
meta.enchantments = new LinkedHashMap<Enchantment, Integer>(this.enchantments);
|
||||||
}
|
}
|
||||||
|
|
||||||
return meta;
|
return meta;
|
||||||
@ -146,7 +146,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
|
|||||||
@Override
|
@Override
|
||||||
public boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
|
public boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
|
||||||
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()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user