mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 23:50:08 +08:00
Fix IMirai
initialize; Fix #1861; Fix some error caused by d757764308
This commit is contained in:
parent
78d0cdd155
commit
cb3bba986c
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
|
||||||
*
|
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
|
||||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
|
||||||
*
|
|
||||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.mamoe.mirai
|
|
||||||
|
|
||||||
import java.util.*
|
|
||||||
import kotlin.reflect.full.companionObjectInstance
|
|
||||||
|
|
||||||
@JvmSynthetic
|
|
||||||
internal actual fun findMiraiInstance(): IMirai {
|
|
||||||
return ServiceLoader.load(IMirai::class.java).firstOrNull()
|
|
||||||
?: Class.forName("net.mamoe.mirai.internal.MiraiImpl").kotlin.companionObjectInstance as IMirai
|
|
||||||
}
|
|
@ -31,6 +31,8 @@ import net.mamoe.mirai.message.data.*
|
|||||||
import net.mamoe.mirai.message.data.Image.Key.queryUrl
|
import net.mamoe.mirai.message.data.Image.Key.queryUrl
|
||||||
import net.mamoe.mirai.message.data.MessageSource.Key.recall
|
import net.mamoe.mirai.message.data.MessageSource.Key.recall
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
|
import java.util.ServiceLoader
|
||||||
|
import kotlin.reflect.full.companionObjectInstance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [IMirai] 实例.
|
* [IMirai] 实例.
|
||||||
@ -354,4 +356,10 @@ internal object _MiraiInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
internal expect fun findMiraiInstance(): IMirai
|
internal fun findMiraiInstance(): IMirai {
|
||||||
|
ServiceLoader.load(IMirai::class.java).firstOrNull()?.let { return it }
|
||||||
|
|
||||||
|
val implClass = Class.forName("net.mamoe.mirai.internal.MiraiImpl")
|
||||||
|
(implClass.kotlin.companionObjectInstance as? IMirai)?.let { return it }
|
||||||
|
return implClass.asSubclass(IMirai::class.java).getConstructor().newInstance()
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
|
||||||
*
|
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
|
||||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
|
||||||
*
|
|
||||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.mamoe.mirai
|
|
||||||
|
|
||||||
import java.util.*
|
|
||||||
import kotlin.reflect.full.companionObjectInstance
|
|
||||||
|
|
||||||
@JvmSynthetic
|
|
||||||
internal actual fun findMiraiInstance(): IMirai {
|
|
||||||
return ServiceLoader.load(IMirai::class.java).firstOrNull()
|
|
||||||
?: Class.forName("net.mamoe.mirai.internal.MiraiImpl").kotlin.companionObjectInstance as IMirai
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user