SPIGOT-4122: Fix an instance of legacy item inequalities

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2018-07-24 08:57:58 +10:00
parent c03c42de6c
commit f69e943876
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));
}