mirror of
https://github.com/tomasff/BeesPlus.git
synced 2024-11-22 01:56:28 +01:00
Use guard clause instead of nested if statememt
This commit is contained in:
parent
1f079051fa
commit
c73fcba252
@ -41,14 +41,16 @@ public class DamageHandler implements Listener {
|
||||
Player player = (Player) event.getEntity();
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
|
||||
if (Stream.of(playerInventory.getArmorContents()).allMatch(Objects::nonNull)) {
|
||||
if (playerInventory.getHelmet().isSimilar(helmet.getResult()) &&
|
||||
playerInventory.getChestplate().isSimilar(chestplate.getResult()) &&
|
||||
playerInventory.getLeggings().isSimilar(leggings.getResult()) &&
|
||||
playerInventory.getBoots().isSimilar(boots.getResult())) {
|
||||
if (!Stream.of(playerInventory.getArmorContents()).allMatch(Objects::nonNull)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setDamage(reduction * event.getDamage());
|
||||
}
|
||||
if (playerInventory.getHelmet().isSimilar(helmet.getResult()) &&
|
||||
playerInventory.getChestplate().isSimilar(chestplate.getResult()) &&
|
||||
playerInventory.getLeggings().isSimilar(leggings.getResult()) &&
|
||||
playerInventory.getBoots().isSimilar(boots.getResult())) {
|
||||
|
||||
event.setDamage(reduction * event.getDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user