From 8a3b0046f967a8bb7d2c00175875a515bec58824 Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 27 Aug 2020 21:04:03 +0800 Subject: [PATCH] Fix PluginLoader<*, *>.register --- .../mirai/console/internal/plugin/PluginManagerImpl.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 c429959cc..828675db7 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 @@ -12,20 +12,23 @@ package net.mamoe.mirai.console.internal.plugin import kotlinx.atomicfu.locks.withLock +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import net.mamoe.mirai.console.MiraiConsole import net.mamoe.mirai.console.internal.data.cast import net.mamoe.mirai.console.internal.data.mkdir +import net.mamoe.mirai.console.internal.util.childScope import net.mamoe.mirai.console.plugin.* 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 net.mamoe.mirai.utils.info import java.io.File import java.nio.file.Path import java.util.concurrent.locks.ReentrantLock -internal object PluginManagerImpl : PluginManager { +internal object PluginManagerImpl : PluginManager, CoroutineScope by MiraiConsole.childScope() { override val pluginsPath: Path = MiraiConsole.rootPath.resolve("plugins").apply { mkdir() } override val pluginsFolder: File = pluginsPath.toFile() @@ -55,7 +58,7 @@ internal object PluginManagerImpl : PluginManager { ?: error("Plugin is unloaded") override fun PluginLoader<*, *>.register(): Boolean = loadersLock.withLock { - if (_pluginLoaders.any { it::class == this }) { + if (_pluginLoaders.any { it::class == this::class }) { return false } _pluginLoaders.add(this)