Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 1.93 KB

README.md

File metadata and controls

77 lines (54 loc) · 1.93 KB

PaperKit Core

Download

This is the core module of PaperKit, which contains only the Kotlin implementations of general Paper components.

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.

Get Started

First of all add the dependency to your project:

Kotlin

implementation("dev.viesoft.paperkit", "core", "VERSION")
Groovy
implementation 'dev.viesoft.paperkit:core:VERSION'

Then you can use the Kotlin implementations of the Paper components:

KotlinPlugin

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
    }
}

KotlinCommand

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()
}