Update KSpigot.kt
This commit is contained in:
@@ -9,18 +9,41 @@ import org.bukkit.plugin.java.JavaPlugin
|
|||||||
* It should be initialized when a plugin using
|
* It should be initialized when a plugin using
|
||||||
* kSpigot gets enabled.
|
* kSpigot gets enabled.
|
||||||
*
|
*
|
||||||
* Do not forget to call the [shutdown] method
|
* **Instead** of overriding [onLoad()], [onEnable()]
|
||||||
* when your plugin gets disabled.
|
* and [onDisable()] **override**:
|
||||||
|
* - [load()] (called first)
|
||||||
|
* - [startup()] (called second)
|
||||||
|
* - [shutdown()] (called in the "end")
|
||||||
*/
|
*/
|
||||||
class KSpigot(val plugin: JavaPlugin) {
|
abstract class KSpigot : JavaPlugin() {
|
||||||
|
|
||||||
val kRunnableHolder = KRunnableHolder()
|
val kRunnableHolder = KRunnableHolder()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function should be invoked
|
* Called when the plugin was loaded
|
||||||
* in the onDisable() method of your plugin.
|
|
||||||
*/
|
*/
|
||||||
fun shutdown() {
|
open fun load() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the plugin was enabled
|
||||||
|
*/
|
||||||
|
open fun startup() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the plugin gets disabled
|
||||||
|
*/
|
||||||
|
open fun shutdown() { }
|
||||||
|
|
||||||
|
final override fun onLoad() {
|
||||||
|
load()
|
||||||
|
}
|
||||||
|
|
||||||
|
final override fun onEnable() {
|
||||||
|
startup()
|
||||||
|
}
|
||||||
|
|
||||||
|
final override fun onDisable() {
|
||||||
|
shutdown()
|
||||||
kRunnableHolder.shutdown()
|
kRunnableHolder.shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user