54 lines
1.2 KiB
Kotlin
54 lines
1.2 KiB
Kotlin
package nl.voidcorp.mainplugin
|
|
|
|
import nl.voidcorp.mainplugin.messaging.Message
|
|
import nl.voidcorp.mainplugin.messaging.MessageType
|
|
import org.bukkit.plugin.java.JavaPlugin
|
|
|
|
abstract class VoidPluginBase : JavaPlugin() {
|
|
|
|
final override fun onLoad() {
|
|
plugins += this
|
|
load()
|
|
}
|
|
|
|
final override fun onEnable() {
|
|
enable()
|
|
memeLog()
|
|
}
|
|
|
|
final override fun onDisable() {
|
|
disable()
|
|
}
|
|
|
|
open fun load() {}
|
|
|
|
open fun enable() {}
|
|
|
|
open fun disable() {}
|
|
|
|
open fun recieve(message: Message) {}
|
|
|
|
open fun send(message: Message) {
|
|
pluginMap[message.to]?.recieve(message)
|
|
}
|
|
|
|
fun send(to: String, messageType: MessageType, content: String = "") = send(Message(to, name, content, messageType))
|
|
|
|
abstract val comment: String
|
|
|
|
var doMeme = false
|
|
|
|
private fun memeLog() {
|
|
plugins.last().doMeme = true
|
|
if (doMeme)
|
|
for (plugin in plugins) {
|
|
plugin.logger.info(plugin.comment)
|
|
}
|
|
}
|
|
|
|
companion object {
|
|
private val plugins = mutableListOf<VoidPluginBase>()
|
|
internal val pluginMap: Map<String, VoidPluginBase>
|
|
get() = plugins.map { it.name to it }.toMap()
|
|
}
|
|
} |