-
-
Notifications
You must be signed in to change notification settings - Fork 4
Developers API
Berke Akçen edited this page Oct 9, 2020
·
27 revisions
Maven repository usually contains latest releases, if not, please check in few days if
release is there.
- Add repository
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
- Add the dependency
<dependencies>
<dependency>
<groupId>com.github.Despical</groupId>
<artifactId>KOTL</artifactId>
<version>1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
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 |