Skip to content

2. Development API

Terry edited this page May 2, 2023 · 6 revisions

Welcome to the PointsAPI wiki!

Implementation

Step 1: Import using maven or gradle (or manually using the PointsAPI.jar)
You can see the latest version here.

Using Maven

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
<dependency>
    <groupId>com.github.teraprath</groupId>
    <artifactId>PointsAPI</artifactId>
    <version>INSERT_VERSION_HERE</version>
</dependency>

Using Gradle

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.teraprath:PointsAPI:INSERT_VERSION_HERE'
}

Step 2: Add PointsAPI as dependency in your plugin.yml:

...
depend: [ PointsAPI ]

Step 4: Now initialize PointsAPI in your onEnable() method:

public final class TestPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        new PointsAPI(this).init();
    }

}

Step 5: You're done.

Basic Usage

An overview of the methods provided by the PointsAPI.

PointsAPI.getPoints(player);
PointsAPI.setPoints(player, amount);
PointsAPI.addPoints(player, amount);
PointsAPI.removePoints(player, amount);
PointsAPI.reset(player);

Asynchronous Processing

To process tasks asynchronously, use the following method provided by the Bukkit library.

Bukkit.getScheduler().runTaskAsynchronously(plugin, task -> {
    int points = PointsAPI.getPoints(player);
    // do stuff
});

Clone this wiki locally