1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

Items to sell/buy must have the same name

This commit is contained in:
KaiKikuchi 2015-07-25 23:54:40 +02:00
parent 3755036137
commit 211e298e77

View File

@ -789,7 +789,7 @@ public class Util {
* The first item stack * The first item stack
* @param stack2 * @param stack2
* The second item stack * 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) { public static boolean matches(ItemStack stack1, ItemStack stack2) {
if (stack1 == stack2) if (stack1 == stack2)
@ -802,6 +802,15 @@ public class Util {
return false; // Not the same durability return false; // Not the same durability
if (!stack1.getEnchantments().equals(stack2.getEnchantments())) if (!stack1.getEnchantments().equals(stack2.getEnchantments()))
return false; // They have the same enchants 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 { try {
Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta"); Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta");
boolean book1 = stack1.getItemMeta() instanceof EnchantmentStorageMeta; boolean book1 = stack1.getItemMeta() instanceof EnchantmentStorageMeta;