plugin disabler

This commit is contained in:
jiahua.liu 2020-03-22 20:52:57 +08:00
parent c42250072b
commit 90fc27d612
4 changed files with 12 additions and 3 deletions

View File

@ -1,7 +1,7 @@
# style guide
kotlin.code.style=official
# config
miraiVersion=0.28.0
miraiVersion=0.29.0
miraiConsoleVersion=0.3.4
miraiConsoleWrapperVersion=0.1.3
kotlin.incremental.multiplatform=true

View File

@ -195,7 +195,6 @@ internal object MiraiConsoleLogger {
if (e != null) {
MiraiConsole.frontEnd.pushLog(LogPriority.INFO, identityStr, identity, e.stackTrace.joinToString("\n"))
}
}
}

View File

@ -24,9 +24,13 @@ object CommandManager : Job by {
}
}() {
private val registeredCommand: MutableMap<String, Command> = mutableMapOf()
val commands: Collection<Command> get() = registeredCommand.values
fun reload(){
registeredCommand.clear()
DefaultCommands()
}
/**
* 注册这个指令.
*

View File

@ -14,7 +14,9 @@ package net.mamoe.mirai.console.plugins
import kotlinx.coroutines.CancellationException
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.command.Command
import net.mamoe.mirai.console.command.CommandManager
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.DefaultCommands
import net.mamoe.mirai.utils.SimpleLogger
import net.mamoe.mirai.utils.io.encodeToString
import java.io.File
@ -236,6 +238,9 @@ object PluginManager {
}
/**
* 请注意 这个方法不会移除该指令已注册的指令
*/
fun disablePlugin(
plugin:PluginBase,
exception: CancellationException? = null
@ -253,6 +258,7 @@ object PluginManager {
}
nameToPluginBaseMap.clear()
pluginDescriptions.clear()
CommandManager.reload()
}