Last active
May 15, 2016 06:00
-
-
Save Tzeentchful/52ac00935fece5e084d7 to your computer and use it in GitHub Desktop.
Get online players lilypad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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