Skip to content

Developer API

pop4959 edited this page Sep 9, 2024 · 3 revisions

Developer API

Chunky provides a basic API for developers to manage generation tasks.

Setting up dependencies

Examples are provided below for declaring a dependency using either Gradle or Maven build tools.

Gradle (Kotlin DSL)

repositories {
    maven("https://repo.codemc.io/repository/maven-public/")
}

dependencies {
    compileOnly(group = "org.popcraft", name = "chunky-common", version = "1.3.38")
}

Maven

<repositories>
    <repository>
        <id>codemc</id>
        <url>https://repo.codemc.io/repository/maven-public/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.popcraft</groupId>
        <artifactId>chunky-common</artifactId>
        <version>1.3.38</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

Using the API

The javadoc for Chunky can be found here.

You will need to get an instance of ChunkyAPI to start using the API. This can be accomplished in Bukkit via the ServicesManager.

ChunkyAPI chunky = Bukkit.getServer().getServicesManager().load(ChunkyAPI.class);

Once you have this you can start writing your integration.

Here is an example to get started:

if (chunky.version() == 0) {
    chunky.startTask("world", "square", 0, 0, 500, 500, "concentric");
    chunky.onGenerationComplete(event -> getLogger().info("Generation completed for " + event.world()));
}

The above would start a new generation task for the world and print a message when it completes.

The API version will be bumped any time a breaking change is introduced to the API which may impact integrations, so it's recommended to check this and disable your integration if it encounters an unexpected version.

Since the API is new, breaking changes may occur with some frequency, however the goal is to reduce this as much as possible. An effort will also be made to annotate any deprecated methods for at least one release before removal. This duration may be increased in the future.