mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-11 02:50:15 +08:00
Fix build
This commit is contained in:
parent
8ea0c538a0
commit
1cf35b8554
@ -65,28 +65,30 @@ object JarPluginLoader : AbstractFilePluginLoader<JvmPlugin, JvmPluginDescriptio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("RemoveExplicitTypeArguments") // until Kotlin 1.4 NI
|
||||||
@Throws(PluginLoadException::class)
|
@Throws(PluginLoadException::class)
|
||||||
override fun load(description: JvmPluginDescription): JvmPlugin = description.runCatching {
|
override fun load(description: JvmPluginDescription): JvmPlugin =
|
||||||
ensureActive()
|
description.runCatching<JvmPluginDescription, JvmPlugin> {
|
||||||
val main = classLoader.loadPluginMainClassByJarFile(name, mainClassName, file).kotlin.run {
|
ensureActive()
|
||||||
objectInstance
|
val main = classLoader.loadPluginMainClassByJarFile(name, mainClassName, file).kotlin.run {
|
||||||
?: kotlin.runCatching { createInstance() }.getOrNull()
|
objectInstance
|
||||||
?: (java.constructors + java.declaredConstructors)
|
?: kotlin.runCatching { createInstance() }.getOrNull()
|
||||||
.firstOrNull { it.parameterCount == 0 }
|
?: (java.constructors + java.declaredConstructors)
|
||||||
?.apply { kotlin.runCatching { isAccessible = true } }
|
.firstOrNull { it.parameterCount == 0 }
|
||||||
?.newInstance()
|
?.apply { kotlin.runCatching { isAccessible = true } }
|
||||||
} ?: error("No Kotlin object or public no-arg constructor found")
|
?.newInstance()
|
||||||
|
} ?: error("No Kotlin object or public no-arg constructor found")
|
||||||
|
|
||||||
check(main is JvmPlugin) { "The main class of Jar plugin must extend JvmPlugin, recommending JavaPlugin or KotlinPlugin" }
|
check(main is JvmPlugin) { "The main class of Jar plugin must extend JvmPlugin, recommending JavaPlugin or KotlinPlugin" }
|
||||||
|
|
||||||
if (main is JvmPluginImpl) {
|
if (main is JvmPluginImpl) {
|
||||||
main._description = description
|
main._description = description
|
||||||
main.internalOnLoad()
|
main.internalOnLoad()
|
||||||
} else main.onLoad()
|
} else main.onLoad()
|
||||||
main
|
main
|
||||||
}.getOrElse {
|
}.getOrElse<JvmPlugin, JvmPlugin> {
|
||||||
throw PluginLoadException("Exception while loading ${description.name}", it)
|
throw PluginLoadException("Exception while loading ${description.name}", it)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun enable(plugin: JvmPlugin) {
|
override fun enable(plugin: JvmPlugin) {
|
||||||
ensureActive()
|
ensureActive()
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
package net.mamoe.mirai.console.command
|
package net.mamoe.mirai.console.command
|
||||||
|
|
||||||
import net.mamoe.mirai.Bot
|
import net.mamoe.mirai.Bot
|
||||||
import net.mamoe.mirai.console.plugins.PluginBase
|
import net.mamoe.mirai.console.plugins.builtin.KotlinPlugin
|
||||||
import net.mamoe.mirai.message.data.*
|
import net.mamoe.mirai.message.data.*
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
|
||||||
val plugin: PluginBase = object : PluginBase() {
|
val plugin: KotlinPlugin = object : KotlinPlugin() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user