ServerPinger 0.0.1-SNAPSHOT

Ping any Minecraft Server with Java (1.3 >)

  1. samczsun
    FOR DEVELOPERS ONLY
    This is an API that allows you to ping a server and get information about it, such as players online, MOTD, player sample, etcetera.

    To use this, simply import the class 'ServerPinger', and use the appropriate version, like this:

    Code (Text):

    StatusResponse resp = ServerPinger.POST_NETTY_REWRITE.fetchData("some ip", 25565);
     

    POST_NETTY_REWRITE is for versions 1.7.x and above.
    PRE_NETTY_REWRITE is for versions 1.6.x and below
    PRE_1_3 is just there because who knows. Someone might be running 1.3 ;-;

    From StatusResponse, you can get access to the description (MOTD), the favicon (in Base64), the max/online players along with the playersample, as well as the version name and protocol.

    For example, here is a possible method to determine the protocol of any given ip and port.

    Code (Text):

    int version = 0;
    String[] nextsplit = s.split(":");
    String ip = nextsplit[0];
    int port = nextsplit.length == 2 ? Integer.parseInt(nextsplit[1]) : 25565;
    if (ServerPinger.POST_NETTY_REWRITE.fetchData(ip, port) != null) {
        version = 3;
    } else if (ServerPinger.PRE_NETTY_REWRITE.fetchData(ip, port) != null) {
        version = 2;
    } else if (ServerPinger.PRE_1_3.fetchData(ip, port) != null) {
        version = 1;
    } else {
        getLogger().severe("Could not determine server version for " + ip + ":" + port);
    }
    if (version != 0) {
        getLogger().info("Loaded server " + ip + ":" + port + " with version " + version);
        // Your loading code here
    }
     

Recent Reviews

  1. gogobebe2
    gogobebe2
    5/5,
    Version: 0.0.1-SNAPSHOT
    Very useful