From 5ef8cec447a8d5d61c818f4ab34b59f914c1e327 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sat, 26 Sep 2020 23:51:00 +0800 Subject: [PATCH 01/16] Fix Terminal version rendering. --- backend/mirai-console/build.gradle.kts | 4 ++-- .../mirai/console/internal/MiraiConsoleBuildConstants.kt | 5 +++-- .../console/terminal/MiraiConsoleImplementationTerminal.kt | 4 +++- .../mirai/console/terminal/MiraiConsoleTerminalLoader.kt | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/mirai-console/build.gradle.kts b/backend/mirai-console/build.gradle.kts index 3bb13026b..4795a996c 100644 --- a/backend/mirai-console/build.gradle.kts +++ b/backend/mirai-console/build.gradle.kts @@ -100,8 +100,8 @@ tasks { })""" } .replace( - Regex("""val version: SemVersion = SemVersion.parse\(".*"\)""") - ) { """val version: SemVersion = SemVersion.parse("${project.version}")""" } + Regex("""const val versionConst:\s+String\s+=\s+".*"""") + ) { """const val versionConst: String = "${project.version}"""" } ) } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleBuildConstants.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleBuildConstants.kt index 95306d28e..b3abe5cbd 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleBuildConstants.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleBuildConstants.kt @@ -14,8 +14,9 @@ import java.time.Instant internal object MiraiConsoleBuildConstants { // auto-filled on build (task :mirai-console:fillBuildConstants) @JvmStatic - val buildDate: Instant = Instant.ofEpochSecond(1600663022) + val buildDate: Instant = Instant.ofEpochSecond(1601134282) + const val versionConst: String = "1.0-RC-dev-29" @JvmStatic - val version: SemVersion = SemVersion("1.0-RC-dev-28") + val version: SemVersion = SemVersion(versionConst) } diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt index c6d790a76..1cd89f853 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt @@ -151,7 +151,9 @@ val terminal: Terminal = run { private object ConsoleFrontEndDescImpl : MiraiConsoleFrontEndDescription { override val name: String get() = "Terminal" override val vendor: String get() = "Mamoe Technologies" - override val version: SemVersion = net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.version + // net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.version + // is console's version not frontend's version + override val version: SemVersion = SemVersion(net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.versionConst) } private val ANSI_RESET = Ansi().reset().toString() diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt index 2aa23e0b6..06bdaf650 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt @@ -59,7 +59,8 @@ object MiraiConsoleTerminalLoader { @ConsoleTerminalExperimentalApi fun printHelpMessage() { val help = listOf( - "" to "Mirai-Console[Terminal FrontEnd] v" + kotlin.runCatching { + "" to "Mirai-Console[Terminal FrontEnd] v" + net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.versionConst, + "" to " [ BackEnd] v" + kotlin.runCatching { net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.version }.getOrElse { "" }, "" to "", From 5af02a4b7310c06dc66b916221f3e78df6e8ee55 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 27 Sep 2020 02:32:57 +0800 Subject: [PATCH 02/16] Remove gitVersion --- buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt | 6 ++++-- .../net/mamoe/mirai/console/gradle/VersionConstants.kt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt index b8567aaec..f18ecea8a 100644 --- a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt +++ b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt @@ -36,8 +36,8 @@ class MiraiConsoleBuildPlugin : Plugin { attributes( "Manifest-Version" to "1", "Implementation-Vendor" to "Mamoe Technologies", - "Implementation-Title" to target.name.toString(), - "Implementation-Version" to target.version.toString() + "+" + gitVersion + "Implementation-Title" to target.name, + "Implementation-Version" to target.version.toString() //+ "+" + gitVersion ) } @Suppress("UNCHECKED_CAST") @@ -120,6 +120,7 @@ fun Project.findLatestFile(): Pair { } ?: error("cannot find any file to upload")*/ } +/* val gitVersion: String by lazy { runCatching { val exec = Runtime.getRuntime().exec("git rev-parse HEAD") @@ -132,3 +133,4 @@ val gitVersion: String by lazy { return@lazy "UNKNOWN" }.getOrThrow() } +*/ \ No newline at end of file diff --git a/tools/gradle-plugin/src/main/kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt b/tools/gradle-plugin/src/main/kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt index 2db0c82e2..c4fc5e2bf 100644 --- a/tools/gradle-plugin/src/main/kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt +++ b/tools/gradle-plugin/src/main/kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt @@ -10,6 +10,6 @@ package net.mamoe.mirai.console.gradle internal object VersionConstants { - const val CONSOLE_VERSION = "1.0-RC-dev-28" // value is written here automatically during build + const val CONSOLE_VERSION = "1.0-RC-dev-29" // value is written here automatically during build const val CORE_VERSION = "1.3.0" // value is written here automatically during build } \ No newline at end of file From 0d21ee4c1b7d1df1001f44cff13bc7b801e8ba43 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sun, 27 Sep 2020 13:01:16 +0800 Subject: [PATCH 03/16] Fix stdout encoding --- .../mirai/console/terminal/MiraiConsoleTerminalLoader.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt index 06bdaf650..8436da087 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt @@ -172,14 +172,18 @@ internal fun overrideSTD() { PrintStream( BufferedOutputStream( logger = DefaultLogger("stdout").run { ({ line: String? -> info(line) }) } - ) + ), + false, + Charsets.UTF_8 ) ) System.setErr( PrintStream( BufferedOutputStream( logger = DefaultLogger("stderr").run { ({ line: String? -> warning(line) }) } - ) + ), + false, + Charsets.UTF_8 ) ) } From 7a2b6e721cb0a93d96565ef645a3e65c9dde9ae2 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sun, 27 Sep 2020 13:16:45 +0800 Subject: [PATCH 04/16] Fix build --- .../mirai/console/terminal/MiraiConsoleTerminalLoader.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt index 8436da087..930e72b48 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt @@ -174,7 +174,7 @@ internal fun overrideSTD() { logger = DefaultLogger("stdout").run { ({ line: String? -> info(line) }) } ), false, - Charsets.UTF_8 + "UTF-8" ) ) System.setErr( @@ -183,7 +183,7 @@ internal fun overrideSTD() { logger = DefaultLogger("stderr").run { ({ line: String? -> warning(line) }) } ), false, - Charsets.UTF_8 + "UTF-8" ) ) } From e214a430433eeb40bc1b8e926829b724087077ff Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 2 Oct 2020 13:45:25 +0800 Subject: [PATCH 05/16] Fix IDE resolve on startup --- buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt | 3 +-- .../run/projects/test-project/build.gradle.kts | 2 +- .../net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt index f18ecea8a..8dbd47d8a 100644 --- a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt +++ b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt @@ -127,8 +127,7 @@ val gitVersion: String by lazy { exec.waitFor() exec.inputStream.readBytes().toString(Charsets.UTF_8).trim().also { println("Git commit id: $it") - } - }.onFailure { + } }.onFailure { it.printStackTrace() return@lazy "UNKNOWN" }.getOrThrow() diff --git a/tools/intellij-plugin/run/projects/test-project/build.gradle.kts b/tools/intellij-plugin/run/projects/test-project/build.gradle.kts index 72f695b95..e1c0ff8b7 100644 --- a/tools/intellij-plugin/run/projects/test-project/build.gradle.kts +++ b/tools/intellij-plugin/run/projects/test-project/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { compileOnly(kotlin("stdlib-jdk8")) val core = "1.3.0" - val console = "1.0-RC-dev-4" + val console = "1.0-RC-dev-28" compileOnly("net.mamoe:mirai-console:$console") compileOnly("net.mamoe:mirai-core:$core") diff --git a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt index a03640687..723da4408 100644 --- a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt +++ b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt @@ -19,7 +19,6 @@ import net.mamoe.mirai.console.compiler.common.resolve.findParent import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptor -import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName import org.jetbrains.kotlin.idea.references.KtSimpleNameReference import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor @@ -98,7 +97,7 @@ fun KtDeclaration.resolveAllCallsWithElement(bindingContext: BindingContext): Se .filterIsInstance() .mapNotNull { val callee = it.calleeExpression ?: return@mapNotNull null - val resolved = callee.getResolvedCallOrResolveToCall(bindingContext) ?: return@mapNotNull null + val resolved = callee.getResolvedCall(bindingContext) ?: return@mapNotNull null resolved to it } @@ -128,7 +127,7 @@ fun KtElement?.getResolvedCallOrResolveToCall( context: BindingContext, bodyResolveMode: BodyResolveMode = BodyResolveMode.PARTIAL, ): ResolvedCall? { - return this?.getCall(context)?.getResolvedCall(context) ?: this?.resolveToCall(bodyResolveMode) + return this?.getCall(context)?.getResolvedCall(context)// ?: this?.resolveToCall(bodyResolveMode) } val ResolvedCall.valueParameters: List get() = this.resultingDescriptor.valueParameters From 48efa5a469546806c077936af719f6d713e32ca5 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 2 Oct 2020 13:47:22 +0800 Subject: [PATCH 06/16] 1.0-RC-dev-30 --- buildSrc/src/main/kotlin/Versions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 801f93344..181c9d0da 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -9,7 +9,7 @@ object Versions { const val core = "1.3.0" - const val console = "1.0-RC-dev-29" + const val console = "1.0-RC-dev-30" const val consoleGraphical = "0.0.7" const val consoleTerminal = console From b1bb417388d56d8087e45ab2b622ca47e81377ff Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 4 Oct 2020 22:28:56 +0800 Subject: [PATCH 07/16] Bump versions --- buildSrc/src/main/kotlin/Versions.kt | 2 +- .../kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt | 2 +- tools/intellij-plugin/build.gradle.kts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 181c9d0da..d5f4b7ac6 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -26,6 +26,6 @@ object Versions { const val bintray = "1.8.5" - const val blockingBridge = "1.0.5" + const val blockingBridge = "1.1.0" const val yamlkt = "0.5.3" } \ No newline at end of file diff --git a/tools/gradle-plugin/src/main/kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt b/tools/gradle-plugin/src/main/kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt index c4fc5e2bf..6c293ee10 100644 --- a/tools/gradle-plugin/src/main/kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt +++ b/tools/gradle-plugin/src/main/kotlin/net/mamoe/mirai/console/gradle/VersionConstants.kt @@ -10,6 +10,6 @@ package net.mamoe.mirai.console.gradle internal object VersionConstants { - const val CONSOLE_VERSION = "1.0-RC-dev-29" // value is written here automatically during build + const val CONSOLE_VERSION = "1.0-RC-dev-30" // value is written here automatically during build const val CORE_VERSION = "1.3.0" // value is written here automatically during build } \ No newline at end of file diff --git a/tools/intellij-plugin/build.gradle.kts b/tools/intellij-plugin/build.gradle.kts index 93a94e3f8..2c02d5f7c 100644 --- a/tools/intellij-plugin/build.gradle.kts +++ b/tools/intellij-plugin/build.gradle.kts @@ -52,7 +52,7 @@ tasks.withType { sinceBuild("193.*") untilBuild("205.*") pluginDescription(""" - Plugin development support for Mirai Conosle + Plugin development support for Mirai Console

