Skip to content

Developers API

Berke Akçen edited this page Oct 9, 2020 · 27 revisions

Table of contents

Maven Repository

Maven repository usually contains latest releases, if not, please check in few days if
release is there.

How to accsess repo:
  1. Add repository
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
  1. Add the dependency
    <dependencies>
        <dependency>
            <groupId>com.github.Despical</groupId>
            <artifactId>KOTL</artifactId>
            <version>1.1.4</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

Events

KOTLPlayerStatisticChangeEvent

The event is called when the player receives a new statistic.

Example:

    @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

Stats Storage

Table of contents

Retrieving online players stats

You can easily get online players stats using KOTL API - Stats Storage class.

Example:

    public int getScore(Player p){
        return StatsStorage.getUserStats(p, StatsStorage.StatisticType.SCORE);
    }

Very easy, right?

Requesting sorted statistics of all players

To access sorted statistics HashMap with players you must call it from StatsStorage
class.

Example:

    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]));
        }
    }

Imgur

Available statistic types

Statistic name (enum) Statistic identifier
(string) (for
advanced things)
Persistent Description
TOURS_PLAYED toursplayed true Played tours
amounts
SCORE score true Total score
amount
Clone this wiki locally