From 579bb82c2755e4fd4e231962fd1070c478dcebfe Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 23 Aug 2020 17:24:32 +0800 Subject: [PATCH] Update docs --- .../kotlin/net/mamoe/mirai/console/MiraiConsole.kt | 12 ++++++++++++ .../mirai/console/MiraiConsoleImplementation.kt | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsole.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsole.kt index 36a27d7d7..30d744d8b 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsole.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsole.kt @@ -17,6 +17,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import net.mamoe.mirai.Bot import net.mamoe.mirai.console.MiraiConsole.INSTANCE +import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start import net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge import net.mamoe.mirai.console.plugin.PluginLoader import net.mamoe.mirai.console.plugin.center.PluginCenter @@ -25,6 +26,7 @@ import net.mamoe.mirai.console.util.ConsoleExperimentalAPI import net.mamoe.mirai.console.util.ConsoleInternalAPI import net.mamoe.mirai.utils.BotConfiguration import net.mamoe.mirai.utils.MiraiLogger +import java.io.File import java.nio.file.Path import java.time.Instant @@ -107,6 +109,16 @@ public interface MiraiConsole : CoroutineScope { } } +/** + * @see MiraiConsole.rootPath + */ +public val MiraiConsole.rootDir: File get() = rootPath.toFile() + +/** + * [MiraiConsoleImplementation] 实现有误时抛出. + * + * @see MiraiConsoleImplementation.start + */ public class IllegalMiraiConsoleImplementationError @JvmOverloads constructor( public override val message: String? = null, public override val cause: Throwable? = null 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 a3b62baa2..f008991a6 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 @@ -33,8 +33,6 @@ import kotlin.coroutines.CoroutineContext /** * 标记一个仅用于 [MiraiConsole] 前端实现的 API. 这些 API 只应由前端实现者使用, 而不应该被插件或其他调用者使用. - * - * 前端实现时 */ @Retention(AnnotationRetention.SOURCE) @RequiresOptIn(level = RequiresOptIn.Level.WARNING) @@ -113,6 +111,7 @@ public interface MiraiConsoleImplementation : CoroutineScope { /** 由前端调用, 初始化 [MiraiConsole] 实例, 并启动 */ @JvmStatic @ConsoleFrontEndImplementation + @Throws(IllegalMiraiConsoleImplementationError::class) public fun MiraiConsoleImplementation.start(): Unit = initLock.withLock { this@Companion.instance = this MiraiConsoleImplementationBridge.doStart()