From 211e298e7739dd91a8a8669f8cfd63d73f76b75c Mon Sep 17 00:00:00 2001 From: KaiKikuchi Date: Sat, 25 Jul 2015 23:54:40 +0200 Subject: [PATCH] Items to sell/buy must have the same name --- src/main/java/org/maxgamer/quickshop/Util/Util.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index dc4d8c8..093b629 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -789,7 +789,7 @@ public class Util { * The first item stack * @param stack2 * The second item stack - * @return true if the itemstacks match. (Material, durability, enchants) + * @return true if the itemstacks match. (Material, durability, enchants, name) */ public static boolean matches(ItemStack stack1, ItemStack stack2) { if (stack1 == stack2) @@ -802,6 +802,15 @@ public class Util { return false; // Not the same durability if (!stack1.getEnchantments().equals(stack2.getEnchantments())) return false; // They have the same enchants + if (stack1.getItemMeta().hasDisplayName() || stack2.getItemMeta().hasDisplayName()) { + if (stack1.getItemMeta().hasDisplayName() && stack2.getItemMeta().hasDisplayName()) { + if (!stack1.getItemMeta().getDisplayName().equals(stack2.getItemMeta().getDisplayName())) { + return false; // items have different display name + } + } else { + return false; // one of the item stacks have a display name + } + } try { Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta"); boolean book1 = stack1.getItemMeta() instanceof EnchantmentStorageMeta;