Skip to content

Commit

Permalink
Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
CitralFlo committed Oct 29, 2024
1 parent bf989cf commit b4d039b
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
UUID attackedUniqueId = attackedPlayerByPerson.getUniqueId();
UUID attackerUniqueId = attacker.getUniqueId();

if (attacker.isOp() && this.config.settings.excludeOpFromCombat ||
attacker.getGameMode().equals(GameMode.CREATIVE) && this.config.settings.excludeCreativeFromCombat ) {
if (this.cannotBeTagged(attacker)) {
return;
}

if (attackedPlayerByPerson.isOp() && this.config.settings.excludeOpFromCombat ||
attackedPlayerByPerson.getGameMode().equals(GameMode.CREATIVE) && this.config.settings.excludeCreativeFromCombat) {
if (this.cannotBeTagged(attackedPlayerByPerson)) {
return;
}

Expand Down Expand Up @@ -95,6 +93,10 @@ void onEntityDamage(EntityDamageEvent event) {
return;
}

if (this.cannotBeTagged(player)) {
return;
}

Duration combatTime = this.config.settings.combatDuration;

UUID uuid = player.getUniqueId();
Expand Down Expand Up @@ -132,4 +134,9 @@ private boolean isPlayerInDisabledWorld(Player player) {
return this.config.settings.worldsToIgnore.contains(worldName);
}

private boolean cannotBeTagged(Player player) {
return (player.getGameMode().equals(GameMode.CREATIVE) && this.config.settings.excludeCreativeFromCombat) ||

This comment has been minimized.

Copy link
@Rollczi

Rollczi Oct 29, 2024

Member

Can you split these conditions?

(player.isOp() && this.config.settings.excludeOpFromCombat);
}

}

0 comments on commit b4d039b

Please sign in to comment.