Skip to content

Commit

Permalink
fix: replace forEach with iterator to avoid concurrent modification e…
Browse files Browse the repository at this point in the history
…xceptions

fix #85

Signed-off-by: Daniel Nägele <daniel@naegele.dev>
  • Loading branch information
daniel-naegele committed Apr 20, 2023
1 parent befdfe3 commit 3e704ba
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
import de.butzlabben.missilewars.configuration.Lobby;
import de.butzlabben.missilewars.util.geometry.GameArea;
import de.butzlabben.missilewars.util.serialization.Serializer;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

@Getter
public class GameManager {

Expand All @@ -45,7 +46,11 @@ public void disableAll() {
}

public void restartAll() {
games.values().forEach(game -> restartGame(game.getLobby(), false));
var iterator = games.values().iterator();
//noinspection WhileLoopReplaceableByForEach
while (iterator.hasNext()) {
restartGame(iterator.next().getLobby(), false);
}
}

/**
Expand Down

0 comments on commit 3e704ba

Please sign in to comment.