From a4afd65c424700b1efd047c4a2a9eb4bced9c634 Mon Sep 17 00:00:00 2001 From: Doan Hiep Date: Tue, 12 Sep 2023 00:01:05 +0700 Subject: [PATCH] fixed HealPoolTask concurrent modification --- .../bedwars/arena/upgrades/HealPoolTask.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolTask.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolTask.java index 1cac082cb..f0f8386d5 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolTask.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolTask.java @@ -87,7 +87,8 @@ public static boolean exists(IArena arena, ITeam bwt){ } public static void removeForArena(IArena a){ if (healPoolTasks.isEmpty() || a == null) return; - for (HealPoolTask hpt: healPoolTasks) { + for (int i = 0; i < healPoolTasks.size(); i++) { + HealPoolTask hpt = healPoolTasks.get(i); if (hpt == null) continue; if (hpt.getArena().equals(a)){ hpt.cancel(); @@ -96,9 +97,10 @@ public static void removeForArena(IArena a){ } } - public static void removeForArena(String a){ + public static void removeForArena(String a){ if (healPoolTasks == null || healPoolTasks.isEmpty() || (a == null)) return; - for (HealPoolTask hpt: healPoolTasks) { + for (int i = 0; i < healPoolTasks.size(); i++) { + HealPoolTask hpt = healPoolTasks.get(i); if (hpt == null) continue; if (hpt.getArena().getWorldName().equals(a)){ hpt.cancel(); @@ -109,7 +111,8 @@ public static void removeForArena(String a){ public static void removeForTeam(ITeam team){ if (healPoolTasks == null || healPoolTasks.isEmpty() || (team == null)) return; - for (HealPoolTask hpt:healPoolTasks) { + for (int i = 0; i < healPoolTasks.size(); i++) { + HealPoolTask hpt = healPoolTasks.get(i); if (hpt == null) continue; if (hpt.getBwt().equals(team)){ hpt.cancel();