SPIGOT-4122: Fix an instance of legacy item inequalities

This commit is contained in:
md_5 2018-07-24 08:57:58 +10:00
parent 38adf52b28
commit ea7b61290a
2 changed files with 7 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import org.bukkit.material.MaterialData;
import com.google.common.collect.ImmutableMap;
import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
import org.bukkit.craftbukkit.util.CraftLegacy;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
@DelegateDeserialization(ItemStack.class)
@ -545,7 +546,8 @@ public final class CraftItemStack extends ItemStack {
if (handle == null || that.handle == null) {
return false;
}
if (!(that.getType() == getType() && getDurability() == that.getDurability())) {
Material comparisonType = CraftLegacy.fromLegacy(that.getType()); // This may be called from legacy item stacks, try to get the right material
if (!(comparisonType == getType() && getDurability() == that.getDurability())) {
return false;
}
return hasItemMeta() ? that.hasItemMeta() && handle.getTag().equals(that.handle.getTag()) : !that.hasItemMeta();

View File

@ -147,6 +147,10 @@ public class CraftLegacy {
}
public static Material fromLegacy(Material material) {
if (material == null || !material.isLegacy()) {
return material;
}
return fromLegacy(new MaterialData(material));
}