AddServer

Discussion in 'BungeeCord Plugin Development' started by Preodym, May 23, 2016.

  1. Hey,

    how can I add a server via Plugin?
    This code does not work.

    Code (Text):
     public static void addServers(String name,int port, int count) throws SQLException {
            int x = 1;
            while (x <= count) {
                if (!BungeeCord.getInstance().getServers().containsKey((name + x).toUpperCase())) {
                    ServerInfo info = ProxyServer.getInstance().constructServerInfo((name + x).toUpperCase(), InetSocketAddress.createUnresolved("127.0.0.1", (port + x)), "MOTD", false);
                    ProxyServer.getInstance().getServers().put((name + x).toUpperCase(), info);
                }
                x++;
            }
        }
     
  2. I don't know actually, why this doesn't work for you... I did it like this: