Annotation Processing Tool for PowerNukkitX plugins.
PNX-APT removes boilerplate from your plugin development by generating code at compile time. Instead of manually registering every listener, command, and config value — just annotate your classes and let the processor handle the rest.
@PluginMeta— generates yourplugin.ymlfrom code@AutoListener— automatically registers all your event listeners@Scheduler— auto-registers and schedules tasks
@Command— auto-registers commands@Config— maps config values into typed fields
PNX-APT is distributed via JitPack.
Add the JitPack repository to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>Add the dependency:
<dependency>
<groupId>com.github.pleaseinsertnamehere</groupId>
<artifactId>pnx-apt</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>Configure the annotation processor in maven-compiler-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.github.pleaseinsertnamehere</groupId>
<artifactId>pnx-apt</artifactId>
<version>VERSION</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>Add the JitPack repository to your build.gradle:
repositories {
maven { url 'https://jitpack.io' }
}Add the dependency:
dependencies {
compileOnly 'com.github.pleaseinsertnamehere:pnx-apt:VERSION'
annotationProcessor 'com.github.pleaseinsertnamehere:pnx-apt:VERSION'
}PNX-APT generates source files at compile time. To make your IDE aware of the generated classes:
- Run
mvn compileonce — this generatesPNXAPTundertarget/generated-sources/annotations/ - IntelliJ will automatically recognize the folder as a generated sources root
To avoid having to do this after every mvn clean, enable annotation processing in IntelliJ:
Settings → Build, Execution, Deployment → Compiler → Annotation Processors → Enable annotation processing
You need to initialize the processor in your main plugin class. Just call PNXAPT.init(this) in onEnable().
public class MyPlugin extends PluginBase {
@Override
public void onEnable() {
PNXAPT.init(this);
}
}Annotate your main plugin class with @PluginMeta to generate a plugin.yml at compile time. No need to maintain a plugin.yml in src/main/resources manually — just delete it.
@PluginMeta(
name = "MyPlugin",
version = "1.0.0",
api = {"2.0.0"},
authors = {"Steve"},
description = "My cool plugin"
)
public class MyPlugin extends PluginBase {
// Your code in here
}| Field | Required | Description |
|---|---|---|
name |
✅ | Plugin name |
version |
✅ | Plugin version |
api |
✅ | Supported PNX API versions |
authors |
❌ | Plugin authors |
description |
❌ | Short description |
website |
❌ | Plugin website |
prefix |
❌ | Log prefix |
depend |
❌ | Hard dependencies |
softDepend |
❌ | Soft dependencies |
loadBefore |
❌ | Plugins to load after this one |
order |
❌ | Load order (STARTUP or POSTWORLD) |
features |
❌ | PNX feature flags |
Note:
@PluginMetacan only be used on a class that extendsPluginBase, and only once per project.
Annotate your listener classes with @AutoListener — no manual registration needed.
import dev.pleaseinsertnamehere.pnxapt.annotations.AutoListener;
@AutoListener
public class PlayerJoinListener implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().sendMessage("Welcome!");
}
}That's it. Every class annotated with @AutoListener is automatically picked up and registered.
Note:
@AutoListenercan only be used on classes that implementcn.nukkit.event.Listener.
Annotate Runnables with @Scheduler to have them automatically registered and scheduled.
import dev.pleaseinsertnamehere.pnxapt.annotations.Scheduler;
@Scheduler(delay = 20, period = 100)
public class MyTask extends Task {
@Override
public void onRun(int currentTick) {
// Task code here
}
}Or annotate any methods which are public static:
import dev.pleaseinsertnamehere.pnxapt.annotations.Scheduler;
public class MyPlugin extends PluginBase {
@Scheduler(delay = 20, period = 100, async = true)
public static void myScheduledMethod() {
// Task code here
}
}- Java 21+
- PowerNukkitX
2.0.0-SNAPSHOTor later
PNX-APT is licensed under MIT.