Features

    From ab5f9f5ceecb4628999b1defaf99facd9d268677 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Wed, 7 Oct 2020 13:25:14 +0800 Subject: [PATCH 08/16] Transfer `allocatePermissionIdForPlugin` to member function --- .../internal/plugin/JvmPluginInternal.kt | 4 +-- .../mirai/console/permission/PermissionId.kt | 7 +++++ .../console/permission/PermissionService.kt | 28 +++++++++++++++++-- .../console/plugin/jvm/AbstractJvmPlugin.kt | 4 ++- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt index 9cd06244f..9284baaa1 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt @@ -18,7 +18,6 @@ import net.mamoe.mirai.console.extension.PluginComponentStorage import net.mamoe.mirai.console.internal.data.mkdir import net.mamoe.mirai.console.permission.Permission import net.mamoe.mirai.console.permission.PermissionService -import net.mamoe.mirai.console.permission.PermissionService.Companion.allocatePermissionIdForPlugin import net.mamoe.mirai.console.plugin.Plugin import net.mamoe.mirai.console.plugin.PluginManager import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.safeLoader @@ -26,7 +25,6 @@ import net.mamoe.mirai.console.plugin.ResourceContainer.Companion.asResourceCont import net.mamoe.mirai.console.plugin.jvm.AbstractJvmPlugin import net.mamoe.mirai.console.plugin.jvm.JvmPlugin import net.mamoe.mirai.console.plugin.jvm.JvmPlugin.Companion.onLoad -import net.mamoe.mirai.console.plugin.name import net.mamoe.mirai.console.util.NamedSupervisorJob import net.mamoe.mirai.utils.MiraiLogger import java.io.File @@ -50,7 +48,7 @@ internal abstract class JvmPluginInternal( final override val parentPermission: Permission by lazy { PermissionService.INSTANCE.register( - PermissionService.INSTANCE.allocatePermissionIdForPlugin(name, "*"), + PermissionService.INSTANCE.allocatePermissionIdForPlugin(this, "*", PermissionService.PluginPermissionIdRequestType.ROOT_PERMISSION), "The base permission" ) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionId.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionId.kt index 86fb7e3c3..9a92e8be2 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionId.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionId.kt @@ -31,6 +31,13 @@ public data class PermissionId( @ResolveContext(PERMISSION_NAME) public val name: String, ) { init { + require(!namespace.contains(' ')) { + "' ' is not allowed in namespace" + } + require(!name.contains(' ')) { + "' ' is not allowed in id" + } + require(!namespace.contains(':')) { "':' is not allowed in namespace" } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt index 88c55556d..1a12b8af1 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt @@ -16,6 +16,8 @@ import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME import net.mamoe.mirai.console.extensions.PermissionServiceProvider import net.mamoe.mirai.console.internal.permission.checkType import net.mamoe.mirai.console.permission.Permission.Companion.parentsWithSelf +import net.mamoe.mirai.console.plugin.Plugin +import net.mamoe.mirai.console.plugin.name import kotlin.reflect.KClass /** @@ -89,6 +91,13 @@ public interface PermissionService

    { parent: Permission = RootPermission, ): P + /** 为 [Plugin] 分配一个 [PermissionId] */ + public fun allocatePermissionIdForPlugin( + plugin: Plugin, + @ResolveContext(COMMAND_NAME) permissionName: String, + reason: PluginPermissionIdRequestType + ): PermissionId = allocatePermissionIdForPluginDefaultImplement(plugin, permissionName, reason) + /////////////////////////////////////////////////////////////////////////// /** @@ -116,6 +125,15 @@ public interface PermissionService

    { @Throws(UnsupportedOperationException::class) public fun cancel(permitteeId: PermitteeId, permission: P, recursive: Boolean) + /** [Plugin] 尝试分配的 [PermissionId] 来源 */ + public enum class PluginPermissionIdRequestType { + /** For [Plugin.parentPermission] */ + ROOT_PERMISSION, + + /** For [Plugin.permissionId] */ + PERMISSION_ID + } + public companion object { internal var instanceField: PermissionService<*>? = null @@ -131,8 +149,14 @@ public interface PermissionService

    { public fun

    PermissionService

    .getOrFail(id: PermissionId): P = get(id) ?: throw NoSuchElementException("Permission not found: $id") - internal fun PermissionService<*>.allocatePermissionIdForPlugin(pluginName: String, @ResolveContext(COMMAND_NAME) permissionName: String) = - PermissionId("plugin.${pluginName.toLowerCase()}", permissionName.toLowerCase()) + internal fun PermissionService<*>.allocatePermissionIdForPluginDefaultImplement( + plugin: Plugin, + @ResolveContext(COMMAND_NAME) permissionName: String, + reason: PluginPermissionIdRequestType + ) = PermissionId( + plugin.name.toLowerCase().replace(' ', '.'), + permissionName.toLowerCase().replace(' ', '.') + ) public fun PermissionId.findCorrespondingPermission(): Permission? = INSTANCE[this] diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt index 9ed8caa29..9b64d84f9 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt @@ -16,6 +16,7 @@ import net.mamoe.mirai.console.data.PluginConfig import net.mamoe.mirai.console.data.PluginData import net.mamoe.mirai.console.internal.plugin.JvmPluginInternal import net.mamoe.mirai.console.permission.PermissionId +import net.mamoe.mirai.console.permission.PermissionService import net.mamoe.mirai.console.util.ConsoleExperimentalApi import net.mamoe.mirai.utils.minutesToMillis import net.mamoe.mirai.utils.secondsToMillis @@ -37,7 +38,8 @@ public abstract class AbstractJvmPlugin @JvmOverloads constructor( public final override val loader: JvmPluginLoader get() = super.loader - public final override fun permissionId(name: String): PermissionId = PermissionId(description.id, name) + public final override fun permissionId(name: String): PermissionId = + PermissionService.INSTANCE.allocatePermissionIdForPlugin(this, "*", PermissionService.PluginPermissionIdRequestType.PERMISSION_ID) /** * 重载 [PluginData] From b52ba9dc2c7803d9f14b1d658711d32b6cb70d45 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 9 Oct 2020 21:43:13 +0800 Subject: [PATCH 09/16] Fix typo --- .../main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt index d10324141..8830312bf 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt @@ -96,7 +96,7 @@ import kotlin.internal.LowPriorityInOverloadResolution */ public interface MessageScope { /** - * 如果此 [MessageScope], 仅包含一个消息对象, 则 [realTarget] 指向这个对象. + * 如果此 [MessageScope] 仅包含一个消息对象, 则 [realTarget] 指向这个对象. 否则 [realTarget] 为 `null`. * * 对于 [CommandSender] 作为 [MessageScope], [realTarget] 总是指令执行者 [User], 即 [CommandSender.user] * From b2d06aba14bed4fb731db43bf6fc9e293db72d0a Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 9 Oct 2020 21:43:42 +0800 Subject: [PATCH 10/16] Remove all `@JvmDefault` since `-Xjvm-default=all` mode --- .../mirai/console/MiraiConsoleFrontEndDescription.kt | 1 - .../net/mamoe/mirai/console/MiraiConsoleImplementation.kt | 2 -- .../net/mamoe/mirai/console/command/CommandSender.kt | 1 - .../console/command/description/CommandArgumentParser.kt | 1 - .../net/mamoe/mirai/console/data/PluginDataHolder.kt | 2 -- .../mamoe/mirai/console/plugin/PluginFileExtensions.kt | 8 -------- .../net/mamoe/mirai/console/plugin/ResourceContainer.kt | 2 -- .../kotlin/net/mamoe/mirai/console/util/MessageScope.kt | 1 - 8 files changed, 18 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleFrontEndDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleFrontEndDescription.kt index 6b7426d4d..f8155a9d1 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleFrontEndDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleFrontEndDescription.kt @@ -43,6 +43,5 @@ public interface MiraiConsoleFrontEndDescription { /** * 返回显示在 [MiraiConsole] 启动时的信息 */ - @JvmDefault public fun render(): String = "Frontend ${name}: version ${version}, provided by $vendor" } \ No newline at end of file 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 94aee7ae3..a1fd6347a 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 @@ -108,12 +108,10 @@ public interface MiraiConsoleImplementation : CoroutineScope { @JvmSynthetic - @JvmDefault public override suspend fun sendMessage(message: Message): Unit = withContext(Dispatchers.IO) { sendMessageJ(message) } @JvmSynthetic - @JvmDefault public override suspend fun sendMessage(message: String): Unit = withContext(Dispatchers.IO) { sendMessageJ(message) } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandSender.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandSender.kt index fa0aec048..08aaccac0 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandSender.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandSender.kt @@ -171,7 +171,6 @@ public interface CommandSender : CoroutineScope, Permittee { * * 对于 [MemberCommandSender], 这个函数总是发送给所在群 */ - @JvmDefault @JvmBlockingBridge public suspend fun sendMessage(message: String): MessageReceipt? diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentParser.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentParser.kt index 3d717cbb6..08f7eee05 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentParser.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentParser.kt @@ -77,7 +77,6 @@ public interface CommandArgumentParser { * @see CommandArgumentParserException */ @Throws(CommandArgumentParserException::class) - @JvmDefault public fun parse(raw: MessageContent, sender: CommandSender): T = parse(raw.content, sender) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataHolder.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataHolder.kt index 06d655913..af2bae5db 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataHolder.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginDataHolder.kt @@ -41,7 +41,6 @@ public interface PluginDataHolder { * @see Companion.newPluginDataInstance * @see KClass.createType */ - @JvmDefault public fun newPluginDataInstance(type: KType): T = newPluginDataInstanceUsingReflection(type) as T @@ -64,7 +63,6 @@ public interface AutoSavePluginDataHolder : PluginDataHolder, CoroutineScope { /** * 仅支持确切的 [PluginData] 类型 */ - @JvmDefault public override fun newPluginDataInstance(type: KType): T { val classifier = type.classifier?.cast>() require(classifier != null && classifier.java == PluginData::class.java) { diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/PluginFileExtensions.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/PluginFileExtensions.kt index 276113880..459d768b4 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/PluginFileExtensions.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/PluginFileExtensions.kt @@ -41,28 +41,24 @@ public interface PluginFileExtensions { * 从数据目录获取一个文件. * @see dataFolderPath */ - @JvmDefault public fun resolveDataFile(relativePath: String): File = dataFolderPath.resolve(relativePath).toFile() /** * 从数据目录获取一个文件. * @see dataFolderPath */ - @JvmDefault public fun resolveDataPath(relativePath: String): Path = dataFolderPath.resolve(relativePath) /** * 从数据目录获取一个文件. * @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) @@ -83,27 +79,23 @@ public interface PluginFileExtensions { * 从配置目录获取一个文件. * @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) /** * 从配置目录获取一个文件. * @see configFolderPath */ - @JvmDefault public fun resolveConfigFile(relativePath: Path): File = configFolderPath.resolve(relativePath).toFile() /** * 从配置目录获取一个文件路径. * @see configFolderPath */ - @JvmDefault public fun resolveConfigPath(relativePath: Path): Path = configFolderPath.resolve(relativePath) } \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/ResourceContainer.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/ResourceContainer.kt index e2e26cc0c..8937f4146 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/ResourceContainer.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/ResourceContainer.kt @@ -37,7 +37,6 @@ public interface ResourceContainer { * * @return 资源文件内容. 在未找到文件时返回 `null`. */ - @JvmDefault public fun getResource(path: String): String? = getResource(path, Charsets.UTF_8) /** @@ -45,7 +44,6 @@ public interface ResourceContainer { * * @return 资源文件内容. 在未找到文件时返回 `null`. */ - @JvmDefault public fun getResource(path: String, charset: Charset): String? = this.getResourceAsStream(path)?.use(InputStream::readBytes)?.let(::String) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt index 8830312bf..92a82a616 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt @@ -116,7 +116,6 @@ public interface MessageScope { /** * 立刻以此发送消息给所有在此 [MessageScope] 下的消息对象 */ - @JvmDefault @JvmBlockingBridge public suspend fun sendMessage(message: String) } From 5cdd32ab4caa84cc6fff125268751b691be54e50 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sat, 10 Oct 2020 11:36:23 +0800 Subject: [PATCH 11/16] Limit JvmPluginClassLoader resource loading region Fix #205 --- .../plugin/BuiltInJvmPluginLoaderImpl.kt | 4 +-- .../internal/plugin/JvmPluginClassLoader.kt | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginClassLoader.kt diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/BuiltInJvmPluginLoaderImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/BuiltInJvmPluginLoaderImpl.kt index ad335f874..d9acd38b8 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/BuiltInJvmPluginLoaderImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/BuiltInJvmPluginLoaderImpl.kt @@ -42,7 +42,7 @@ internal object BuiltInJvmPluginLoaderImpl : override val dataStorage: PluginDataStorage get() = MiraiConsoleImplementationBridge.dataStorageForJvmPluginLoader - internal val classLoaders: MutableList = mutableListOf() + internal val classLoaders: MutableList = mutableListOf() @Suppress("EXTENSION_SHADOWED_BY_MEMBER") // doesn't matter override fun getPluginDescription(plugin: JvmPlugin): JvmPluginDescription = plugin.description @@ -68,7 +68,7 @@ internal object BuiltInJvmPluginLoaderImpl : val filePlugins = this.filterNot { pluginFileToInstanceMap.containsKey(it) }.associateWith { - URLClassLoader(arrayOf(it.toURI().toURL()), MiraiConsole::class.java.classLoader) + JvmPluginClassLoader(it, MiraiConsole::class.java.classLoader) }.onEach { (_, classLoader) -> classLoaders.add(classLoader) }.asSequence().findAllInstances().onEach { diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginClassLoader.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginClassLoader.kt new file mode 100644 index 000000000..1787c3809 --- /dev/null +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginClassLoader.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2019-2020 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + * + */ + +package net.mamoe.mirai.console.internal.plugin + +import java.io.File +import java.net.URL +import java.net.URLClassLoader +import java.util.* + +internal class JvmPluginClassLoader( + file: File, + parent: ClassLoader?, +) : URLClassLoader(arrayOf(file.toURI().toURL()), parent) { + //// 只允许插件 getResource 时获取插件自身资源, #205 + override fun getResources(name: String?): Enumeration = findResources(name) + override fun getResource(name: String?): URL? = findResource(name) + // getResourceAsStream 在 URLClassLoader 中通过 getResource 确定资源 + // 因此无需 override getResourceAsStream +} From 1935352ae6f0894850fbb986279b28796a9c92bd Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 15 Oct 2020 07:07:42 +0800 Subject: [PATCH 12/16] Update ConfiguringProjects.md --- docs/ConfiguringProjects.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/ConfiguringProjects.md b/docs/ConfiguringProjects.md index 3fa2db93f..6831ff24d 100644 --- a/docs/ConfiguringProjects.md +++ b/docs/ConfiguringProjects.md @@ -28,6 +28,8 @@ console 由后端和前端一起工作. 使用时必须选择一个前端. ## 配置项目 +请选择以下三种方法之一。 + ### 使用模板项目 Mirai 鼓励插件开发者将自己的作品开源,并为此提供了模板项目。 @@ -77,4 +79,4 @@ dependencies { ``` 之后还需要配置 Kotlin `jvm-default` 编译参数,Kotlin 和 Java 的编译目标等。 -在打包插件时必须将依赖一并打包进插件 JAR,且排除 `mirai-core`,`mirai-console` 和它们的间接依赖,否则插件不会被加载。 \ No newline at end of file +在打包插件时必须将依赖一并打包进插件 JAR,且排除 `mirai-core`,`mirai-console` 和它们的间接依赖,否则插件不会被加载。 From 521f92892660e7f53ec6933d130edeca2169657e Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Thu, 15 Oct 2020 18:16:15 +0800 Subject: [PATCH 13/16] fix #206 --- .../console/internal/permission/parseFromStringImpl.kt | 1 + .../net/mamoe/mirai/console/permission/PermitteeId.kt | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/permission/parseFromStringImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/permission/parseFromStringImpl.kt index 71a055ade..343832ab6 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/permission/parseFromStringImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/permission/parseFromStringImpl.kt @@ -16,6 +16,7 @@ import net.mamoe.mirai.console.permission.AbstractPermitteeId.* internal fun parseFromStringImpl(string: String): AbstractPermitteeId { val str = string.trim { it.isWhitespace() }.toLowerCase() + if (str == "*") return AnyContact if (str == "console") return Console if (str.isNotEmpty()) { when (str[0]) { diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermitteeId.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermitteeId.kt index ec46d5da7..3379e3b6d 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermitteeId.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermitteeId.kt @@ -266,13 +266,13 @@ public sealed class AbstractPermitteeId( /** * 表示唯一的一个好友 * - * - **直接父标识符**: [ExactUser] + * - **直接父标识符**: [ExactUser], [AnyFriend] * - **间接父标识符**: [AnyUser], [AnyContact] * - 字符串表示: "f$id" */ public data class ExactFriend( public val id: Long, - ) : AbstractPermitteeId(ExactUser(id)) { + ) : AbstractPermitteeId(ExactUser(id), AnyFriend) { override fun asString(): String = "f$id" } @@ -304,7 +304,7 @@ public sealed class AbstractPermitteeId( * 表示唯一的一个 *在临时会话发送消息的* [群成员][Member] * * - **直接父标识符**: [ExactMember] - * - **间接父标识符**: [AnyUser], [AnyMember], [ExactUser], [AnyContact] + * - **间接父标识符**: [AnyUser], [AnyMember], [ExactUser], [AnyContact], [AnyMemberFromAnyGroup] * - 字符串表示: "t$groupId.$memberId" */ public data class ExactTemp( From 7cb6ee1e189b4de82c94545362ef7cfaa22d96c7 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Fri, 16 Oct 2020 18:09:34 +0800 Subject: [PATCH 14/16] Keep permissionName intact --- .../net/mamoe/mirai/console/permission/PermissionService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt index 1a12b8af1..0a6c39f89 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt @@ -155,7 +155,7 @@ public interface PermissionService

    { reason: PluginPermissionIdRequestType ) = PermissionId( plugin.name.toLowerCase().replace(' ', '.'), - permissionName.toLowerCase().replace(' ', '.') + permissionName ) public fun PermissionId.findCorrespondingPermission(): Permission? = INSTANCE[this] @@ -226,4 +226,4 @@ public interface PermissionService

    { return p.testPermission(permissible) } } -} \ No newline at end of file +} From e31174a2b72b3c272d7322d0758c9fedcaa59793 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Fri, 16 Oct 2020 18:13:56 +0800 Subject: [PATCH 15/16] Keep permissionName intact --- .../net/mamoe/mirai/console/permission/PermissionService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt index 0a6c39f89..32e3d57fd 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt @@ -155,7 +155,7 @@ public interface PermissionService

    { reason: PluginPermissionIdRequestType ) = PermissionId( plugin.name.toLowerCase().replace(' ', '.'), - permissionName + permissionName.toLowerCase() ) public fun PermissionId.findCorrespondingPermission(): Permission? = INSTANCE[this] From 6bb0241eeffadbbb8ab5ae4488a5fb7ecec8e9af Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Fri, 16 Oct 2020 18:20:30 +0800 Subject: [PATCH 16/16] Fix Plugin.permissionId --- .../net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt index 9b64d84f9..fb1f1849f 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/AbstractJvmPlugin.kt @@ -39,7 +39,7 @@ public abstract class AbstractJvmPlugin @JvmOverloads constructor( public final override val loader: JvmPluginLoader get() = super.loader public final override fun permissionId(name: String): PermissionId = - PermissionService.INSTANCE.allocatePermissionIdForPlugin(this, "*", PermissionService.PluginPermissionIdRequestType.PERMISSION_ID) + PermissionService.INSTANCE.allocatePermissionIdForPlugin(this, name, PermissionService.PluginPermissionIdRequestType.PERMISSION_ID) /** * 重载 [PluginData] @@ -75,4 +75,4 @@ public inline fun AbstractJvmPlugin.reloadPluginData(instance: PluginData): Unit * @see AbstractJvmPlugin.reload */ @JvmSynthetic -public inline fun AbstractJvmPlugin.reloadPluginConfig(instance: PluginConfig): Unit = this.run { instance.reload() } \ No newline at end of file +public inline fun AbstractJvmPlugin.reloadPluginConfig(instance: PluginConfig): Unit = this.run { instance.reload() }