From d931f38b1880006a8e067731f2965060968f9c26 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 21 Aug 2018 01:48:19 +0100 Subject: [PATCH] Fix Clans selection not working --- .../mineplex/hub/server/ServerManager.java | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index e06906c3d..5e8dc280e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -261,7 +261,7 @@ public class ServerManager extends MiniPlugin if (npcName.contains("Clans")) { - ServerGroup serverGroup = _serverGroupsByName.get("Clans"); + ServerGroup serverGroup = _serverGroupsByName.get("ClansHub"); if (serverGroup == null) { @@ -269,7 +269,7 @@ public class ServerManager extends MiniPlugin return; } - if (!selectBest(player, serverGroup)) + if (!selectBest(player, serverGroup, false)) { player.sendMessage(F.main(getName(), "Sorry I was unable to find you a good server to send you to.")); } @@ -490,6 +490,11 @@ public class ServerManager extends MiniPlugin } public boolean selectBest(Player player, ServerGroup serverGroup) + { + return selectBest(player, serverGroup, true); + } + + public boolean selectBest(Player player, ServerGroup serverGroup, boolean checkValid) { if (!Recharge.Instance.use(player, "Select Best Server", SELECT_SERVER_COOLDOWN, false, false)) { @@ -499,28 +504,31 @@ public class ServerManager extends MiniPlugin Collection servers = getServers(serverGroup.getPrefix()); int required = getRequiredSlots(player); - servers.removeIf(server -> + if (checkValid) { - MinecraftServer serverStatus = server.getServer(); - GameInfo info = server.getInfo(); - - if (server.isDevServer() || info.getJoinable() != GameJoinStatus.OPEN || serverStatus.getMaxPlayerCount() - serverStatus.getPlayerCount() <= required) + servers.removeIf(server -> { - return true; - } + MinecraftServer serverStatus = server.getServer(); + GameInfo info = server.getInfo(); - switch (info.getStatus()) - { - case WAITING: - case VOTING: - return false; - case STARTING: - // If the game is about to start, ignore it. The player probably won't make it in time. - return info.getTimer() < 5; - default: + if (server.isDevServer() || info.getJoinable() != GameJoinStatus.OPEN || serverStatus.getMaxPlayerCount() - serverStatus.getPlayerCount() <= required) + { return true; - } - }); + } + + switch (info.getStatus()) + { + case WAITING: + case VOTING: + return false; + case STARTING: + // If the game is about to start, ignore it. The player probably won't make it in time. + return info.getTimer() < 5; + default: + return true; + } + }); + } if (servers.isEmpty()) {