From 7eb8b8c6143928161aa32e8c25dda47318fa3132 Mon Sep 17 00:00:00 2001 From: Joel Date: Sat, 20 Feb 2021 03:29:58 +0100 Subject: [PATCH] Probs made a fix so players won't stuck in a lobby anymore, when all lobbies are restarting. --- .../zone/themcgamer/proxy/hub/HubBalancer.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/proxy/src/main/java/zone/themcgamer/proxy/hub/HubBalancer.java b/proxy/src/main/java/zone/themcgamer/proxy/hub/HubBalancer.java index daa4f84..48c9037 100644 --- a/proxy/src/main/java/zone/themcgamer/proxy/hub/HubBalancer.java +++ b/proxy/src/main/java/zone/themcgamer/proxy/hub/HubBalancer.java @@ -11,6 +11,7 @@ import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventPriority; import zone.themcgamer.common.Tuple; import zone.themcgamer.data.jedis.command.JedisCommandHandler; +import zone.themcgamer.data.jedis.command.impl.ServerRestartCommand; import zone.themcgamer.data.jedis.command.impl.ServerStateChangeCommand; import zone.themcgamer.data.jedis.data.ServerGroup; import zone.themcgamer.data.jedis.data.server.MinecraftServer; @@ -46,6 +47,20 @@ public class HubBalancer implements Runnable, Listener { proxy.getProxy().getPluginManager().registerListener(proxy, this); JedisCommandHandler.getInstance().addListener(jedisCommand -> { + if (jedisCommand instanceof ServerRestartCommand) { + ServerRestartCommand serverRestartCommand = (ServerRestartCommand) jedisCommand; + ServerInfo serverInfo = proxy.getProxy().getServerInfo(serverRestartCommand.getServerId()); + if (serverInfo == null) + return; + for (ProxiedPlayer player : proxy.getProxy().getPlayers()) { + if (player.getServer().getInfo().equals(serverInfo)) { + if (hubs.isEmpty() || hubs.size() == 1) + kickPlayer(player, NO_AVAILABLE_HUB); + } + } + if (hubs.containsValue(serverInfo)) + hubs.remove(serverRestartCommand.getServerId()); + } if (jedisCommand instanceof ServerStateChangeCommand) { ServerStateChangeCommand serverStateChangeCommand = (ServerStateChangeCommand) jedisCommand; System.out.println("Received update status from server " + serverStateChangeCommand.getServer().getId() + " status: " + serverStateChangeCommand.getNewState());