From 8f39f42e56597e6bacbe9038a670091f85034830 Mon Sep 17 00:00:00 2001 From: PeratX <1215714524@qq.com> Date: Thu, 20 Aug 2020 12:21:54 +0800 Subject: [PATCH] Fix ConsoleInternalApi in ConsoleThread --- .../mamoe/mirai/console/pure/ConsoleThread.kt | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsoleThread.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsoleThread.kt index 2fcb0921a..5447636f8 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsoleThread.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/ConsoleThread.kt @@ -11,10 +11,11 @@ package net.mamoe.mirai.console.pure import kotlinx.coroutines.* import net.mamoe.mirai.console.MiraiConsole -import net.mamoe.mirai.console.command.* +import net.mamoe.mirai.console.command.BuiltInCommands import net.mamoe.mirai.console.command.Command.Companion.primaryName +import net.mamoe.mirai.console.command.CommandExecuteStatus +import net.mamoe.mirai.console.command.CommandManager import net.mamoe.mirai.console.command.CommandManager.INSTANCE.executeCommandDetailed -import net.mamoe.mirai.console.command.CommandManager.INSTANCE.register import net.mamoe.mirai.console.util.ConsoleInternalAPI import net.mamoe.mirai.utils.DefaultLogger import org.fusesource.jansi.Ansi @@ -22,7 +23,7 @@ import java.util.* import java.util.concurrent.Executors import kotlin.concurrent.thread -@ConsoleInternalAPI +@OptIn(ConsoleInternalAPI::class) internal fun startupConsoleThread() { val service = Executors.newSingleThreadExecutor { code -> thread(start = false, isDaemon = false, name = "Console Input", block = code::run) @@ -45,21 +46,6 @@ internal fun startupConsoleThread() { } } - /* - object : AbstractCommand(ConsoleCommandOwner, "test") { - override val usage: String - get() = "? Why usage" - - override suspend fun CommandSender.onCommand(args: Array) { - withContext(Dispatchers.IO) { - launch { sendMessage("I1> " + MiraiConsole.frontEnd.requestInput("Value 1")) } - launch { sendMessage("I2> " + MiraiConsole.frontEnd.requestInput("Value 2")) } - } - } - - }.register(true) - */ - CoroutineScope(dispatch).launch { val consoleLogger = DefaultLogger("Console") while (isActive) { @@ -110,4 +96,4 @@ internal fun startupConsoleThread() { }.exceptionOrNull()?.printStackTrace() } } -} \ No newline at end of file +}