From aa3c8baccbce0ed807f0fb5c858d4922dae8bd3e Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 13 Sep 2020 00:26:50 +0800 Subject: [PATCH] Add Java bridge for implementing ConsoleInput --- .../console/MiraiConsoleImplementation.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt index 0090bcc7a..8e53e4f9c 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt @@ -118,6 +118,9 @@ public interface MiraiConsoleImplementation : CoroutineScope { withContext(Dispatchers.IO) { sendMessageJ(message) } } + /** + * [ConsoleCommandSender] + */ public val consoleCommandSender: ConsoleCommandSenderImpl public val dataStorageForJvmPluginLoader: PluginDataStorage @@ -127,9 +130,27 @@ public interface MiraiConsoleImplementation : CoroutineScope { /** * @see ConsoleInput 的实现 + * @see JConsoleInput */ public val consoleInput: ConsoleInput + /** + * 供 Java 用户实现 [ConsoleInput] + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @ConsoleFrontEndImplementation + public interface JConsoleInput : ConsoleInput { + /** + * @see ConsoleInput.requestInput + */ + @JvmName("requestInput") + public fun requestInputJ(hint: String): String + + override suspend fun requestInput(hint: String): String { + return withContext(Dispatchers.IO) { requestInputJ(hint) } + } + } + /** * 创建一个 [LoginSolver] *