1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-04-25 21:23:55 +08:00

Console Update

This commit is contained in:
jiahua.liu 2020-01-25 17:27:34 +08:00
parent f4b3dbfa1e
commit d8feefcc57
2 changed files with 15 additions and 4 deletions
mirai-console/src/main/kotlin/net/mamoe/mirai/plugin

View File

@ -22,9 +22,15 @@ object CommandManager {
if (!registeredCommand.containsKey(commandHead)) {
return false
}
registeredCommand[commandHead]?.onCommand(
blocks.subList(1, blocks.size)
)
val args = blocks.subList(1, blocks.size)
registeredCommand[commandHead]?.run {
if (onCommand(
blocks.subList(1, blocks.size)
)
) {
PluginManager.onCommand(this, args)
}
}
return true
}

View File

@ -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 {
//已完成加载的
private val nameToPluginBaseMap: MutableMap<String, PluginBase> = mutableMapOf()
fun onCommand(command: Command, args: List<String>) {
this.nameToPluginBaseMap.values.forEach {
it.onCommand(command, args)
}
}
/**
* 尝试加载全部插件