ServerPing Null localhost

Discussion in 'BungeeCord Plugin Development' started by matgsan, Sep 5, 2017.

  1. Hey guys, i am developing a plugin that i need to do serverping in all my servers.
    Well, i create a method to get de ServerPing but sometimes it is showing the result null and i dont know why, because the server is online and is in localhost.

    Code (Text):

        public ServerPing getInfo() {
            getServerInfo().ping(new Callback<ServerPing>() {
                @Override
                public void done(ServerPing result, Throwable error) {
                    if (error != null) {
                        if (getGameType() != GameType.TESTE) {
                            System.out.println("Failed to ping " + getName());
                        }
                        return;
                    }
                    serverPing = result;
                }
            });
            return serverPing;
        }
    Its not Failed to ping because it dont show that message, i thing the result is null.
    I am running these in a task each 2 seconds.
     
  2. Why not check if the result is null. Maybe there are occassions where there is no error thrown.
     
  3. But why the result will be null?