Quick Start
Project Overview
BetterPlugin is a plugin development framework for Paper servers. Its features are grouped by capability area:
| Module | Package | Description | Documentation |
|---|---|---|---|
| Plugin base | org.coffeepop.betterPlugin.api.plugin | Base class for your plugin (PluginBase) | Plugin base |
| Command module | org.coffeepop.betterPlugin.api.command | Command registration and execution | Command API |
| Exceptions | org.coffeepop.betterPlugin.api.exception | Common framework exception types | Exceptions |
Choosing an Entry Class
Plugins that use the framework have two options:
- Extend
JavaPlugindirectly. The command module only needs aJavaPlugininstance, so this path works fine. - Extend
PluginBase. It adds everyday helpers on top ofJavaPlugin: typed config reading, a short logger alias, task scheduling with automatic cleanup on disable,runWhenReady, and acommand()shortcut. See Plugin entry for details.
Both can use CommandBuilder; see Plugin base for details.
Adding the Dependency
Third-party plugins use published tags from JitPack, so no local build is needed. Add the following to your project's build.gradle.kts:
repositories {
maven("https://jitpack.io")
}
dependencies {
compileOnly("com.github.CoffeePopStudio:BetterPlugin:26.13.0-mc26.1.2")
}The first time a version is requested, JitPack builds it in the cloud, which can take a moment. See JitPack for build status and the version list.
Declaring the Runtime Dependency
Declare the dependency in plugin.yml, and place the BetterPlugin jar in the server's plugins/ directory:
name: MyPlugin
version: 1.0.0
main: com.example.MyPlugin
api-version: '26.1.2'
depend: [BetterPlugin]See Integration for the full setup.
Registering Your First Command
import org.bukkit.plugin.java.JavaPlugin;
import org.coffeepop.betterPlugin.api.command.CommandBuilder;
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
CommandBuilder.create(this)
.name("ping")
.executes((sender, command, label, args) -> {
sender.sendPlainMessage("pong");
return true;
})
.register();
}
}You don't need to keep a commands: section in plugin.yml; the framework registers commands for you.
Call
register()duringonEnable(), before Paper'sCOMMANDSevent fires. If you call it from a command executor, a scheduled task, or after startup, the command won't be registered and a warning is logged.