First download our everythingrs-api.jar from here and include it into your project.
After adding the everything-rs.jar into your project the next step is to create an account, once the account is created you must register onto the toplist as we use the toplist data in many of our api's.
public static void main(
Add this and change your secret key to the one on your account
com.everythingrs.playersonline.PlayersOnline.service.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
int online = 0;
for (Player player: PlayerHandler.players) {
if (player != null) {
online += 1;
}
}
com.everythingrs.playersonline.PlayersOnline.insert("secret_key", online, false);
}
}, 0, 30, TimeUnit.SECONDS);
com.everythingrs.playersonline.PlayersOnline.service.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
int online = 0;
for (Player player: World.getPlayers()) {
if (player != null) {
online += 1;
}
}
com.everythingrs.playersonline.PlayersOnline.insert("secret_key", online, false);
}
}, 0, 30, TimeUnit.SECONDS);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
var accountName = "REPLACE_THIS_WITH_YOUR_ACCOUNT_NAME";
$.get("https://everythingrs.com/api/players-online/get/" + accountName, function (response) {
$("#players").html(response);
});
</script>
There are currently <span id="players"></span> players online.
com.everythingrs.playersonline.PlayersOnline.get();
To set the count to whatever you wish use this code
com.everythingrs.playersonline.PlayersOnline.set(value);
To add to the playercount use this
com.everythingrs.playersonline.PlayersOnline.increment(value);
To subtract from the playercount use this
com.everythingrs.playersonline.PlayersOnline.decrement(value);