mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-26 08:00:11 +08:00
Merge pull request #42 from Sincky/master
fix class init issues and fix reload exception
This commit is contained in:
commit
604b944e5d
@ -17,6 +17,7 @@ import net.mamoe.mirai.console.command.Command
|
|||||||
import net.mamoe.mirai.console.command.CommandManager
|
import net.mamoe.mirai.console.command.CommandManager
|
||||||
import net.mamoe.mirai.console.command.CommandSender
|
import net.mamoe.mirai.console.command.CommandSender
|
||||||
import net.mamoe.mirai.console.encodeToString
|
import net.mamoe.mirai.console.encodeToString
|
||||||
|
import net.mamoe.mirai.utils.LockFreeLinkedList
|
||||||
import net.mamoe.mirai.utils.SimpleLogger
|
import net.mamoe.mirai.utils.SimpleLogger
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
@ -58,7 +59,7 @@ object PluginManager {
|
|||||||
* 他的优先级取决于依赖,
|
* 他的优先级取决于依赖,
|
||||||
* 在这个队列中, 被依赖的插件会在依赖的插件之前
|
* 在这个队列中, 被依赖的插件会在依赖的插件之前
|
||||||
*/
|
*/
|
||||||
private val pluginsSequence: MutableList<PluginBase> = mutableListOf()
|
private val pluginsSequence: LockFreeLinkedList<PluginBase> = LockFreeLinkedList()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,7 +231,7 @@ object PluginManager {
|
|||||||
nameToPluginBaseMap[description.name] = plugin
|
nameToPluginBaseMap[description.name] = plugin
|
||||||
pluginDescriptions[description.name] = description
|
pluginDescriptions[description.name] = description
|
||||||
plugin.pluginName = description.name
|
plugin.pluginName = description.name
|
||||||
pluginsSequence.add(plugin)//按照实际加载顺序加入队列
|
pluginsSequence.addLast(plugin)//按照实际加载顺序加入队列
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ internal class PluginsLoader(private val parentClassLoader: ClassLoader) {
|
|||||||
if(!pluginLoaders.containsKey(pluginName)){
|
if(!pluginLoaders.containsKey(pluginName)){
|
||||||
pluginLoaders[pluginName] = PluginClassLoader(pluginName,jarFile, this, parentClassLoader)
|
pluginLoaders[pluginName] = PluginClassLoader(pluginName,jarFile, this, parentClassLoader)
|
||||||
}
|
}
|
||||||
return Class.forName(mainClass,true,pluginLoaders[pluginName])
|
return pluginLoaders[pluginName]!!.loadClass(mainClass)
|
||||||
}catch (e : ClassNotFoundException){
|
}catch (e : ClassNotFoundException){
|
||||||
throw ClassNotFoundException("PluginsClassLoader(${pluginName}) can't load this pluginMainClass:${mainClass}",e)
|
throw ClassNotFoundException("PluginsClassLoader(${pluginName}) can't load this pluginMainClass:${mainClass}",e)
|
||||||
}catch (e : Throwable){
|
}catch (e : Throwable){
|
Loading…
Reference in New Issue
Block a user