mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 21:23:55 +08:00
Console Update
This commit is contained in:
parent
f4b3dbfa1e
commit
d8feefcc57
mirai-console/src/main/kotlin/net/mamoe/mirai/plugin
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试加载全部插件
|
||||
|
Loading…
Reference in New Issue
Block a user