Merge branch 'fix/lobby-cleanup-blocked' into 'main'

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

See merge request cs108-fs26/Gruppe-13!184
This commit is contained in:
Jona Walpert
2026-05-15 13:40:45 +00:00
2 changed files with 6 additions and 1 deletions
@@ -98,9 +98,14 @@ public class GetGameStateHandler extends CommandHandler<GetGameStateRequest> {
}
try {
// Remove all active players
for (String playerName : lobby.getPlayerNames()) {
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);
} catch (RuntimeException e) {
LOGGER.log(
@@ -217,7 +217,7 @@ public class LobbyManager {
for (Map.Entry<LobbyId, Lobby> e : activeLobbies.entrySet()) {
LobbyId id = e.getKey();
Lobby l = e.getValue();
if (l.getPlayerNames().isEmpty()) {
if (!l.hasAnyPlayers()) {
Instant created = creationTimes.get(id);
if (created != null && created.isBefore(cutoff)) {
result.add(id);