diff --git a/plugin/src/main/java/org/screamingsandals/bedwars/Main.java b/plugin/src/main/java/org/screamingsandals/bedwars/Main.java index 9c9021a39..78886d901 100644 --- a/plugin/src/main/java/org/screamingsandals/bedwars/Main.java +++ b/plugin/src/main/java/org/screamingsandals/bedwars/Main.java @@ -802,6 +802,10 @@ public org.screamingsandals.bedwars.api.game.Game getRandomWaitingGameForBungeeM return; } + if (game.getConnectedPlayers().size() >= game.getMaxPlayers()) { + return; + } + availableGames.computeIfAbsent(game.getConnectedPlayers().size(), ArrayList::new).add(game); }); @@ -809,9 +813,9 @@ public org.screamingsandals.bedwars.api.game.Game getRandomWaitingGameForBungeeM return null; } - List gamesWithMinimumPlayers = availableGames.lastEntry().getValue(); + List gamesWithMaximumPlayers = availableGames.lastEntry().getValue(); - return gamesWithMinimumPlayers.get(MiscUtils.randInt(0, gamesWithMinimumPlayers.size() - 1)); + return gamesWithMaximumPlayers.get(MiscUtils.randInt(0, gamesWithMaximumPlayers.size() - 1)); } public org.screamingsandals.bedwars.api.game.Game getFirstRunningGame() { diff --git a/plugin/src/main/java/org/screamingsandals/bedwars/commands/AutojoinCommand.java b/plugin/src/main/java/org/screamingsandals/bedwars/commands/AutojoinCommand.java index 00ea9acac..092a2e4d7 100644 --- a/plugin/src/main/java/org/screamingsandals/bedwars/commands/AutojoinCommand.java +++ b/plugin/src/main/java/org/screamingsandals/bedwars/commands/AutojoinCommand.java @@ -42,7 +42,7 @@ public boolean execute(CommandSender sender, List args) { return true; } - Game game = Main.getInstance().getGameWithHighestPlayers(); // prioritizing player count - scorp + Game game = Main.getInstance().getRandomWaitingGameForBungeeMode(); if (game == null) { player.sendMessage(i18n("there_is_no_empty_game")); } else { diff --git a/plugin/src/main/java/org/screamingsandals/bedwars/commands/JoinCommand.java b/plugin/src/main/java/org/screamingsandals/bedwars/commands/JoinCommand.java index c09c72775..c6fc00a2c 100644 --- a/plugin/src/main/java/org/screamingsandals/bedwars/commands/JoinCommand.java +++ b/plugin/src/main/java/org/screamingsandals/bedwars/commands/JoinCommand.java @@ -50,7 +50,7 @@ public boolean execute(CommandSender sender, List args) { player.sendMessage(i18n("no_arena_found")); } } else { - final Game game = Main.getInstance().getGameWithHighestPlayers(); + final Game game = Main.getInstance().getRandomWaitingGameForBungeeMode(); if (game != null) { game.joinToGame(player); return true;