Ejemplo n.º 1
0
 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();
                     });
           });
 }
Ejemplo n.º 2
0
    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());
    }
Ejemplo n.º 3
0
  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();
            });
  }