mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-31 19:40:24 +08:00
Rename BuiltInExtensionSelector
to SingletonExtensionSelectorImpl
This commit is contained in:
parent
1b0f30c4bf
commit
1cde9029b7
@ -14,7 +14,7 @@ import net.mamoe.mirai.console.extension.AbstractExtensionPoint
|
|||||||
import net.mamoe.mirai.console.extension.Extension
|
import net.mamoe.mirai.console.extension.Extension
|
||||||
import net.mamoe.mirai.console.extension.FunctionExtension
|
import net.mamoe.mirai.console.extension.FunctionExtension
|
||||||
import net.mamoe.mirai.console.extension.SingletonExtension
|
import net.mamoe.mirai.console.extension.SingletonExtension
|
||||||
import net.mamoe.mirai.console.internal.extension.BuiltInSingletonExtensionSelector
|
import net.mamoe.mirai.console.internal.extension.SingletonExtensionSelectorImpl
|
||||||
import net.mamoe.mirai.console.internal.extension.ExtensionRegistry
|
import net.mamoe.mirai.console.internal.extension.ExtensionRegistry
|
||||||
import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
|
import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
|
||||||
import net.mamoe.mirai.console.plugin.Plugin
|
import net.mamoe.mirai.console.plugin.Plugin
|
||||||
@ -55,7 +55,7 @@ public interface SingletonExtensionSelector : FunctionExtension {
|
|||||||
check(instanceField == null) { "Internal error: reinitialize SingletonExtensionSelector" }
|
check(instanceField == null) { "Internal error: reinitialize SingletonExtensionSelector" }
|
||||||
val instances = GlobalComponentStorage.run { SingletonExtensionSelector.getExtensions() }
|
val instances = GlobalComponentStorage.run { SingletonExtensionSelector.getExtensions() }
|
||||||
instanceField = when {
|
instanceField = when {
|
||||||
instances.isEmpty() -> BuiltInSingletonExtensionSelector
|
instances.isEmpty() -> SingletonExtensionSelectorImpl
|
||||||
instances.size == 1 -> {
|
instances.size == 1 -> {
|
||||||
instances.single().also { (plugin, ext) ->
|
instances.single().also { (plugin, ext) ->
|
||||||
MiraiConsole.mainLogger.info { "Loaded SingletonExtensionSelector: $ext from ${plugin?.name ?: "<builtin>"}" }
|
MiraiConsole.mainLogger.info { "Loaded SingletonExtensionSelector: $ext from ${plugin?.name ?: "<builtin>"}" }
|
||||||
|
@ -32,7 +32,7 @@ import net.mamoe.mirai.console.internal.data.builtins.AutoLoginConfig.Account.Co
|
|||||||
import net.mamoe.mirai.console.internal.data.builtins.AutoLoginConfig.Account.PasswordKind.MD5
|
import net.mamoe.mirai.console.internal.data.builtins.AutoLoginConfig.Account.PasswordKind.MD5
|
||||||
import net.mamoe.mirai.console.internal.data.builtins.AutoLoginConfig.Account.PasswordKind.PLAIN
|
import net.mamoe.mirai.console.internal.data.builtins.AutoLoginConfig.Account.PasswordKind.PLAIN
|
||||||
import net.mamoe.mirai.console.internal.data.builtins.LoggerConfig
|
import net.mamoe.mirai.console.internal.data.builtins.LoggerConfig
|
||||||
import net.mamoe.mirai.console.internal.extension.BuiltInSingletonExtensionSelector
|
import net.mamoe.mirai.console.internal.extension.SingletonExtensionSelectorImpl
|
||||||
import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
|
import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
|
||||||
import net.mamoe.mirai.console.internal.logging.LoggerControllerImpl
|
import net.mamoe.mirai.console.internal.logging.LoggerControllerImpl
|
||||||
import net.mamoe.mirai.console.internal.logging.MiraiConsoleLogger
|
import net.mamoe.mirai.console.internal.logging.MiraiConsoleLogger
|
||||||
@ -164,7 +164,7 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope,
|
|||||||
phase("load SingletonExtensionSelector") {
|
phase("load SingletonExtensionSelector") {
|
||||||
SingletonExtensionSelector.init()
|
SingletonExtensionSelector.init()
|
||||||
val instance = SingletonExtensionSelector.instance
|
val instance = SingletonExtensionSelector.instance
|
||||||
if (instance is BuiltInSingletonExtensionSelector) {
|
if (instance is SingletonExtensionSelectorImpl) {
|
||||||
consoleDataScope.addAndReloadConfig(instance.config)
|
consoleDataScope.addAndReloadConfig(instance.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import net.mamoe.mirai.console.util.ConsoleInput
|
|||||||
import net.mamoe.mirai.utils.info
|
import net.mamoe.mirai.utils.info
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
internal object BuiltInSingletonExtensionSelector : SingletonExtensionSelector {
|
internal object SingletonExtensionSelectorImpl : SingletonExtensionSelector {
|
||||||
|
|
||||||
internal val config: SaveData = SaveData()
|
internal val config: SaveData = SaveData()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user