Best Eggwars/Bedwars plugin out there! Tons of cool features that you don't want to miss!
//Getting top players
//First you have to load all players data, this should be Async
try {
HashMap<String, String> playersData = EggwarsAPI.getAllPlayersData();
//You can now get top players out of the playersData, ordered by a specfic stat
//If the third argument (int) is bigger than the amount of entries in the playersData hashmap, it will be filled with 'NO_PLAYER'
List<Entry<String, Integer>> top = EggwarsAPI.getTopPlayers(playersData, Stat.KILLS, 10);
//Top now contains the top 10 players, ordered by their kills stat
//Entry key is the player name, and the entry value is their score
for(int i = 0; i < top.size(); i++){
Bukkit.broadcastMessage("# " + (i+1) + " is " + top.get(i).getKey() + " with a score of " + top.get(i).getValue());
}
} catch (SQLException e){
e.printStackTrace();
}
//If you want to modify offline players stats, then you have to use a different method, because you can't use the PlayerData class on offline players
//The following method returns true if the stat was updated, and it returns false if the player name wasn't found or the stat wasn't updated for some reason
//The boolean at the end 'increment' is whether you want to SET their stat to the give value, or you want to add it up
try {
boolean updated = EggwarsAPI.modifyOfflinePlayerStat("Wazup92", Stat.COINS, 50, true);
} catch (SQLException e){
e.printStackTrace();
}
}
}
[LIST=1]
[/LIST]