void checkServers() { servers .values() .stream() .filter(server -> !server.isOnline()) .forEach( server -> { ProxyServer.getInstance() .getLogger() .severe( "[Servers] Server " + server.getName() + " detected as offline, removing."); remove(server.getName()); BungeeBridge.getInstance() .getExecutor() .addTask( () -> { Jedis jedis = BungeeBridge.getInstance().getConnector().getBungeeResource(); jedis.hdel("servers", server.getName()); jedis.sadd("offlineservers", server.getName()); jedis.del("connectedonserv:" + server.getName()); jedis.publish("servers", "stop " + server.getName()); jedis.close(); }); }); }
public Set<UUID> getPlayers() { Jedis jedis = BungeeBridge.getInstance().getConnector().getBungeeResource(); Set<String> list = jedis.smembers("connectedonserv:" + name); jedis.close(); return list.stream().map(UUID::fromString).collect(Collectors.toSet()); }
public void createServer(String server, String ip, String port) { InetSocketAddress address = new InetSocketAddress(ip, Integer.parseInt(port)); ServerInfo info = ProxyServer.getInstance() .constructServerInfo(server, address, "Automatically added server", false); ProxyServer.getInstance().getServers().put(server, info); RemoteServer remoteServer = new RemoteServer(new Date(), server, info); this.servers.put(server, remoteServer); ProxyServer.getInstance() .getLogger() .info("[Servers] Created server " + server + ", " + ip + ":" + port); BungeeBridge.getInstance() .getExecutor() .addTask( () -> { Jedis jedis = BungeeBridge.getInstance().getConnector().getBungeeResource(); jedis.srem("offlineservers", server); jedis.close(); }); }