Make a copy of the players list when disconnecting them all on shutdown
@@ -61,6 +61,7 @@ import org.geysermc.connector.utils.LocaleUtils;
import java.net.InetSocketAddress;
import java.text.DecimalFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
@@ -189,7 +190,9 @@ public class GeyserConnector {
if (players.size() >= 1) {
bootstrap.getGeyserLogger().info(LanguageUtils.getLocaleStringLog("geyser.core.shutdown.kick.log", players.size()));
- for (GeyserSession playerSession : players) {
+ // Make a copy to prevent ConcurrentModificationException
+ final List<GeyserSession> tmpPlayers = new ArrayList<>(players);
+ for (GeyserSession playerSession : tmpPlayers) {
playerSession.disconnect(LanguageUtils.getPlayerLocaleString("geyser.core.shutdown.kick.message", playerSession.getClientData().getLanguageCode()));
}
