This is the core module of PaperKit, which contains only the Kotlin implementations of general Paper components.
- KotlinPlugin — alternative to JavaPlugin with suspend functions.
- KotlinListener — alternative to Listener with suspend listeners support.
- KotlinCommand — alternative to Command with suspend execute & tabComplete functions.
First of all add the dependency to your project:
implementation("dev.viesoft.paperkit", "core", "VERSION")
implementation 'dev.viesoft.paperkit:core:VERSION'
Then you can use the Kotlin implementations of the Paper components:
class MyPlugin : KotlinPlugin() {
override suspend fun loadConfig() {
// Your plugin config logic here
}
override suspend fun onEnabled() {
// Your plugin start logic here
}
override suspend fun onDisabled() {
// Your plugin stop logic here
}
}
class ExampleCommand(plugin: IKotlinPlugin) : KotlinCommand(plugin, "example") {
override suspend fun execute(sender: CommandSender, alias: String, args: List<String>): Boolean {
sender.sendMessage("Hello!")
return true
}
}
Then in the plugin class:
private val exampleCommand = ExampleCommand(this)
override suspend fun onEnabled() {
exampleCommand.register()
}
override suspend fun onDisabled() {
exampleCommand.unregister()
}