diff options
author | md_5 <git@md-5.net> | 2018-08-30 09:06:10 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-08-30 09:19:46 +1000 |
commit | 28237f03e476ca980c59a5146954649d489fe5bc (patch) | |
tree | 442382287cf222fa1e4de35fd8aa26c19ad3be2b /src/main | |
parent | 3d50da5752316cd9a6de6869d707ef5c247d82c3 (diff) | |
download | bukkit-28237f03e476ca980c59a5146954649d489fe5bc.tar bukkit-28237f03e476ca980c59a5146954649d489fe5bc.tar.gz bukkit-28237f03e476ca980c59a5146954649d489fe5bc.tar.lz bukkit-28237f03e476ca980c59a5146954649d489fe5bc.tar.xz bukkit-28237f03e476ca980c59a5146954649d489fe5bc.zip |
SPIGOT-4330: Improve isSimilar for legacy stacks
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/inventory/ItemStack.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java index 2e44d4e2..c744799f 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -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); } |