How to include the API with Maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories><dependencies>
<dependency>
<groupId>com.github.elijuh</groupId>
<artifactId>ServerPingerAPI</artifactId>
<version>1.0</version>
</dependency>
</dependencies>How to include the API with Gradle:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compileOnly "com.github.elijuh:ServerPingerAPI:1.0"
}Example Usage of ServerPinger
publicclassTest {
publicstaticvoidmain(String[] args) {
// Creating an instanceServerPingerpinger = newServerPinger();
try {
// Pinging hypixel.net server-list informationServerResponseresponse = pinger.ping("hypixel.net");
// Ping in mslongping = response.getPing();
// Description of the serverServerResponse.Descriptiondescription = response.getDescription();
// Version of the serverServerResponse.Versionversion = response.getVersion();
// Player informationServerResponse.Playersplayers = response.getPlayers();
intonline = players.getOnline();
intmaxPlayers = players.getMax();
// Some servers show a list of the players online, but in this example; hypixel does not.List<ServerResponse.Player> playerList = players.getSample();
// You can also get the Base64 for the server iconStringiconBase = response.getFavicon();
// Displaying information to consoleSystem.out.println("Ping: " + ping + "ms");
System.out.println("Description: " + description.getText());
System.out.println("Version: " + version.getName());
System.out.println("Player Count: " + online + "/" + maxPlayers);
System.out.println("Players: " + playerList);
System.out.println("Icon Base64: " + iconBase);
} catch (IOExceptione) {
e.printStackTrace();
}
}
}