mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Fix loadFromResource
This commit is contained in:
parent
d1f431e98e
commit
cf08c2b767
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.console.internal.util
|
package net.mamoe.mirai.console.internal.util
|
||||||
|
|
||||||
|
import net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl
|
||||||
|
|
||||||
internal inline fun <reified E : Throwable, R> runIgnoreException(block: () -> R): R? {
|
internal inline fun <reified E : Throwable, R> runIgnoreException(block: () -> R): R? {
|
||||||
try {
|
try {
|
||||||
return block()
|
return block()
|
||||||
@ -41,6 +43,7 @@ internal fun getCallerClassloader(): ClassLoader? {
|
|||||||
net.mamoe.mirai.console.TestMiraiConosleKt.main(TestMiraiConosle.kt)
|
net.mamoe.mirai.console.TestMiraiConosleKt.main(TestMiraiConosle.kt)
|
||||||
*/
|
*/
|
||||||
val traces = Thread.currentThread().stackTrace
|
val traces = Thread.currentThread().stackTrace
|
||||||
Class.forName(traces[3].className).classLoader
|
val classname = traces[3].className
|
||||||
|
BuiltInJvmPluginLoaderImpl.classLoaders.firstOrNull { it.findClass(classname, true) != null }
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
@ -67,7 +67,7 @@ public interface JvmPluginDescription : PluginDescription {
|
|||||||
* @param filename [ClassLoader.getResourceAsStream] 的参数 `name`
|
* @param filename [ClassLoader.getResourceAsStream] 的参数 `name`
|
||||||
* @param pluginClassloader 默认通过 [Thread.getStackTrace] 获取调用方 [Class] 然后获取其 [Class.getClassLoader].
|
* @param pluginClassloader 默认通过 [Thread.getStackTrace] 获取调用方 [Class] 然后获取其 [Class.getClassLoader].
|
||||||
*/
|
*/
|
||||||
@JvmOverloads
|
// @JvmOverloads // compiler error
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun loadFromResource(
|
public fun loadFromResource(
|
||||||
filename: String = "plugin.yml",
|
filename: String = "plugin.yml",
|
||||||
|
Loading…
Reference in New Issue
Block a user