From 825332abfefd498092c31ae57e5e27fd0e996339 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Thu, 18 Feb 2021 01:22:56 +0800 Subject: [PATCH] Update comments --- .../src/MiraiConsoleImplementation.kt | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/backend/mirai-console/src/MiraiConsoleImplementation.kt b/backend/mirai-console/src/MiraiConsoleImplementation.kt index da85d7ddd..7a2417b56 100644 --- a/backend/mirai-console/src/MiraiConsoleImplementation.kt +++ b/backend/mirai-console/src/MiraiConsoleImplementation.kt @@ -31,7 +31,6 @@ import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.utils.BotConfiguration import net.mamoe.mirai.utils.LoginSolver import net.mamoe.mirai.utils.MiraiLogger -import java.lang.IllegalStateException import java.nio.file.Path import java.util.* import java.util.concurrent.locks.ReentrantLock @@ -193,38 +192,60 @@ public interface MiraiConsoleImplementation : CoroutineScope { /// Hooks & Backend Access /** * 后端 在 [phase] 阶段执行前会调用此方法, 如果此方法抛出了一个错误会直接中断 console 初始化 + * + * @since 2.5.0-dev-2 */ public fun prePhase(phase: String) {} /** * 后端 在 [phase] 阶段执行后会调用此方法, 如果此方法抛出了一个错误会直接中断 console 初始化 + * + * @since 2.5.0-dev-2 */ public fun postPhase(phase: String) {} - /** 后端在 [start] 前会调用此方法 */ + /** + * 后端在 [start] 前会调用此方法 + * + * @since 2.5.0-dev-2 + */ public fun preStart() {} - /** 后端在 [start] 后会调用此方法 */ + /** + * 后端在 [start] 后会调用此方法 + * + * @since 2.5.0-dev-2 + */ public fun postStart() {} /** - * 用于提供前端访问后端内部实现 + * 前端访问后端内部实现的桥 + * + * @see backendAccess + * @since 2.5.0-dev-2 */ @ConsoleFrontEndImplementation public interface BackendAccess { // GlobalComponentStorage public val globalComponentStorage: ComponentStorage + // PluginManagerImpl.resolvedPlugins public val resolvedPlugins: MutableList } - public val backendAccess: BackendAccess get() { - if (instanceInitialized) { - if (this === instance) - return backendAccessInstance + /** + * @see BackendAccess + * @since 2.5.0-dev-2 + * @throws IllegalStateException 当前端实例不是 `this` 时抛出 + */ + public val backendAccess: BackendAccess + get() { + if (instanceInitialized) { + if (this === instance) + return backendAccessInstance + } + throw IllegalStateException("Permission denied") } - throw IllegalStateException("Permission denied") - } public companion object { private val backendAccessInstance = object : BackendAccess {