mirror of
https://github.com/devproje/px32-bot.git
synced 2024-11-26 10:43:05 +00:00
remove: removed global command handler
This commit is contained in:
parent
c889cbe2d8
commit
01a003a001
3 changed files with 12 additions and 12 deletions
|
@ -8,7 +8,6 @@ import org.slf4j.Logger
|
|||
import org.slf4j.LoggerFactory
|
||||
|
||||
abstract class Plugin {
|
||||
private val globalCommandHandler = CommandHandler()
|
||||
private val handlerContainer = mutableListOf<ListenerAdapter>()
|
||||
private val config = this.javaClass.getResourceAsStream("/plugin.json")?.let {
|
||||
val raw = it.bufferedReader().readText()
|
||||
|
@ -33,10 +32,6 @@ abstract class Plugin {
|
|||
handlerContainer.remove(listener)
|
||||
}
|
||||
|
||||
fun getCommandContainer(): CommandHandler {
|
||||
return globalCommandHandler
|
||||
}
|
||||
|
||||
abstract fun onLoad()
|
||||
abstract fun destroy()
|
||||
}
|
||||
|
|
|
@ -29,10 +29,6 @@ class CoreKernel(token: String) {
|
|||
}
|
||||
|
||||
fun build(): JDA {
|
||||
handlers.map {
|
||||
builder.addEventListeners(it)
|
||||
}
|
||||
builder.addEventListeners(handler)
|
||||
PluginLoader.load()
|
||||
|
||||
val plugins = PluginLoader.getPlugins()
|
||||
|
@ -40,11 +36,16 @@ class CoreKernel(token: String) {
|
|||
logger.info("Load plugin ${c.name} v${c.version}")
|
||||
p.onLoad()
|
||||
|
||||
builder.addEventListeners(p.getCommandContainer())
|
||||
p.getHandlers().map { handler ->
|
||||
handlers.add(handler)
|
||||
}
|
||||
}
|
||||
|
||||
handlers.map {
|
||||
println("test $it")
|
||||
builder.addEventListeners(it)
|
||||
}
|
||||
builder.addEventListeners(handler)
|
||||
}
|
||||
}
|
||||
|
||||
val jda = builder.build()
|
||||
handler.register(jda)
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package net.projecttl.plugin.sample
|
||||
|
||||
import net.projecttl.p.x32.api.Plugin
|
||||
import net.projecttl.p.x32.api.command.CommandHandler
|
||||
import net.projecttl.plugin.sample.command.Greeting
|
||||
|
||||
class CorePlugin extends Plugin {
|
||||
@Override
|
||||
void onLoad() {
|
||||
logger.info "Hello, World!"
|
||||
commandContainer.addCommand new Greeting()
|
||||
CommandHandler handler = new CommandHandler()
|
||||
handler.addCommand new Greeting()
|
||||
|
||||
addHandler handler
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue