Return early from forceEnd() if there are no players in the arena.

This means that the cleanup code will only run if there are players in the lobby, arena, or spectator area. This fixes the first part of #435 where the cleanup code is taking too long for large/many arenas.

Originally, the force end command was meant as a way to circumvent any condition keeping players from leaving the arena and cleaning it up. In retrospect, the main reason for using force end is to "get people out of there", but since there's plenty of stuff that can go wrong when a player leaves, this isn't really that helpful, as exceptions will just cause the command to break at the same point anyway.
This commit is contained in:
Andreas Troelsen 2018-04-22 20:12:31 +02:00
parent a91c5e7a74
commit b1634f9460

View File

@ -642,10 +642,12 @@ public class ArenaImpl implements Arena
@Override
public void forceEnd() {
for (Player p : getAllPlayers()) {
playerLeave(p);
List<Player> players = getAllPlayers();
if (players.isEmpty()) {
return;
}
players.forEach(this::playerLeave);
cleanup();
}