mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Allow overriding MiraiConsole impl when stopped
This commit is contained in:
parent
c3fbff1807
commit
39f0eeb508
@ -265,7 +265,12 @@ public interface MiraiConsoleImplementation : CoroutineScope {
|
|||||||
@ConsoleFrontEndImplementation
|
@ConsoleFrontEndImplementation
|
||||||
@Throws(MalformedMiraiConsoleImplementationError::class)
|
@Throws(MalformedMiraiConsoleImplementationError::class)
|
||||||
public fun MiraiConsoleImplementation.start(): Unit = initLock.withLock {
|
public fun MiraiConsoleImplementation.start(): Unit = initLock.withLock {
|
||||||
if (::instance.isInitialized) error("Mirai Console is already initialized.")
|
if (::instance.isInitialized && instance.isActive) {
|
||||||
|
error(
|
||||||
|
"Mirai Console is already initialized and is currently running. " +
|
||||||
|
"Run MiraiConsole.cancel to kill old instance before starting another instance."
|
||||||
|
)
|
||||||
|
}
|
||||||
this@Companion.instance = this
|
this@Companion.instance = this
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
MiraiConsoleImplementationBridge.doStart()
|
MiraiConsoleImplementationBridge.doStart()
|
||||||
|
Loading…
Reference in New Issue
Block a user