remove durability check, prefer material and item meta for spawn eggs

This commit is contained in:
jascotty2 2019-08-16 12:22:53 -05:00
parent cfa18f7c3f
commit 7d4fb871bc
2 changed files with 8 additions and 9 deletions

View File

@ -64,7 +64,7 @@ public class BossSpawnListener implements Listener {
if(block.getType() == Material.AIR) return;
Map<BossEntity, ItemStack> entitiesAndSpawnItems = this.bossEntityManager.getMapOfEntitiesAndSpawnItems();
ItemStack itemStack = this.versionHandler.getItemInHand(player).clone();
ItemStack itemStack = this.versionHandler.getItemInHand(player);
BossEntity bossEntity = null;
for(Map.Entry<BossEntity, ItemStack> entry : entitiesAndSpawnItems.entrySet()) {

View File

@ -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;
}