-
-
Notifications
You must be signed in to change notification settings - Fork 4
Developers API
More information can be found on the wiki page. The Javadoc can be browsed. Questions related to the usage of King of the Ladder should be posted on my Discord server.
The project isn't in the Central Repository yet, so specifying a repository is needed.
To add this project as a dependency to your project, add the following to your pom.xml:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Despical</groupId>
<artifactId>KOTL</artifactId>
<version>1.2.1</version>
<scope>compile</scope>
</dependency>
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compileOnly group: "com.github.Despical", name: "KOTL", version: "1.2.1";
}
The event is called when the player receives a new statistic.
@EventHandler
public void onStatChange(KOTLPlayerStatisticChangeEvent event){
StatisticType stat = e.getStatisticType();
int statNumber = e.getNumber();
e.getPlayer().sendMessage("Your statistic " + stat.getName() + " has changed to " + statNumber);
}
event#getPlayer() - returns player involved in this event
event#getArena() - returns arena player is playing (player is always in arena when this event is called)
event#getStatisticType() - returns statistic of StatsStorage.StatisticType enum
event#getNumber() - returns current value of statistic
You can easily get online players stats using KOTL API - Stats Storage class.
public int getScore(Player p){
return StatsStorage.getUserStats(p, StatsStorage.StatisticType.SCORE);
}
Very easy, right?
To access sorted statistics HashMap with players you must call it from StatsStorage
class.
public void printBestStats(StatsStorage.StatisticType statistic){
Map<UUID, Integer> statsMap = StatsStorage.getStats(statistic);
UUID[] uuidsArray = (UUID[]) StatsStorage.getStats(statistic).keySet().toArray();
for (int i = 0; i < 10; i++){
Bukkit.broadcastMessage("#" + i + " UUID: " + uuidsArray[i] + ", stats: " + statsMap.get(uuidsArray[i]));
}
}
Statistic name (enum) | Statistic identifier (string) (for advanced things) |
Persistent | Description |
---|---|---|---|
TOURS_PLAYED | toursplayed | true | Played tours amounts |
SCORE | score | true | Total score amount |