Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ConcurrentModificationsException caused by removing the healing pool #986

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import java.util.Random;

import static com.andrei1058.bedwars.BedWars.config;
Expand Down Expand Up @@ -85,35 +86,41 @@ public static boolean exists(IArena arena, ITeam bwt){
}
return false;
}
public static void removeForArena(IArena a){
if (healPoolTasks.isEmpty() || a == null) return;
for (HealPoolTask hpt: healPoolTasks) {
public static void removeForArena(IArena arena) {
if (healPoolTasks.isEmpty() || arena == null) return;
Iterator<HealPoolTask> healPoolTasksIterator = healPoolTasks.iterator();
while (healPoolTasksIterator.hasNext()) {
HealPoolTask hpt = healPoolTasksIterator.next();
if (hpt == null) continue;
if (hpt.getArena().equals(a)){
if (hpt.getArena().equals(arena)){
hpt.cancel();
healPoolTasks.remove(hpt);
healPoolTasksIterator.remove();
}
}
}

public static void removeForArena(String a){
if (healPoolTasks == null || healPoolTasks.isEmpty() || (a == null)) return;
for (HealPoolTask hpt: healPoolTasks) {
public static void removeForArena(String arena) {
if (healPoolTasks == null || healPoolTasks.isEmpty() || (arena == null)) return;
Iterator<HealPoolTask> healPoolTasksIterator = healPoolTasks.iterator();
while (healPoolTasksIterator.hasNext()) {
HealPoolTask hpt = healPoolTasksIterator.next();
if (hpt == null) continue;
if (hpt.getArena().getWorldName().equals(a)){
if (hpt.getArena().getWorldName().equals(arena)){
hpt.cancel();
healPoolTasks.remove(hpt);
healPoolTasksIterator.remove();
}
}
}

public static void removeForTeam(ITeam team){
if (healPoolTasks == null || healPoolTasks.isEmpty() || (team == null)) return;
for (HealPoolTask hpt:healPoolTasks) {
Iterator<HealPoolTask> healPoolTasksIterator = healPoolTasks.iterator();
while (healPoolTasksIterator.hasNext()) {
HealPoolTask hpt = healPoolTasksIterator.next();
if (hpt == null) continue;
if (hpt.getBwt().equals(team)){
hpt.cancel();
healPoolTasks.remove(hpt);
healPoolTasksIterator.remove();
}
}
}
Expand Down
Loading