From b5ab460bf8d30f73067bbd4cec12bc1144f31ecc Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 27 Aug 2020 21:04:25 +0800 Subject: [PATCH] Fix Plugin.description in PluginManager --- .../mamoe/mirai/console/internal/plugin/PluginManagerImpl.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/PluginManagerImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/PluginManagerImpl.kt index 828675db7..c28349223 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/PluginManagerImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/PluginManagerImpl.kt @@ -52,11 +52,14 @@ internal object PluginManagerImpl : PluginManager, CoroutineScope by MiraiConsol get() = _pluginLoaders.toList() override val Plugin.description: PluginDescription - get() = resolvedPlugins.firstOrNull { it == this } + get() = if (this is JvmPlugin) { + this.safeLoader.getDescription(this) + } else resolvedPlugins.firstOrNull { it == this } ?.loader?.cast>() ?.getDescription(this) ?: error("Plugin is unloaded") + override fun PluginLoader<*, *>.register(): Boolean = loadersLock.withLock { if (_pluginLoaders.any { it::class == this::class }) { return false