Fix Plugin.description in PluginManager

This commit is contained in:
Him188 2020-08-27 21:04:25 +08:00
parent 8a3b0046f9
commit b5ab460bf8

View File

@ -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<PluginLoader<Plugin, PluginDescription>>()
?.getDescription(this)
?: error("Plugin is unloaded")
override fun PluginLoader<*, *>.register(): Boolean = loadersLock.withLock {
if (_pluginLoaders.any { it::class == this::class }) {
return false