mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-11 02:50:15 +08:00
parent
bde3d995be
commit
5cdd32ab4c
@ -42,7 +42,7 @@ internal object BuiltInJvmPluginLoaderImpl :
|
|||||||
override val dataStorage: PluginDataStorage
|
override val dataStorage: PluginDataStorage
|
||||||
get() = MiraiConsoleImplementationBridge.dataStorageForJvmPluginLoader
|
get() = MiraiConsoleImplementationBridge.dataStorageForJvmPluginLoader
|
||||||
|
|
||||||
internal val classLoaders: MutableList<ClassLoader> = mutableListOf()
|
internal val classLoaders: MutableList<JvmPluginClassLoader> = mutableListOf()
|
||||||
|
|
||||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // doesn't matter
|
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // doesn't matter
|
||||||
override fun getPluginDescription(plugin: JvmPlugin): JvmPluginDescription = plugin.description
|
override fun getPluginDescription(plugin: JvmPlugin): JvmPluginDescription = plugin.description
|
||||||
@ -68,7 +68,7 @@ internal object BuiltInJvmPluginLoaderImpl :
|
|||||||
val filePlugins = this.filterNot {
|
val filePlugins = this.filterNot {
|
||||||
pluginFileToInstanceMap.containsKey(it)
|
pluginFileToInstanceMap.containsKey(it)
|
||||||
}.associateWith {
|
}.associateWith {
|
||||||
URLClassLoader(arrayOf(it.toURI().toURL()), MiraiConsole::class.java.classLoader)
|
JvmPluginClassLoader(it, MiraiConsole::class.java.classLoader)
|
||||||
}.onEach { (_, classLoader) ->
|
}.onEach { (_, classLoader) ->
|
||||||
classLoaders.add(classLoader)
|
classLoaders.add(classLoader)
|
||||||
}.asSequence().findAllInstances().onEach {
|
}.asSequence().findAllInstances().onEach {
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.mamoe.mirai.console.internal.plugin
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.net.URL
|
||||||
|
import java.net.URLClassLoader
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
internal class JvmPluginClassLoader(
|
||||||
|
file: File,
|
||||||
|
parent: ClassLoader?,
|
||||||
|
) : URLClassLoader(arrayOf(file.toURI().toURL()), parent) {
|
||||||
|
//// 只允许插件 getResource 时获取插件自身资源, #205
|
||||||
|
override fun getResources(name: String?): Enumeration<URL> = findResources(name)
|
||||||
|
override fun getResource(name: String?): URL? = findResource(name)
|
||||||
|
// getResourceAsStream 在 URLClassLoader 中通过 getResource 确定资源
|
||||||
|
// 因此无需 override getResourceAsStream
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user