Skip to content

Commit

Permalink
simpler code for test if item matches
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCataliasTNT2k committed Aug 11, 2023
1 parent 80a85eb commit e1937d6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/me/ryanhamshire/GriefPrevention/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public static boolean checkHeldItem(ItemStack itemStack) {
//if he's not holding the golden shovel anymore, do nothing
if (itemStack == null)
return false;
ItemMeta heldItem = itemStack.getItemMeta();
ItemMeta toolMeta = GriefPrevention.instance.config_claims_modificationTool.getItemMeta();
if (!(
heldItem.getDisplayName().equals(toolMeta.getDisplayName()) &&
heldItem.getCustomModelData() == toolMeta.getCustomModelData() &&
heldItem.isUnbreakable() == toolMeta.isUnbreakable()
)
)
ItemMeta heldItemMeta = itemStack.getItemMeta();
if (heldItemMeta == null)
return false;
return !heldItem.hasDisplayName() || !toolMeta.hasDisplayName() || heldItem.getDisplayName().equals(toolMeta.getDisplayName());
ItemMeta toolMeta = GriefPrevention.instance.config_claims_modificationTool.getItemMeta();
assert toolMeta != null;
return itemStack.getType() != GriefPrevention.instance.config_claims_modificationTool.getType()
&& heldItemMeta.getCustomModelData() == toolMeta.getCustomModelData()
&& heldItemMeta.isUnbreakable() == toolMeta.isUnbreakable()
&& heldItemMeta.getDisplayName().equals(toolMeta.getDisplayName()
);
}
}

0 comments on commit e1937d6

Please sign in to comment.