Skip to content

Developers API

Berke Akçen edited this page Jul 13, 2023 · 5 revisions

Table of contents

TNT Run API

The project isn't in the Central Repository yet, so specifying a repository is needed.

Maven dependency
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
<dependency>
    <groupId>com.github.Despical</groupId>
    <artifactId>TNTRun</artifactId>
    <version>2.3.4</version>
    <scope>compile</scope>
</dependency>
Gradle dependency
repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    compileOnly group: "com.github.Despical", name: "TNTRun", version: "2.3.4";
}

Retrieving Players Statistics

You can easily get online players stats using StatsStorage class.

Example:

    public int getWins(Player p){
        return StatsStorage.getUserStats(p, StatsStorage.StatisticType.WINS);
    }

Requesting Sorted Statistics of All Players

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

Example:

    public void printStats(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]));
        }
    }

Available Statistic Types

Statistic name (enum) Statistic identifier
(string) (for
advanced things)
Persistent Description
WINS wins true Wins
amount
LOSES loses true Loses
amount
GAMES_PLAYED gamesplayed true Total games
played
COINS coinsearned true Total earned
coins
LONGEST_SUVIVE longestsurvive true Longest survive
time
LOCAL_SURVIVE local_survive false In-game current
survive time
LOCAL_COINS local_coins false In-Game current
coins amount
LOCAL_DOUBLE_JUMPS local_double_jumps false In-Game current
double jump amount

Clone this wiki locally