Fix Clans selection not working

This commit is contained in:
Sam 2018-08-21 01:48:19 +01:00 committed by Alexander Meech
parent 33e6bdc4f7
commit d931f38b18

View File

@ -261,7 +261,7 @@ public class ServerManager extends MiniPlugin
if (npcName.contains("Clans")) if (npcName.contains("Clans"))
{ {
ServerGroup serverGroup = _serverGroupsByName.get("Clans"); ServerGroup serverGroup = _serverGroupsByName.get("ClansHub");
if (serverGroup == null) if (serverGroup == null)
{ {
@ -269,7 +269,7 @@ public class ServerManager extends MiniPlugin
return; 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.")); 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) 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)) if (!Recharge.Instance.use(player, "Select Best Server", SELECT_SERVER_COOLDOWN, false, false))
{ {
@ -499,28 +504,31 @@ public class ServerManager extends MiniPlugin
Collection<GameServer> servers = getServers(serverGroup.getPrefix()); Collection<GameServer> servers = getServers(serverGroup.getPrefix());
int required = getRequiredSlots(player); int required = getRequiredSlots(player);
servers.removeIf(server -> if (checkValid)
{ {
MinecraftServer serverStatus = server.getServer(); servers.removeIf(server ->
GameInfo info = server.getInfo();
if (server.isDevServer() || info.getJoinable() != GameJoinStatus.OPEN || serverStatus.getMaxPlayerCount() - serverStatus.getPlayerCount() <= required)
{ {
return true; MinecraftServer serverStatus = server.getServer();
} GameInfo info = server.getInfo();
switch (info.getStatus()) if (server.isDevServer() || info.getJoinable() != GameJoinStatus.OPEN || serverStatus.getMaxPlayerCount() - serverStatus.getPlayerCount() <= required)
{ {
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; 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()) if (servers.isEmpty())
{ {