diff --git a/plugin/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java b/plugin/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java index 249ae4b..a193327 100644 --- a/plugin/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java +++ b/plugin/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java @@ -2592,10 +2592,10 @@ public class LanguageUtils { messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_SET, langConfig.getString("message.config.set", "&6Changed &a%PROPERTY% &6to &a%VALUE%&6."))); messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_REMOVED, langConfig.getString("message.config.removed", "&6Removed &a%VALUE% &6from &a%PROPERTY%&6."))); messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_ADDED, langConfig.getString("message.config.added", "&6Added &a%VALUE% &6to &a%PROPERTY%&6."))); - messages.add(new LocalizedMessage(Message.VALUE_OF_ITEM_BUY, langConfig.getString("message.valueOfItemBuy", "&6This item is bought by &a%AMOUNT% &6players for an average price of &a%BUY-PRICE%&6."))); - messages.add(new LocalizedMessage(Message.VALUE_OF_ITEM_SELL, langConfig.getString("message.valueOfItemSell", "&6This item is sold by &a%AMOUNT% &6players for an average price of &a%SELL-PRICE%&6."))); - messages.add(new LocalizedMessage(Message.VALUE_NO_SHOPS_BUY, langConfig.getString("message.valueNoShopsBuy", "&cNo shops are currently buying this item."))); - messages.add(new LocalizedMessage(Message.VALUE_NO_SHOPS_SELL, langConfig.getString("message.valueNoShopsSell", "&cNo shops are currently selling this item."))); + messages.add(new LocalizedMessage(Message.VALUE_OF_ITEM_BUY, langConfig.getString("message.valueOfItemBuy", "&6This item can be bought at &a%AMOUNT% &6players for an average price of &a%BUY-PRICE%&6."))); + messages.add(new LocalizedMessage(Message.VALUE_OF_ITEM_SELL, langConfig.getString("message.valueOfItemSell", "&6This item can be sold at &a%AMOUNT% &6players for an average price of &a%SELL-PRICE%&6."))); + messages.add(new LocalizedMessage(Message.VALUE_NO_SHOPS_BUY, langConfig.getString("message.valueNoShopsBuy", "&cNo shops are currently letting you buy this item."))); + messages.add(new LocalizedMessage(Message.VALUE_NO_SHOPS_SELL, langConfig.getString("message.valueNoShopsSell", "&cNo shops are currently letting you sell this item."))); } /** diff --git a/plugin/src/main/java/de/epiceric/shopchest/utils/Utils.java b/plugin/src/main/java/de/epiceric/shopchest/utils/Utils.java index a64bde9..3b95fa1 100644 --- a/plugin/src/main/java/de/epiceric/shopchest/utils/Utils.java +++ b/plugin/src/main/java/de/epiceric/shopchest/utils/Utils.java @@ -10,16 +10,21 @@ import de.epiceric.shopchest.shop.Shop; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Beehive; import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; +import org.bukkit.block.ShulkerBox; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; import java.nio.charset.StandardCharsets; @@ -43,10 +48,7 @@ public class Utils { ItemMeta itemMeta1 = itemStack1.getItemMeta(); ItemMeta itemMeta2 = itemStack2.getItemMeta(); - if (itemMeta1 instanceof BookMeta && itemMeta2 instanceof BookMeta) { - BookMeta bookMeta1 = (BookMeta) itemStack1.getItemMeta(); - BookMeta bookMeta2 = (BookMeta) itemStack2.getItemMeta(); - + if (itemMeta1 instanceof BookMeta bookMeta1 && itemMeta2 instanceof BookMeta bookMeta2) { if ((getMajorVersion() == 9 && getRevision() == 1) || getMajorVersion() == 8) { CustomBookMeta.Generation generation1 = CustomBookMeta.getGeneration(itemStack1); CustomBookMeta.Generation generation2 = CustomBookMeta.getGeneration(itemStack2); @@ -65,6 +67,50 @@ public class Utils { itemStack2 = decode(encode(itemStack2)); } + if (itemMeta1 instanceof BlockStateMeta && itemMeta2 instanceof BlockStateMeta) { + BlockStateMeta blockMeta1 = (BlockStateMeta)itemMeta1; + BlockStateMeta blockMeta2 = (BlockStateMeta)itemMeta2; + + if (blockMeta1.getBlockState() instanceof ShulkerBox box1 && blockMeta2.getBlockState() instanceof ShulkerBox box2) { + + if (!box1.getInventory().isEmpty() && !box2.getInventory().isEmpty()) { + return false; + } + } + } + + if (itemMeta1 instanceof EnchantmentStorageMeta book1 && itemMeta2 instanceof EnchantmentStorageMeta book2) { + + if (book1.hasStoredEnchants() != book2.hasStoredEnchants()) { + return false; + } + + for (Map.Entry enchantment: book1.getStoredEnchants().entrySet()) { + if (!book2.hasStoredEnchant(enchantment.getKey())) { + return false; + } + if (book2.getStoredEnchantLevel(enchantment.getKey()) != enchantment.getValue()) { + return false; + } + } + + //Cross-check for set equivalence + for (Map.Entry enchantment: book2.getStoredEnchants().entrySet()) { + if (!book1.hasStoredEnchant(enchantment.getKey())) { + return false; + } + if (book1.getStoredEnchantLevel(enchantment.getKey()) != enchantment.getValue()) { + return false; + } + } + + return true; + } + + if (itemMeta1 instanceof Beehive b1 && itemMeta2 instanceof Beehive b2) { + return b1.getEntityCount() == b2.getEntityCount(); + } + return itemStack1.isSimilar(itemStack2); } @@ -212,7 +258,7 @@ public class Utils { if (Utils.getMajorVersion() < 13) axes = Arrays.asList("WOOD_AXE", "STONE_AXE", "IRON_AXE", "GOLD_AXE", "DIAMOND_AXE"); else - axes = Arrays.asList("WOODEN_AXE", "STONE_AXE", "IRON_AXE", "GOLDEN_AXE", "DIAMOND_AXE"); + axes = Arrays.asList("WOODEN_AXE", "STONE_AXE", "IRON_AXE", "GOLDEN_AXE", "DIAMOND_AXE", "NETHERITE_AXE"); ItemStack item = getItemInMainHand(p); if (item == null || !axes.contains(item.getType().toString())) {