Update docs

This commit is contained in:
Him188 2020-08-23 17:24:32 +08:00
parent 98e9fe8b7f
commit 579bb82c27
2 changed files with 13 additions and 2 deletions

View File

@ -17,6 +17,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.console.MiraiConsole.INSTANCE 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.internal.MiraiConsoleImplementationBridge
import net.mamoe.mirai.console.plugin.PluginLoader import net.mamoe.mirai.console.plugin.PluginLoader
import net.mamoe.mirai.console.plugin.center.PluginCenter 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.console.util.ConsoleInternalAPI
import net.mamoe.mirai.utils.BotConfiguration import net.mamoe.mirai.utils.BotConfiguration
import net.mamoe.mirai.utils.MiraiLogger import net.mamoe.mirai.utils.MiraiLogger
import java.io.File
import java.nio.file.Path import java.nio.file.Path
import java.time.Instant 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 class IllegalMiraiConsoleImplementationError @JvmOverloads constructor(
public override val message: String? = null, public override val message: String? = null,
public override val cause: Throwable? = null public override val cause: Throwable? = null

View File

@ -33,8 +33,6 @@ import kotlin.coroutines.CoroutineContext
/** /**
* 标记一个仅用于 [MiraiConsole] 前端实现的 API. 这些 API 只应由前端实现者使用, 而不应该被插件或其他调用者使用. * 标记一个仅用于 [MiraiConsole] 前端实现的 API. 这些 API 只应由前端实现者使用, 而不应该被插件或其他调用者使用.
*
* 前端实现时
*/ */
@Retention(AnnotationRetention.SOURCE) @Retention(AnnotationRetention.SOURCE)
@RequiresOptIn(level = RequiresOptIn.Level.WARNING) @RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@ -113,6 +111,7 @@ public interface MiraiConsoleImplementation : CoroutineScope {
/** 由前端调用, 初始化 [MiraiConsole] 实例, 并启动 */ /** 由前端调用, 初始化 [MiraiConsole] 实例, 并启动 */
@JvmStatic @JvmStatic
@ConsoleFrontEndImplementation @ConsoleFrontEndImplementation
@Throws(IllegalMiraiConsoleImplementationError::class)
public fun MiraiConsoleImplementation.start(): Unit = initLock.withLock { public fun MiraiConsoleImplementation.start(): Unit = initLock.withLock {
this@Companion.instance = this this@Companion.instance = this
MiraiConsoleImplementationBridge.doStart() MiraiConsoleImplementationBridge.doStart()