diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index 11ec5a1a55..bec8fda788 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -867,14 +867,29 @@ public class TableController { public boolean isTournamentStillValid() { if (table.getTournament() != null) { - TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(table.getTournament().getId()); - if (tournamentController != null) { - return tournamentController.isTournamentStillValid(table.getState()); + if (!table.getState().equals(TableState.WAITING) && !table.getState().equals(TableState.READY_TO_START) && !table.getState().equals(TableState.STARTING) ) { + TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(table.getTournament().getId()); + if (tournamentController != null) { + return tournamentController.isTournamentStillValid(table.getState()); + } else { + return false; + } } else { - return false; + // check if table creator is still a valid user, if not remove table + User user = UserManager.getInstance().getUser(userId); + return user != null; } } - return true; + return false; + } + + public UUID getUserId(UUID playerId) { + for (Map.Entry entry: userPlayerMap.entrySet()) { + if (entry.getValue().equals(playerId)) { + return entry.getKey(); + } + } + return null; } public boolean isMatchTableStillValid() { diff --git a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java index 3ee884b71d..301055bcd2 100644 --- a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java +++ b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java @@ -477,9 +477,10 @@ public class TournamentController { logger.debug("Tournament user is missing but player active -> start quit - tournamentId: " + tournament.getId() + " state: " + tableState.toString()); // active tournament player but the user is no longer online quit(entry.getKey()); + } else { + activePlayers++; } - } - activePlayers++; + } } } else { // tournament player is missing