Commit d8feefcc authored by jiahua.liu's avatar jiahua.liu

Console Update

parent f4b3dbfa
...@@ -22,9 +22,15 @@ object CommandManager { ...@@ -22,9 +22,15 @@ object CommandManager {
if (!registeredCommand.containsKey(commandHead)) { if (!registeredCommand.containsKey(commandHead)) {
return false return false
} }
registeredCommand[commandHead]?.onCommand( val args = blocks.subList(1, blocks.size)
blocks.subList(1, blocks.size) registeredCommand[commandHead]?.run {
) if (onCommand(
blocks.subList(1, blocks.size)
)
) {
PluginManager.onCommand(this, args)
}
}
return true return true
} }
......
...@@ -48,7 +48,7 @@ abstract class PluginBase(coroutineContext: CoroutineContext) : CoroutineScope { ...@@ -48,7 +48,7 @@ abstract class PluginBase(coroutineContext: CoroutineContext) : CoroutineScope {
/** /**
* 当任意指令被使用 * 当任意指令被使用
*/ */
open fun onCommand(command: Command) { open fun onCommand(command: Command, args: List<String>) {
} }
...@@ -176,6 +176,11 @@ object PluginManager { ...@@ -176,6 +176,11 @@ object PluginManager {
//已完成加载的 //已完成加载的
private val nameToPluginBaseMap: MutableMap<String, PluginBase> = mutableMapOf() private val nameToPluginBaseMap: MutableMap<String, PluginBase> = mutableMapOf()
fun onCommand(command: Command, args: List<String>) {
this.nameToPluginBaseMap.values.forEach {
it.onCommand(command, args)
}
}
/** /**
* 尝试加载全部插件 * 尝试加载全部插件
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment