diff --git a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt index 8571613db..92879ab1e 100644 --- a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt +++ b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginManager.kt @@ -17,6 +17,7 @@ import net.mamoe.mirai.console.command.Command import net.mamoe.mirai.console.command.CommandManager import net.mamoe.mirai.console.command.CommandSender import net.mamoe.mirai.console.encodeToString +import net.mamoe.mirai.utils.LockFreeLinkedList import net.mamoe.mirai.utils.SimpleLogger import java.io.File import java.io.InputStream @@ -58,7 +59,7 @@ object PluginManager { * 他的优先级取决于依赖, * 在这个队列中, 被依赖的插件会在依赖的插件之前 */ - private val pluginsSequence: MutableList = mutableListOf() + private val pluginsSequence: LockFreeLinkedList = LockFreeLinkedList() /** @@ -230,7 +231,7 @@ object PluginManager { nameToPluginBaseMap[description.name] = plugin pluginDescriptions[description.name] = description plugin.pluginName = description.name - pluginsSequence.add(plugin)//按照实际加载顺序加入队列 + pluginsSequence.addLast(plugin)//按照实际加载顺序加入队列 return true } diff --git a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginsClassLoader.kt b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginsLoader.kt similarity index 98% rename from mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginsClassLoader.kt rename to mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginsLoader.kt index 3b9ae81b5..dedf7a32b 100644 --- a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginsClassLoader.kt +++ b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginsLoader.kt @@ -48,7 +48,7 @@ internal class PluginsLoader(private val parentClassLoader: ClassLoader) { if(!pluginLoaders.containsKey(pluginName)){ pluginLoaders[pluginName] = PluginClassLoader(pluginName,jarFile, this, parentClassLoader) } - return Class.forName(mainClass,true,pluginLoaders[pluginName]) + return pluginLoaders[pluginName]!!.loadClass(mainClass) }catch (e : ClassNotFoundException){ throw ClassNotFoundException("PluginsClassLoader(${pluginName}) can't load this pluginMainClass:${mainClass}",e) }catch (e : Throwable){