Skip to content

Instantly share code, notes, and snippets.

@Tzeentchful
Last active May 15, 2016 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Tzeentchful/52ac00935fece5e084d7 to your computer and use it in GitHub Desktop.
Save Tzeentchful/52ac00935fece5e084d7 to your computer and use it in GitHub Desktop.
Get online players lilypad
public class OnlineGUIItem implements GUIItem, Runnable {
private int playerCount = 0;
public OnlineGUIItem() {
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), this, 80L, 80L);
}
@Override
public void processUpdate(Core plugin, Player player, Objective obj) {
Score players = obj.getScore(Bukkit.getOfflinePlayer("Players Online"));
players.setScore(playerCount);
}
@Override
public void run() {
Connect connect = Bukkit.getServicesManager().getRegistration(Connect.class).getProvider();
this.playerCount = Bukkit.getOnlinePlayers().length;
try {
this.playerCount = connect.request(new GetPlayersRequest()).await(50L).getCurrentPlayers();
} catch (RequestException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment