ServerPingerAPI
This is the API for my ServerPinger plugin. With this you can check the online Status of other servers, get the MOTD, Players Online, etc. To start off with, you need to include this in your java Build path.AS WELL AS COPY THE JAR INTO YOUR /plugins DIRECTORY OTHERWISE IT WILL NOT WORK! Once you've got that done, I assume you want to connect to a server, no? Well let's get on with it!
Server server = new Server("maxisociety.com", 25565); //This one set's the ip to what you enter and the port to 25565 Server server = new Server("maxisociety.com"); //This one set's the IP to "127.0.0.1" which is localhost. And the port to 25565. Server server = new Server();
That's it! The first argument is the IP of the server. And the second is the Port.
Now to get the Data from the other server.
String motd = server.getMOTD(); String currentOnlinePlayers = server.getPlayers(); String maxPlayers = server.getMaxPlayers(); String serverVersion = server.getVersion(); //My favorite :) boolean isOnline = server.isOnline();
That's it! But just as a tip, always check if the server is online before you do anything. Otherwise it won't work. You can check this by doing the following:
if(!server.isOnline()) { //The server's offline, thus do nothing. }else { //DO ALL OF THE CODE! }
Does this support 1.8+?
This is amazing! Thank You for existing!
Update?
@RentAMonkey
Thanks, feel free to provide any feedback or suggestions, I'll gladly listen :).
@MersenneTwizter Good Job. :)