From 7d4fb871bcba7c9e3a3ad8c0b9308e4edcabc263 Mon Sep 17 00:00:00 2001 From: jascotty2 Date: Fri, 16 Aug 2019 12:22:53 -0500 Subject: [PATCH] remove durability check, prefer material and item meta for spawn eggs --- .../listeners/pre/BossSpawnListener.java | 2 +- .../utils/itemstack/ItemStackUtils.java | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/listeners/pre/BossSpawnListener.java b/plugin-modules/Core/src/com/songoda/epicbosses/listeners/pre/BossSpawnListener.java index 6471278..2d8f66b 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/listeners/pre/BossSpawnListener.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/listeners/pre/BossSpawnListener.java @@ -64,7 +64,7 @@ public class BossSpawnListener implements Listener { if(block.getType() == Material.AIR) return; Map entitiesAndSpawnItems = this.bossEntityManager.getMapOfEntitiesAndSpawnItems(); - ItemStack itemStack = this.versionHandler.getItemInHand(player).clone(); + ItemStack itemStack = this.versionHandler.getItemInHand(player); BossEntity bossEntity = null; for(Map.Entry entry : entitiesAndSpawnItems.entrySet()) { diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java index 6ccbacb..57d83ef 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java @@ -60,7 +60,7 @@ public class ItemStackUtils { return new ItemStack(Material.AIR); if (versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_12_R1)) { - return new ItemStack(Material.valueOf("MONSTER_EGG"), spawnableEntityIds.get(entityType)); + return new ItemStack(Material.valueOf("MONSTER_EGG"), 1, spawnableEntityIds.get(entityType)); } else { return new ItemStack(spawnableEntityMaterials.get(entityType)); } @@ -399,7 +399,8 @@ public class ItemStackUtils { public static boolean isItemStackSame(ItemStack itemStack1, ItemStack itemStack2) { if(itemStack1 == null || itemStack2 == null) return false; if(itemStack1.getType() != itemStack2.getType()) return false; - if(itemStack1.getDurability() != itemStack2.getDurability()) return false; + // Durability checks are too tempermental to be reliable for all versions + //if(itemStack1.getDurability() != itemStack2.getDurability()) return false; ItemMeta itemMeta1 = itemStack1.getItemMeta(); ItemMeta itemMeta2 = itemStack2.getItemMeta(); @@ -407,17 +408,15 @@ public class ItemStackUtils { if(itemMeta1 == null || itemMeta2 == null) return false; if(itemMeta1.hasDisplayName() == itemMeta2.hasDisplayName()) { - if(itemMeta1.hasDisplayName()) { - if(!itemMeta1.getDisplayName().equals(itemMeta2.getDisplayName())) return false; - } + if(itemMeta1.hasDisplayName() && !itemMeta1.getDisplayName().equals(itemMeta2.getDisplayName())) + return false; } else { return false; } if(itemMeta1.hasLore() == itemMeta2.hasLore()) { - if(itemMeta1.hasLore()) { - if(!itemMeta1.getLore().equals(itemMeta2.getLore())) return false; - } + if(itemMeta1.hasLore() && !itemMeta1.getLore().equals(itemMeta2.getLore())) + return false; } else { return false; }