Skip to content

Commit b4d039b

Browse files
committed
Extract method
1 parent bf989cf commit b4d039b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightTagController.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,11 @@ void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
5555
UUID attackedUniqueId = attackedPlayerByPerson.getUniqueId();
5656
UUID attackerUniqueId = attacker.getUniqueId();
5757

58-
if (attacker.isOp() && this.config.settings.excludeOpFromCombat ||
59-
attacker.getGameMode().equals(GameMode.CREATIVE) && this.config.settings.excludeCreativeFromCombat ) {
58+
if (this.cannotBeTagged(attacker)) {
6059
return;
6160
}
6261

63-
if (attackedPlayerByPerson.isOp() && this.config.settings.excludeOpFromCombat ||
64-
attackedPlayerByPerson.getGameMode().equals(GameMode.CREATIVE) && this.config.settings.excludeCreativeFromCombat) {
62+
if (this.cannotBeTagged(attackedPlayerByPerson)) {
6563
return;
6664
}
6765

@@ -95,6 +93,10 @@ void onEntityDamage(EntityDamageEvent event) {
9593
return;
9694
}
9795

96+
if (this.cannotBeTagged(player)) {
97+
return;
98+
}
99+
98100
Duration combatTime = this.config.settings.combatDuration;
99101

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

137+
private boolean cannotBeTagged(Player player) {
138+
return (player.getGameMode().equals(GameMode.CREATIVE) && this.config.settings.excludeCreativeFromCombat) ||
139+
(player.isOp() && this.config.settings.excludeOpFromCombat);
140+
}
141+
135142
}

0 commit comments

Comments
 (0)