You can access the api with -> EggwarsAPI class
Methods:
- EggwarsAPI.getPlayerData(Player p); -> returns the player playerdata which holds all of his stats (Everything can be modified)
- EggwarsAPI.isInArena(Player p);
- EggwarsAPI.isSpectating(Player p);
- EggwarsAPI.isPlaying(Player p);
- EggwarsAPI.getTeam(Player p); //Returns a scoreboard team
- EggwarsAPI.getArenaName(Player p);
- EggwarsAPI.getTeams(String arenaName); //Returns a list of all the registered teams
- EggwarsAPI.translateChatColorToColor(ChatColor cc); //Returns a color that hold the rgb values (Which can be used to dye leather armor)
- EggwarsAPI.getItemStack(String itemString, boolean amount, boolean extras); //Used to read the plugin item format which is 'ITEM
URABILITY : AMOUNT : EXTRAS' if the item string contains an amount then the boolean should be true, if the item string contains enchantments and what not then the extras boolean should be true
- EggwarsAPI.getItemStackString(ItemStack item); //Returns a string that can be read by the getItemStack() method
Now for the methods that are a little more complicated
Code (Text):
//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();
}
}
}