Bladeren bron

plugin disabler

jiahua.liu 6 jaren geleden
bovenliggende
commit
90fc27d612

+ 1 - 1
gradle.properties

@@ -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

+ 0 - 1
mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsole.kt

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

+ 5 - 1
mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandManager.kt

@@ -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()
+    }
+
     /**
      * 注册这个指令.
      *

+ 6 - 0
mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt

@@ -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()
     }