Skip to content

Latest commit

 

History

History

core

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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