Use guard clause instead of nested if statememt

This commit is contained in:
Tomás F 2020-07-01 20:08:15 +01:00
parent 1f079051fa
commit c73fcba252

View File

@ -41,7 +41,10 @@ public class DamageHandler implements Listener {
Player player = (Player) event.getEntity();
PlayerInventory playerInventory = player.getInventory();
if (Stream.of(playerInventory.getArmorContents()).allMatch(Objects::nonNull)) {
if (!Stream.of(playerInventory.getArmorContents()).allMatch(Objects::nonNull)) {
return;
}
if (playerInventory.getHelmet().isSimilar(helmet.getResult()) &&
playerInventory.getChestplate().isSimilar(chestplate.getResult()) &&
playerInventory.getLeggings().isSimilar(leggings.getResult()) &&
@ -51,6 +54,5 @@ public class DamageHandler implements Listener {
}
}
}
}
}