mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-11 02:50:15 +08:00
Cleanup
This commit is contained in:
parent
98224cfe5e
commit
d496df3deb
@ -27,18 +27,9 @@ internal object CommandManagerImpl : CommandManager, CoroutineScope by Coroutine
|
|||||||
@JvmField
|
@JvmField
|
||||||
internal val registeredCommands: MutableList<Command> = mutableListOf()
|
internal val registeredCommands: MutableList<Command> = mutableListOf()
|
||||||
|
|
||||||
/**
|
|
||||||
* 全部注册的指令
|
|
||||||
* /mute -> MuteCommand
|
|
||||||
* /jinyan -> MuteCommand
|
|
||||||
*/
|
|
||||||
@JvmField
|
@JvmField
|
||||||
internal val requiredPrefixCommandMap: MutableMap<String, Command> = mutableMapOf()
|
internal val requiredPrefixCommandMap: MutableMap<String, Command> = mutableMapOf()
|
||||||
|
|
||||||
/**
|
|
||||||
* Command name of commands that are prefix optional
|
|
||||||
* mute -> MuteCommand
|
|
||||||
*/
|
|
||||||
@JvmField
|
@JvmField
|
||||||
internal val optionalPrefixCommandMap: MutableMap<String, Command> = mutableMapOf()
|
internal val optionalPrefixCommandMap: MutableMap<String, Command> = mutableMapOf()
|
||||||
|
|
||||||
@ -57,8 +48,7 @@ internal object CommandManagerImpl : CommandManager, CoroutineScope by Coroutine
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal val commandListener: Listener<MessageEvent> by lazy {
|
internal val commandListener: Listener<MessageEvent> by lazy {
|
||||||
@Suppress("RemoveExplicitTypeArguments")
|
subscribeAlways(
|
||||||
subscribeAlways<MessageEvent>(
|
|
||||||
concurrency = Listener.ConcurrencyKind.CONCURRENT,
|
concurrency = Listener.ConcurrencyKind.CONCURRENT,
|
||||||
priority = Listener.EventPriority.HIGH
|
priority = Listener.EventPriority.HIGH
|
||||||
) {
|
) {
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package net.mamoe.mirai.console.internal.data
|
package net.mamoe.mirai.console.internal.data
|
||||||
|
|
||||||
import kotlinx.atomicfu.atomic
|
import kotlinx.atomicfu.atomic
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import net.mamoe.mirai.console.data.*
|
import net.mamoe.mirai.console.data.*
|
||||||
import net.mamoe.mirai.console.internal.plugin.updateWhen
|
import net.mamoe.mirai.console.internal.plugin.updateWhen
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
||||||
@ -35,8 +38,7 @@ internal open class AutoSavePluginData(
|
|||||||
internal var currentFirstStartTime = atomic(0L)
|
internal var currentFirstStartTime = atomic(0L)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@OptIn(InternalCoroutinesApi::class)
|
owner.coroutineContext[Job]?.invokeOnCompletion { doSave() }
|
||||||
owner.coroutineContext[Job]?.invokeOnCompletion(true) { doSave() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val updaterBlock: suspend CoroutineScope.() -> Unit = {
|
private val updaterBlock: suspend CoroutineScope.() -> Unit = {
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
package net.mamoe.mirai.console.internal.plugin
|
package net.mamoe.mirai.console.internal.plugin
|
||||||
|
|
||||||
import kotlinx.atomicfu.locks.withLock
|
import kotlinx.atomicfu.locks.withLock
|
||||||
import kotlinx.coroutines.InternalCoroutinesApi
|
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import net.mamoe.mirai.console.MiraiConsole
|
import net.mamoe.mirai.console.MiraiConsole
|
||||||
import net.mamoe.mirai.console.internal.data.cast
|
import net.mamoe.mirai.console.internal.data.cast
|
||||||
@ -58,8 +57,7 @@ internal object PluginManagerImpl : PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@OptIn(InternalCoroutinesApi::class)
|
MiraiConsole.coroutineContext[Job]!!.invokeOnCompletion {
|
||||||
MiraiConsole.coroutineContext[Job]!!.invokeOnCompletion(true) {
|
|
||||||
plugins.forEach(Plugin::disable)
|
plugins.forEach(Plugin::disable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user