Fix: Lobby cleanup got blocked by previous feature for rejoining lobby while game is still going.

This commit is contained in:
Jona Walpert
2026-05-15 15:37:55 +02:00
parent bd78d177a5
commit 1f73083778
2 changed files with 6 additions and 1 deletions
@@ -98,9 +98,14 @@ public class GetGameStateHandler extends CommandHandler<GetGameStateRequest> {
} }
try { try {
// Remove all active players
for (String playerName : lobby.getPlayerNames()) { for (String playerName : lobby.getPlayerNames()) {
lobbyManager.removePlayer(playerName); lobbyManager.removePlayer(playerName);
} }
// Also remove all absent players so the lobby can be deleted
for (String playerName : lobby.getAbsentPlayers()) {
lobbyManager.removePlayer(playerName);
}
lobby.initGame(null); lobby.initGame(null);
} catch (RuntimeException e) { } catch (RuntimeException e) {
LOGGER.log( LOGGER.log(
@@ -217,7 +217,7 @@ public class LobbyManager {
for (Map.Entry<LobbyId, Lobby> e : activeLobbies.entrySet()) { for (Map.Entry<LobbyId, Lobby> e : activeLobbies.entrySet()) {
LobbyId id = e.getKey(); LobbyId id = e.getKey();
Lobby l = e.getValue(); Lobby l = e.getValue();
if (l.getPlayerNames().isEmpty()) { if (!l.hasAnyPlayers()) {
Instant created = creationTimes.get(id); Instant created = creationTimes.get(id);
if (created != null && created.isBefore(cutoff)) { if (created != null && created.isBefore(cutoff)) {
result.add(id); result.add(id);