SPIGOT-4330: Improve isSimilar for legacy stacks

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2018-08-30 09:06:10 +10:00
parent 6ea05f1541
commit 7c0a97e876

View file

@ -120,6 +120,8 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
}
if (type.isLegacy()) {
createData((byte) 0);
} else {
this.data = null;
}
}
@ -263,7 +265,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
if (stack == this) {
return true;
}
Material comparisonType = Bukkit.getUnsafe().fromLegacy(this.getType()); // This may be called from legacy item stacks, try to get the right material
Material comparisonType = (this.type.isLegacy()) ? Bukkit.getUnsafe().fromLegacy(this.getData(), true) : this.type; // This may be called from legacy item stacks, try to get the right material
return comparisonType == stack.getType() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true);
}