Fixed lobby checks

This commit is contained in:
Joel 2021-02-20 04:02:55 +01:00
parent b50aa92f76
commit 6f3c62b464

@ -55,14 +55,14 @@ public class HubBalancer implements Runnable, Listener {
System.out.println("ServerInfo is null"); System.out.println("ServerInfo is null");
//We do this check due sometimes players stay in a server which is deleted. But were send to it before it was deleted. //We do this check due sometimes players stay in a server which is deleted. But were send to it before it was deleted.
for (ProxiedPlayer player : proxy.getProxy().getPlayers()) { for (ProxiedPlayer player : proxy.getProxy().getPlayers()) {
if (player.getServer() == null || player.getServer().getInfo().getName().equals(serverRestartCommand.getServerId())) if (player.getServer() == null && (hubs.size() == 0))
kickPlayer(player, NO_AVAILABLE_HUB); kickPlayer(player, NO_AVAILABLE_HUB);
} }
return; return;
} else { } else {
for (ProxiedPlayer player : proxy.getProxy().getPlayers()) { for (ProxiedPlayer player : proxy.getProxy().getPlayers()) {
if (player.getServer().getInfo().equals(serverInfo)) { if (player.getServer().getInfo().equals(serverInfo)) {
if (hubs.isEmpty() || hubs.size() <= 1) if (hubs.isEmpty())
kickPlayer(player, NO_AVAILABLE_HUB); kickPlayer(player, NO_AVAILABLE_HUB);
} }
} }
@ -101,7 +101,7 @@ public class HubBalancer implements Runnable, Listener {
kickPlayer(player, HUB_SEND_FAILED); kickPlayer(player, HUB_SEND_FAILED);
event.setCancelled(true); event.setCancelled(true);
} else event.setTarget(serverInfo); } else event.setTarget(serverInfo);
} else if (reason == ServerConnectEvent.Reason.LOBBY_FALLBACK) { } else if (reason == ServerConnectEvent.Reason.LOBBY_FALLBACK || (event.getTarget().isRestricted())) {
kickPlayer(player, NO_AVAILABLE_HUB); kickPlayer(player, NO_AVAILABLE_HUB);
event.setCancelled(true); event.setCancelled(true);
} }