diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/Plugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/Plugin.kt index b4b2f3d53..dbbbc3614 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/Plugin.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/Plugin.kt @@ -11,16 +11,15 @@ package net.mamoe.mirai.console.plugin +import com.vdurmont.semver4j.Semver import net.mamoe.mirai.console.command.CommandOwner -import net.mamoe.mirai.console.data.PluginConfig -import net.mamoe.mirai.console.data.PluginData import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.disable import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.enable import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.safeLoader +import net.mamoe.mirai.console.plugin.description.PluginDependency import net.mamoe.mirai.console.plugin.description.PluginDescription +import net.mamoe.mirai.console.plugin.description.PluginKind import net.mamoe.mirai.console.plugin.jvm.JvmPlugin -import java.io.File -import java.nio.file.Path /** * 表示一个 mirai-console 插件. @@ -51,86 +50,39 @@ public interface Plugin : CommandOwner { } /** - * 获取 + * 获取 [PluginDescription] */ public inline val Plugin.description: PluginDescription get() = this.safeLoader.getDescription(this) /** - * 支持文件系统存储的扩展. - * - * @suppress 此接口只应由 [JvmPlugin] 继承 - * - * @see JvmPlugin + * 获取 [PluginDescription.name`] */ -public interface PluginFileExtensions { - /** - * 数据目录路径 - * @see PluginData - */ - public val dataFolderPath: Path +public inline val Plugin.name: String get() = this.description.name - /** - * 数据目录. `dataFolderPath.toFile()` - * @see PluginData - */ - public val dataFolder: File +/** + * 获取 [PluginDescription.version] + */ +public inline val Plugin.version: Semver get() = this.description.version +/** + * 获取 [PluginDescription.kind] + */ +public inline val Plugin.kind: PluginKind get() = this.description.kind - /** - * 从数据目录获取一个文件. - * @see dataFolderPath - */ - @JvmDefault - public fun resolveDataFile(relativePath: String): File = dataFolderPath.resolve(relativePath).toFile() +/** + * 获取 [PluginDescription.info] + */ +public inline val Plugin.info: String get() = this.description.info - /** - * 从数据目录获取一个文件. - * @see dataFolderPath - */ - @JvmDefault - public fun resolveDataPath(relativePath: String): Path = dataFolderPath.resolve(relativePath) +/** + * 获取 [PluginDescription.author] + */ +public inline val Plugin.author: String get() = this.description.author - /** - * 从数据目录获取一个文件. - * @see dataFolderPath - */ - @JvmDefault - public fun resolveDataFile(relativePath: Path): File = dataFolderPath.resolve(relativePath).toFile() - - /** - * 从数据目录获取一个文件路径. - * @see dataFolderPath - */ - @JvmDefault - public fun resolveDataPath(relativePath: Path): Path = dataFolderPath.resolve(relativePath) - - - /** - * 插件配置保存路径 - * @see PluginConfig - */ - public val configFolderPath: Path - - /** - * 插件配置保存路径 - * @see PluginConfig - */ - public val configFolder: File - - - /** - * 从配置目录获取一个文件. - * @see configFolderPath - */ - @JvmDefault - public fun resolveConfigFile(relativePath: String): File = configFolderPath.resolve(relativePath).toFile() - - /** - * 从配置目录获取一个文件. - * @see configFolderPath - */ - @JvmDefault - public fun resolveConfigPath(relativePath: String): Path = configFolderPath.resolve(relativePath) +/** + * 获取 [PluginDescription.dependencies] + */ +public inline val Plugin.dependencies: List get() = this.description.dependencies /** * 从配置目录获取一个文件.