diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt index 274bc3aa4..882e6bb02 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt @@ -38,8 +38,6 @@ public abstract class AbstractPluginData : PluginData, PluginDataImpl() { /** * 所有 [valueNodes] 更新和保存序列化器. 仅供内部使用 - * - * @suppress 注意, 这是实验性 API. */ public final override val updaterSerializer: KSerializer get() = super.updaterSerializer diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt index d4004c82f..f76cc13a8 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt @@ -176,9 +176,7 @@ public interface PluginData { ): T /** - * 所有 [valueNodes] 更新和保存序列化器. 仅供内部使用 - * - * @suppress 注意, 这是实验性 API. + * 所有 [valueNodes] 更新和保存序列化器. 仅供内部使用。 */ public val updaterSerializer: KSerializer diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataStorage.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataStorage.kt index 2f1bb0ec1..0c9e0e55e 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataStorage.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataStorage.kt @@ -30,6 +30,9 @@ import java.nio.file.Path * * [JvmPluginLoader] 实现一个 [PluginDataStorage], 用于管理所有 [JvmPlugin] 的 [PluginData] 实例. * + * ### 实现 [PluginDataStorage] + * 无特殊需求。实现两个成员函数即可。可参考内建 [MultiFilePluginDataStorageImpl] + * * @see PluginDataHolder * @see JvmPluginLoader.dataStorage */ diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/Extension.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/Extension.kt index 9a83ef339..e26d1398a 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/Extension.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/Extension.kt @@ -13,10 +13,28 @@ import net.mamoe.mirai.console.extensions.PermissionServiceProvider import net.mamoe.mirai.console.extensions.PluginLoaderProvider import net.mamoe.mirai.console.extensions.SingletonExtensionSelector import net.mamoe.mirai.console.extensions.SingletonExtensionSelector.ExtensionPoint.selectSingleton +import net.mamoe.mirai.console.plugin.jvm.JvmPlugin +import net.mamoe.mirai.console.plugin.jvm.JvmPlugin.Companion.onLoad /** * 表示一个扩展. * + * ### 获取扩展 + * Console 不允许插件获取自己或其他插件注册的扩展。 + * + * ### 注册扩展 + * 插件仅能在 [JvmPlugin.onLoad] 阶段注册扩展。 + * + * ```kotlin + * object MyPlugin : KotlinPlugin( /* ... */ ) { + * fun PluginComponentStorage.onLoad() { + * contributePermissionService { /* ... */ } + * contributePluginLoader { /* ... */ } + * contribute(ExtensionPoint) { /* ... */ } + * } + * } + * ``` + * * @see ComponentStorage */ public interface Extension diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PluginLoaderProvider.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PluginLoaderProvider.kt index 5a8912130..510a1119b 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PluginLoaderProvider.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PluginLoaderProvider.kt @@ -10,11 +10,14 @@ package net.mamoe.mirai.console.extensions import net.mamoe.mirai.console.extension.AbstractExtensionPoint +import net.mamoe.mirai.console.extension.Extension import net.mamoe.mirai.console.extension.InstanceExtension import net.mamoe.mirai.console.plugin.loader.PluginLoader /** * 提供扩展 [PluginLoader] + * + * @see Extension */ public interface PluginLoaderProvider : InstanceExtension> { public companion object ExtensionPoint : AbstractExtensionPoint(PluginLoaderProvider::class)