summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-07-24 08:57:58 +1000
committermd_5 <git@md-5.net>2018-07-24 08:57:58 +1000
commitea7b61290a39f0ab355d7a723907ed312f713b05 (patch)
tree42976990d5c1f9ea1c17eeb2bc05a5e1b919f309 /src
parent38adf52b28859a5d2d54909b622784177ae62b85 (diff)
downloadcraftbukkit-ea7b61290a39f0ab355d7a723907ed312f713b05.tar
craftbukkit-ea7b61290a39f0ab355d7a723907ed312f713b05.tar.gz
craftbukkit-ea7b61290a39f0ab355d7a723907ed312f713b05.tar.lz
craftbukkit-ea7b61290a39f0ab355d7a723907ed312f713b05.tar.xz
craftbukkit-ea7b61290a39f0ab355d7a723907ed312f713b05.zip
SPIGOT-4122: Fix an instance of legacy item inequalities
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java4
2 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index d7fb0acb..f4672b9a 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -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();
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java
index ea2fa6f4..ea6b8885 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java
@@ -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));
}