How to add maven dependency to PowerNukkit?

Question

I’m creating a plugin using maven, how do I add a dependency to PowerNukkit so I can use the new APIs?

Answer

plugin.yml (optional)

First, if your plugin requires PowerNukkit to work, add PowerNukkit as a dependency to your plugin.yml file, example:

api: ["1.0.11"]
name: ExamplePlugin
main: com.github.youruser.yourplugin.YourPlugin
version: "1.0.0"
depend: [PowerNukkit]

If your plugin does not require PowerNukkit but may use the new API when running on it, then use softdepend instead:

softdepend: [PowerNukkit]

It will safeguard server owners by letting them know that your plugin requires PowerNukkit or can interact safely with it.

This is an optional but recommended step.

Gradle

If you are using gradle, make sure you have mavenCentral() or jcenter() in your repositories block, than add a dependency to org.powernukkit:powernukkit:<version>, you can see a list of version here and here.

You may also use the dynamic version pattern, the version numbers mean:
upstream.major.minor.patch see the https://semver.org for details.

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.powernukkit:powernukkit:1.3.+'
}

Maven

If you are using maven, just add this into your <dependencies> block, change the version to the minimum PowerNukkit version that is supported by your plugin.

The version numbers mean:
upstream.major.minor.patch see the https://semver.org for details.

    <dependencies>
        <dependency>
            <groupId>org.powernukkit</groupId>
            <artifactId>powernukkit</artifactId>
            <version>1.3.1.4-PN</version>
        </dependency>
    </dependencies>

You don’t need to add repositories to the <repositories> block unless you want to depend on snapshot builds.

Snapshots

If you want to depend on a snapshot from the bleeding branches, you need to add the repository https://oss.sonatype.org/content/repositories/snapshots to your build file.

Using Gradle

repositories {
    mavenCentral()
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}

dependencies {
    implementation 'org.powernukkit:powernukkit:1.4.0.0-PN-SNAPSHOT'
}

Using Maven

    <repositories>
        <repository>
            <id>powernukkit-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.powernukkit</groupId>
            <artifactId>powernukkit</artifactId>
            <version>1.4.0.0-PN-SNAPSHOT</version>
        </dependency>
    </dependencies>