Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 6, 2024
1 parent 7235008 commit 7002aab
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,15 @@ public ItemLegality legalityOf(ItemStack itemStack) {
}

if (!useWhitelist || blacklistMode == whitelistedTypes.contains(itemStack.getType())) {
if (itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) {
return ItemLegality.ILLEGAL;
if (skipZeroDurability && itemStack.getType().getMaxDurability() == 0) {
return ItemLegality.LEGAL;
}

if (!skipZeroDurability || itemStack.getType().getMaxDurability() != 0) {
if (itemStack.getDurability() > itemStack.getType().getMaxDurability() || itemStack.getDurability() < 0) {
return ItemLegality.ILLEGAL;
}
if (itemStack.getDurability() > itemStack.getType().getMaxDurability() || itemStack.getDurability() < 0) {
return ItemLegality.ILLEGAL;
}

else if (itemStack.getDurability() > 2031) {
if (itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) {
return ItemLegality.ILLEGAL;
}
}
Expand Down Expand Up @@ -102,14 +100,11 @@ public void handleItem(ItemStack itemStack, ItemLegality legality) {
itemStack.setItemMeta(itemMeta);
}

if (!skipZeroDurability || itemStack.getType().getMaxDurability() != 0) {
if (itemStack.getDurability() > itemStack.getType().getMaxDurability() || itemStack.getDurability() < 0) {
itemStack.setDurability(itemStack.getType().getMaxDurability());
itemStack.setItemMeta(itemMeta);
}
if (skipZeroDurability && itemStack.getType().getMaxDurability() == 0) {
return;
}

else if (itemStack.getDurability() > 2031) {
if (itemStack.getDurability() > itemStack.getType().getMaxDurability() || itemStack.getDurability() < 0) {
itemStack.setDurability(itemStack.getType().getMaxDurability());
itemStack.setItemMeta(itemMeta);
}
Expand Down

0 comments on commit 7002aab

Please sign in to comment.