From a94e52038c6bdf54868ad203dd83a378d92a047e Mon Sep 17 00:00:00 2001 From: citralflo Date: Thu, 12 Oct 2023 11:01:03 +0200 Subject: [PATCH] Follow DMK suggestions --- .../java/com/eternalcode/combat/fight/FightManager.java | 5 ++--- src/main/java/com/eternalcode/combat/fight/FightTask.java | 5 +---- .../combat/fight/effect/FightEffectController.java | 8 ++------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/eternalcode/combat/fight/FightManager.java b/src/main/java/com/eternalcode/combat/fight/FightManager.java index 245004c0..98531720 100644 --- a/src/main/java/com/eternalcode/combat/fight/FightManager.java +++ b/src/main/java/com/eternalcode/combat/fight/FightManager.java @@ -10,13 +10,12 @@ import java.time.Instant; import java.util.Collection; import java.util.Collections; -import java.util.Map; import java.util.UUID; -import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; public class FightManager { - private final Map fights = new HashMap<>(); + private final ConcurrentHashMap fights = new ConcurrentHashMap<>(); private final EventCaller eventCaller; public FightManager(EventCaller eventCaller) { diff --git a/src/main/java/com/eternalcode/combat/fight/FightTask.java b/src/main/java/com/eternalcode/combat/fight/FightTask.java index 77785cce..cedd45ea 100644 --- a/src/main/java/com/eternalcode/combat/fight/FightTask.java +++ b/src/main/java/com/eternalcode/combat/fight/FightTask.java @@ -12,8 +12,6 @@ import panda.utilities.text.Formatter; import java.time.Duration; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; public class FightTask implements Runnable { @@ -36,8 +34,7 @@ public FightTask(Server server, PluginConfig config, FightManager fightManager, public void run() { - List fights = new ArrayList<>(this.fightManager.getFights()); - for (FightTag fightTag : fights) { + for (FightTag fightTag : this.fightManager.getFights()) { Player player = this.server.getPlayer(fightTag.getTaggedPlayer()); if (player == null) { diff --git a/src/main/java/com/eternalcode/combat/fight/effect/FightEffectController.java b/src/main/java/com/eternalcode/combat/fight/effect/FightEffectController.java index d8badd42..e0220501 100644 --- a/src/main/java/com/eternalcode/combat/fight/effect/FightEffectController.java +++ b/src/main/java/com/eternalcode/combat/fight/effect/FightEffectController.java @@ -35,9 +35,7 @@ public void onTag(FightTagEvent event) { Player player = this.server.getPlayer(event.getPlayer()); - if (player == null) { - return; - } + assert player != null; this.effectSettings.customEffects.forEach((key, value) -> this.effectService.applyCustomEffect(player, key, value)); @@ -65,9 +63,7 @@ public void onUntag(FightUntagEvent event) { Player player = this.server.getPlayer(event.getPlayer()); - if (player == null) { - return; - } + assert player != null; this.effectSettings.customEffects.forEach((key, value) -> this.effectService.removeCustomEffect(player, key, value));