mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Correct class naming following Kotlin formal style
This commit is contained in:
parent
e41a2c0d09
commit
956e193d02
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION", "unused")
|
@file:Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION", "unused")
|
||||||
@file:OptIn(ConsoleInternalAPI::class)
|
@file:OptIn(ConsoleInternalApi::class)
|
||||||
|
|
||||||
package net.mamoe.mirai.console
|
package net.mamoe.mirai.console
|
||||||
|
|
||||||
@ -25,8 +25,8 @@ import net.mamoe.mirai.console.plugin.PluginLoader
|
|||||||
import net.mamoe.mirai.console.plugin.PluginManager
|
import net.mamoe.mirai.console.plugin.PluginManager
|
||||||
import net.mamoe.mirai.console.plugin.center.PluginCenter
|
import net.mamoe.mirai.console.plugin.center.PluginCenter
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JarPluginLoader
|
import net.mamoe.mirai.console.plugin.jvm.JarPluginLoader
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScopeContext
|
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScopeContext
|
||||||
import net.mamoe.mirai.utils.BotConfiguration
|
import net.mamoe.mirai.utils.BotConfiguration
|
||||||
import net.mamoe.mirai.utils.MiraiLogger
|
import net.mamoe.mirai.utils.MiraiLogger
|
||||||
@ -60,7 +60,7 @@ public interface MiraiConsole : CoroutineScope {
|
|||||||
*
|
*
|
||||||
* **注意**: 插件不应该在任何时刻使用它.
|
* **注意**: 插件不应该在任何时刻使用它.
|
||||||
*/
|
*/
|
||||||
@ConsoleInternalAPI
|
@ConsoleInternalApi
|
||||||
public val mainLogger: MiraiLogger
|
public val mainLogger: MiraiLogger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,13 +80,13 @@ public interface MiraiConsole : CoroutineScope {
|
|||||||
*/
|
*/
|
||||||
public val version: Semver
|
public val version: Semver
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public val pluginCenter: PluginCenter
|
public val pluginCenter: PluginCenter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个 logger
|
* 创建一个 logger
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun createLogger(identity: String?): MiraiLogger
|
public fun createLogger(identity: String?): MiraiLogger
|
||||||
|
|
||||||
public companion object INSTANCE : MiraiConsole by MiraiConsoleImplementationBridge {
|
public companion object INSTANCE : MiraiConsole by MiraiConsoleImplementationBridge {
|
||||||
@ -106,7 +106,7 @@ public interface MiraiConsole : CoroutineScope {
|
|||||||
* @see BotConfigurationAlterer ExtensionPoint
|
* @see BotConfigurationAlterer ExtensionPoint
|
||||||
*/
|
*/
|
||||||
// don't static
|
// don't static
|
||||||
@ConsoleExperimentalAPI("This is a low-level API and might be removed in the future.")
|
@ConsoleExperimentalApi("This is a low-level API and might be removed in the future.")
|
||||||
public fun addBot(id: Long, password: String, configuration: BotConfiguration.() -> Unit = {}): Bot =
|
public fun addBot(id: Long, password: String, configuration: BotConfiguration.() -> Unit = {}): Bot =
|
||||||
addBotImpl(id, password, configuration)
|
addBotImpl(id, password, configuration)
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ public interface MiraiConsole : CoroutineScope {
|
|||||||
* @see Bot.botInstances 获取现有 [Bot] 实例列表
|
* @see Bot.botInstances 获取现有 [Bot] 实例列表
|
||||||
* @see BotConfigurationAlterer ExtensionPoint
|
* @see BotConfigurationAlterer ExtensionPoint
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI("This is a low-level API and might be removed in the future.")
|
@ConsoleExperimentalApi("This is a low-level API and might be removed in the future.")
|
||||||
public fun addBot(id: Long, password: ByteArray, configuration: BotConfiguration.() -> Unit = {}): Bot =
|
public fun addBot(id: Long, password: ByteArray, configuration: BotConfiguration.() -> Unit = {}): Bot =
|
||||||
addBotImpl(id, password, configuration)
|
addBotImpl(id, password, configuration)
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ import net.mamoe.mirai.console.permission.PermissionService.Companion.denyPermis
|
|||||||
import net.mamoe.mirai.console.permission.PermissionService.Companion.findCorrespondingPermissionOrFail
|
import net.mamoe.mirai.console.permission.PermissionService.Companion.findCorrespondingPermissionOrFail
|
||||||
import net.mamoe.mirai.console.permission.PermissionService.Companion.getGrantedPermissions
|
import net.mamoe.mirai.console.permission.PermissionService.Companion.getGrantedPermissions
|
||||||
import net.mamoe.mirai.console.permission.PermissionService.Companion.grantPermission
|
import net.mamoe.mirai.console.permission.PermissionService.Companion.grantPermission
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
import net.mamoe.mirai.contact.*
|
import net.mamoe.mirai.contact.*
|
||||||
import net.mamoe.mirai.event.events.EventCancelledException
|
import net.mamoe.mirai.event.events.EventCancelledException
|
||||||
import net.mamoe.mirai.message.nextMessageOrNull
|
import net.mamoe.mirai.message.nextMessageOrNull
|
||||||
@ -35,7 +35,7 @@ import kotlin.concurrent.thread
|
|||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
@Suppress("EXPOSED_SUPER_INTERFACE")
|
@Suppress("EXPOSED_SUPER_INTERFACE")
|
||||||
public interface BuiltInCommand : Command, BuiltInCommandInternal
|
public interface BuiltInCommand : Command, BuiltInCommandInternal
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ internal interface BuiltInCommandInternal : Command
|
|||||||
/**
|
/**
|
||||||
* 内建指令列表
|
* 内建指令列表
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@OptIn(ExperimentalPermission::class)
|
@OptIn(ExperimentalPermission::class)
|
||||||
public object BuiltInCommands {
|
public object BuiltInCommands {
|
||||||
@ -101,7 +101,7 @@ public object BuiltInCommands {
|
|||||||
},
|
},
|
||||||
onFailure = {
|
onFailure = {
|
||||||
if (it is CancellationException) return@fold
|
if (it is CancellationException) return@fold
|
||||||
@OptIn(ConsoleInternalAPI::class)
|
@OptIn(ConsoleInternalApi::class)
|
||||||
MiraiConsole.mainLogger.error("Exception in stop", it)
|
MiraiConsole.mainLogger.error("Exception in stop", it)
|
||||||
ignoreException<EventCancelledException> {
|
ignoreException<EventCancelledException> {
|
||||||
sendMessage(
|
sendMessage(
|
||||||
|
@ -36,7 +36,7 @@ import net.mamoe.mirai.console.permission.AbstractPermissibleIdentifier
|
|||||||
import net.mamoe.mirai.console.permission.ExperimentalPermission
|
import net.mamoe.mirai.console.permission.ExperimentalPermission
|
||||||
import net.mamoe.mirai.console.permission.Permissible
|
import net.mamoe.mirai.console.permission.Permissible
|
||||||
import net.mamoe.mirai.console.permission.PermissibleIdentifier
|
import net.mamoe.mirai.console.permission.PermissibleIdentifier
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScope
|
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScope
|
||||||
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScopeContext
|
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScopeContext
|
||||||
import net.mamoe.mirai.console.util.MessageScope
|
import net.mamoe.mirai.console.util.MessageScope
|
||||||
@ -180,7 +180,7 @@ public interface CommandSender : CoroutineScope, Permissible {
|
|||||||
@JvmBlockingBridge
|
@JvmBlockingBridge
|
||||||
public suspend fun sendMessage(message: String): MessageReceipt<Contact>?
|
public suspend fun sendMessage(message: String): MessageReceipt<Contact>?
|
||||||
|
|
||||||
@ConsoleExperimentalAPI("This is unstable and might get changed")
|
@ConsoleExperimentalApi("This is unstable and might get changed")
|
||||||
public suspend fun catchExecutionException(e: Throwable)
|
public suspend fun catchExecutionException(e: Throwable)
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
@ -282,7 +282,7 @@ public sealed class AbstractCommandSender : CommandSender, CoroutineScope {
|
|||||||
public abstract override val user: User?
|
public abstract override val user: User?
|
||||||
public abstract override fun toString(): String
|
public abstract override fun toString(): String
|
||||||
|
|
||||||
@ConsoleExperimentalAPI("This is unstable and might get changed")
|
@ConsoleExperimentalApi("This is unstable and might get changed")
|
||||||
override suspend fun catchExecutionException(e: Throwable) {
|
override suspend fun catchExecutionException(e: Throwable) {
|
||||||
if (this is CommandSenderOnMessage<*>) {
|
if (this is CommandSenderOnMessage<*>) {
|
||||||
val cause = e.rootCauseOrSelf
|
val cause = e.rootCauseOrSelf
|
||||||
@ -469,7 +469,7 @@ public inline fun <R> CommandSender.fold(
|
|||||||
* @return [inGroup] 或 [inPrivate] 执行结果.
|
* @return [inGroup] 或 [inPrivate] 执行结果.
|
||||||
*/
|
*/
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public inline fun <R> UserCommandSender.foldContext(
|
public inline fun <R> UserCommandSender.foldContext(
|
||||||
inGroup: MemberCommandSender.() -> R,
|
inGroup: MemberCommandSender.() -> R,
|
||||||
inPrivate: UserCommandSender.() -> R,
|
inPrivate: UserCommandSender.() -> R,
|
||||||
|
@ -22,7 +22,7 @@ import net.mamoe.mirai.console.internal.command.AbstractReflectionCommand
|
|||||||
import net.mamoe.mirai.console.internal.command.CompositeCommandSubCommandAnnotationResolver
|
import net.mamoe.mirai.console.internal.command.CompositeCommandSubCommandAnnotationResolver
|
||||||
import net.mamoe.mirai.console.permission.ExperimentalPermission
|
import net.mamoe.mirai.console.permission.ExperimentalPermission
|
||||||
import net.mamoe.mirai.console.permission.Permission
|
import net.mamoe.mirai.console.permission.Permission
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.message.data.MessageChain
|
import net.mamoe.mirai.message.data.MessageChain
|
||||||
import kotlin.annotation.AnnotationRetention.RUNTIME
|
import kotlin.annotation.AnnotationRetention.RUNTIME
|
||||||
import kotlin.annotation.AnnotationTarget.FUNCTION
|
import kotlin.annotation.AnnotationTarget.FUNCTION
|
||||||
@ -81,7 +81,7 @@ import kotlin.annotation.AnnotationTarget.FUNCTION
|
|||||||
*
|
*
|
||||||
* @see buildCommandArgumentContext
|
* @see buildCommandArgumentContext
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public abstract class CompositeCommand @OptIn(ExperimentalPermission::class) constructor(
|
public abstract class CompositeCommand @OptIn(ExperimentalPermission::class) constructor(
|
||||||
owner: CommandOwner,
|
owner: CommandOwner,
|
||||||
vararg names: String,
|
vararg names: String,
|
||||||
|
@ -16,7 +16,7 @@ import net.mamoe.mirai.console.command.CommandSender
|
|||||||
import net.mamoe.mirai.console.command.CompositeCommand
|
import net.mamoe.mirai.console.command.CompositeCommand
|
||||||
import net.mamoe.mirai.console.command.SimpleCommand
|
import net.mamoe.mirai.console.command.SimpleCommand
|
||||||
import net.mamoe.mirai.console.command.description.CommandArgumentContext.ParserPair
|
import net.mamoe.mirai.console.command.description.CommandArgumentContext.ParserPair
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.contact.*
|
import net.mamoe.mirai.contact.*
|
||||||
import kotlin.internal.LowPriorityInOverloadResolution
|
import kotlin.internal.LowPriorityInOverloadResolution
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
@ -238,7 +238,7 @@ public class CommandArgumentContextBuilder : MutableList<ParserPair<*>> by mutab
|
|||||||
/**
|
/**
|
||||||
* 添加一个指令解析器
|
* 添加一个指令解析器
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
public inline infix fun <reified T : Any> add(
|
public inline infix fun <reified T : Any> add(
|
||||||
crossinline parser: CommandArgumentParser<*>.(s: String) -> T
|
crossinline parser: CommandArgumentParser<*>.(s: String) -> T
|
||||||
@ -249,7 +249,7 @@ public class CommandArgumentContextBuilder : MutableList<ParserPair<*>> by mutab
|
|||||||
/**
|
/**
|
||||||
* 添加一个指令解析器
|
* 添加一个指令解析器
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
@LowPriorityInOverloadResolution
|
@LowPriorityInOverloadResolution
|
||||||
public inline infix fun <reified T : Any> add(
|
public inline infix fun <reified T : Any> add(
|
||||||
|
@ -16,7 +16,7 @@ import net.mamoe.mirai.console.command.CompositeCommand
|
|||||||
import net.mamoe.mirai.console.command.description.buildCommandArgumentContext
|
import net.mamoe.mirai.console.command.description.buildCommandArgumentContext
|
||||||
import net.mamoe.mirai.console.permission.ExperimentalPermission
|
import net.mamoe.mirai.console.permission.ExperimentalPermission
|
||||||
import net.mamoe.mirai.console.permission.Permission
|
import net.mamoe.mirai.console.permission.Permission
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复合指令. 指令注册时候会通过反射构造指令解析器.
|
* 复合指令. 指令注册时候会通过反射构造指令解析器.
|
||||||
@ -68,7 +68,7 @@ import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
|||||||
*
|
*
|
||||||
* @see buildCommandArgumentContext
|
* @see buildCommandArgumentContext
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public abstract class JCompositeCommand @OptIn(ExperimentalPermission::class)
|
public abstract class JCompositeCommand @OptIn(ExperimentalPermission::class)
|
||||||
@JvmOverloads constructor(
|
@JvmOverloads constructor(
|
||||||
owner: CommandOwner,
|
owner: CommandOwner,
|
||||||
|
@ -16,7 +16,7 @@ import kotlinx.coroutines.*
|
|||||||
import net.mamoe.mirai.console.MiraiConsole
|
import net.mamoe.mirai.console.MiraiConsole
|
||||||
import net.mamoe.mirai.console.internal.command.qualifiedNameOrTip
|
import net.mamoe.mirai.console.internal.command.qualifiedNameOrTip
|
||||||
import net.mamoe.mirai.console.internal.plugin.updateWhen
|
import net.mamoe.mirai.console.internal.plugin.updateWhen
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +38,7 @@ public open class AutoSavePluginData private constructor(
|
|||||||
public constructor() : this(null)
|
public constructor() : this(null)
|
||||||
|
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
override fun onInit(owner: PluginDataHolder, storage: PluginDataStorage) {
|
override fun onInit(owner: PluginDataHolder, storage: PluginDataStorage) {
|
||||||
check(owner is AutoSavePluginDataHolder) { "owner must be AutoSavePluginDataHolder for AutoSavePluginData" }
|
check(owner is AutoSavePluginDataHolder) { "owner must be AutoSavePluginDataHolder for AutoSavePluginData" }
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ public open class AutoSavePluginData private constructor(
|
|||||||
/**
|
/**
|
||||||
* @return `true` 时, 一段时间后, 即使无属性改变, 也会进行保存.
|
* @return `true` 时, 一段时间后, 即使无属性改变, 也会进行保存.
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
protected open fun shouldPerformAutoSaveWheneverChanged(): Boolean {
|
protected open fun shouldPerformAutoSaveWheneverChanged(): Boolean {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package net.mamoe.mirai.console.data
|
|||||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可以持有相关 [AutoSavePluginData] 的对象.
|
* 可以持有相关 [AutoSavePluginData] 的对象.
|
||||||
@ -13,7 +13,7 @@ import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
|||||||
*
|
*
|
||||||
* @see net.mamoe.mirai.console.plugin.jvm.JvmPlugin
|
* @see net.mamoe.mirai.console.plugin.jvm.JvmPlugin
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface AutoSavePluginDataHolder : PluginDataHolder, CoroutineScope {
|
public interface AutoSavePluginDataHolder : PluginDataHolder, CoroutineScope {
|
||||||
/**
|
/**
|
||||||
* [AutoSavePluginData] 每次自动保存时间间隔
|
* [AutoSavePluginData] 每次自动保存时间间隔
|
||||||
@ -27,6 +27,6 @@ public interface AutoSavePluginDataHolder : PluginDataHolder, CoroutineScope {
|
|||||||
* @see LongRange Java 用户使用 [LongRange] 的构造器创建
|
* @see LongRange Java 用户使用 [LongRange] 的构造器创建
|
||||||
* @see Long.rangeTo Kotlin 用户使用 [Long.rangeTo] 创建, 如 `3000..50000`
|
* @see Long.rangeTo Kotlin 用户使用 [Long.rangeTo] 创建, 如 `3000..50000`
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public val autoSaveIntervalMillis: LongRange
|
public val autoSaveIntervalMillis: LongRange
|
||||||
}
|
}
|
@ -21,8 +21,7 @@ import kotlinx.serialization.KSerializer
|
|||||||
import net.mamoe.mirai.console.data.java.JAutoSavePluginData
|
import net.mamoe.mirai.console.data.java.JAutoSavePluginData
|
||||||
import net.mamoe.mirai.console.internal.data.*
|
import net.mamoe.mirai.console.internal.data.*
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin
|
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin
|
||||||
import net.mamoe.mirai.console.plugin.jvm.reloadPluginData
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
|
||||||
import kotlin.internal.LowPriorityInOverloadResolution
|
import kotlin.internal.LowPriorityInOverloadResolution
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
@ -117,7 +116,7 @@ public interface PluginData {
|
|||||||
/**
|
/**
|
||||||
* 这个 [PluginData] 保存时使用的名称. 默认通过 [ValueName] 获取, 否则使用 [类全名][KClass.qualifiedName] (即 [Class.getCanonicalName])
|
* 这个 [PluginData] 保存时使用的名称. 默认通过 [ValueName] 获取, 否则使用 [类全名][KClass.qualifiedName] (即 [Class.getCanonicalName])
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public val saveName: String
|
public val saveName: String
|
||||||
get() {
|
get() {
|
||||||
val clazz = this::class
|
val clazz = this::class
|
||||||
@ -129,7 +128,7 @@ public interface PluginData {
|
|||||||
/**
|
/**
|
||||||
* 由 [provideDelegate] 创建, 来自一个通过 `by value` 初始化的属性节点.
|
* 由 [provideDelegate] 创建, 来自一个通过 `by value` 初始化的属性节点.
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public data class ValueNode<T>(
|
public data class ValueNode<T>(
|
||||||
/**
|
/**
|
||||||
* 节点名称.
|
* 节点名称.
|
||||||
@ -191,7 +190,7 @@ public interface PluginData {
|
|||||||
/**
|
/**
|
||||||
* 当这个 [PluginData] 被放入一个 [PluginDataStorage] 时调用
|
* 当这个 [PluginData] 被放入一个 [PluginDataStorage] 时调用
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun onInit(owner: PluginDataHolder, storage: PluginDataStorage)
|
public fun onInit(owner: PluginDataHolder, storage: PluginDataStorage)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +345,6 @@ internal fun <T> PluginData.valueImpl(type: KType, classifier: KClass<*>): Seria
|
|||||||
* - 使用 [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) 的 [Serializable] 标记的类
|
* - 使用 [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) 的 [Serializable] 标记的类
|
||||||
*/
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun <T> PluginData.valueFromKType(type: KType, default: T): SerializerAwareValue<T> =
|
public fun <T> PluginData.valueFromKType(type: KType, default: T): SerializerAwareValue<T> =
|
||||||
(valueFromKTypeImpl(type) as SerializerAwareValue<Any?>).apply { this.value = default } as SerializerAwareValue<T>
|
(valueFromKTypeImpl(type) as SerializerAwareValue<Any?>).apply { this.value = default } as SerializerAwareValue<T>
|
||||||
|
@ -4,7 +4,7 @@ package net.mamoe.mirai.console.data
|
|||||||
|
|
||||||
import net.mamoe.mirai.console.data.PluginDataExtensions.withDefault
|
import net.mamoe.mirai.console.data.PluginDataExtensions.withDefault
|
||||||
import net.mamoe.mirai.console.internal.data.ShadowMap
|
import net.mamoe.mirai.console.internal.data.ShadowMap
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import kotlin.internal.LowPriorityInOverloadResolution
|
import kotlin.internal.LowPriorityInOverloadResolution
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +12,7 @@ import kotlin.internal.LowPriorityInOverloadResolution
|
|||||||
*/
|
*/
|
||||||
public object PluginDataExtensions {
|
public object PluginDataExtensions {
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public open class NotNullMap<K, V> internal constructor(
|
public open class NotNullMap<K, V> internal constructor(
|
||||||
private val delegate: Map<K, V>
|
private val delegate: Map<K, V>
|
||||||
) : Map<K, V> by delegate {
|
) : Map<K, V> by delegate {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.console.data
|
package net.mamoe.mirai.console.data
|
||||||
|
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可以持有相关 [PluginData] 实例的对象, 作为 [PluginData] 实例的拥有者.
|
* 可以持有相关 [PluginData] 实例的对象, 作为 [PluginData] 实例的拥有者.
|
||||||
@ -21,12 +21,12 @@ import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
|||||||
*
|
*
|
||||||
* @see AutoSavePluginDataHolder 支持自动保存
|
* @see AutoSavePluginDataHolder 支持自动保存
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PluginDataHolder {
|
public interface PluginDataHolder {
|
||||||
/**
|
/**
|
||||||
* 保存时使用的分类名
|
* 保存时使用的分类名
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public val dataHolderName: String
|
public val dataHolderName: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import net.mamoe.mirai.console.internal.data.MemoryPluginDataStorageImpl
|
|||||||
import net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl
|
import net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JarPluginLoader
|
import net.mamoe.mirai.console.plugin.jvm.JarPluginLoader
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin
|
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
@ -33,12 +33,12 @@ import java.nio.file.Path
|
|||||||
* @see PluginDataHolder
|
* @see PluginDataHolder
|
||||||
* @see JarPluginLoader.dataStorage
|
* @see JarPluginLoader.dataStorage
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PluginDataStorage {
|
public interface PluginDataStorage {
|
||||||
/**
|
/**
|
||||||
* 读取一个实例. 并为 [instance] [设置 [PluginDataStorage]][PluginData.onInit]
|
* 读取一个实例. 并为 [instance] [设置 [PluginDataStorage]][PluginData.onInit]
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun load(holder: PluginDataHolder, instance: PluginData)
|
public fun load(holder: PluginDataHolder, instance: PluginData)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +46,7 @@ public interface PluginDataStorage {
|
|||||||
*
|
*
|
||||||
* **实现细节**: 调用 [PluginData.updaterSerializer]
|
* **实现细节**: 调用 [PluginData.updaterSerializer]
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun store(holder: PluginDataHolder, instance: PluginData)
|
public fun store(holder: PluginDataHolder, instance: PluginData)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -96,7 +96,7 @@ public companion object {
|
|||||||
* 在内存存储所有 [PluginData] 实例的 [PluginDataStorage]. 在内存数据丢失后相关 [PluginData] 实例也会丢失.
|
* 在内存存储所有 [PluginData] 实例的 [PluginDataStorage]. 在内存数据丢失后相关 [PluginData] 实例也会丢失.
|
||||||
* @see PluginDataStorage
|
* @see PluginDataStorage
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface MemoryPluginDataStorage : PluginDataStorage {
|
public interface MemoryPluginDataStorage : PluginDataStorage {
|
||||||
public companion object {
|
public companion object {
|
||||||
/**
|
/**
|
||||||
@ -112,7 +112,7 @@ public interface MemoryPluginDataStorage : PluginDataStorage {
|
|||||||
/**
|
/**
|
||||||
* 用多个文件存储 [PluginData] 实例的 [PluginDataStorage].
|
* 用多个文件存储 [PluginData] 实例的 [PluginDataStorage].
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface MultiFilePluginDataStorage : PluginDataStorage {
|
public interface MultiFilePluginDataStorage : PluginDataStorage {
|
||||||
/**
|
/**
|
||||||
* 存放 [PluginData] 的目录.
|
* 存放 [PluginData] 的目录.
|
||||||
|
@ -16,7 +16,7 @@ import kotlinx.serialization.KSerializer
|
|||||||
import kotlinx.serialization.StringFormat
|
import kotlinx.serialization.StringFormat
|
||||||
import net.mamoe.mirai.console.internal.data.map
|
import net.mamoe.mirai.console.internal.data.map
|
||||||
import net.mamoe.mirai.console.internal.data.setValueBySerializer
|
import net.mamoe.mirai.console.internal.data.setValueBySerializer
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import kotlin.properties.ReadWriteProperty
|
import kotlin.properties.ReadWriteProperty
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ public interface StringValue : PrimitiveValue<String>
|
|||||||
/**
|
/**
|
||||||
* 复合数据类型实现
|
* 复合数据类型实现
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface CompositeValue<T> : Value<T>
|
public interface CompositeValue<T> : Value<T>
|
||||||
|
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ public interface ListValue<E> : CompositeValue<List<E>>
|
|||||||
*
|
*
|
||||||
* @param E 不是基础数据类型
|
* @param E 不是基础数据类型
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface CompositeListValue<E> : ListValue<E>
|
public interface CompositeListValue<E> : ListValue<E>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,16 +235,16 @@ public interface CompositeListValue<E> : ListValue<E>
|
|||||||
*
|
*
|
||||||
* @param E 是基础类型
|
* @param E 是基础类型
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveListValue<E> : ListValue<E>
|
public interface PrimitiveListValue<E> : ListValue<E>
|
||||||
|
|
||||||
|
|
||||||
//// region PrimitiveListValue CODEGEN ////
|
//// region PrimitiveListValue CODEGEN ////
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveIntListValue : PrimitiveListValue<Int>
|
public interface PrimitiveIntListValue : PrimitiveListValue<Int>
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveLongListValue : PrimitiveListValue<Long>
|
public interface PrimitiveLongListValue : PrimitiveListValue<Long>
|
||||||
// TODO + codegen
|
// TODO + codegen
|
||||||
|
|
||||||
@ -255,30 +255,30 @@ public interface PrimitiveLongListValue : PrimitiveListValue<Long>
|
|||||||
* @see [CompositeSetValue]
|
* @see [CompositeSetValue]
|
||||||
* @see [PrimitiveSetValue]
|
* @see [PrimitiveSetValue]
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface SetValue<E> : CompositeValue<Set<E>>
|
public interface SetValue<E> : CompositeValue<Set<E>>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复合数据类型 [Set]
|
* 复合数据类型 [Set]
|
||||||
* @param E 是基础数据类型
|
* @param E 是基础数据类型
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface CompositeSetValue<E> : SetValue<E>
|
public interface CompositeSetValue<E> : SetValue<E>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础数据类型 [Set]
|
* 基础数据类型 [Set]
|
||||||
* @param E 是基础数据类型
|
* @param E 是基础数据类型
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveSetValue<E> : SetValue<E>
|
public interface PrimitiveSetValue<E> : SetValue<E>
|
||||||
|
|
||||||
|
|
||||||
//// region PrimitiveSetValue CODEGEN ////
|
//// region PrimitiveSetValue CODEGEN ////
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveIntSetValue : PrimitiveSetValue<Int>
|
public interface PrimitiveIntSetValue : PrimitiveSetValue<Int>
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveLongSetValue : PrimitiveSetValue<Long>
|
public interface PrimitiveLongSetValue : PrimitiveSetValue<Long>
|
||||||
// TODO + codegen
|
// TODO + codegen
|
||||||
|
|
||||||
@ -289,27 +289,27 @@ public interface PrimitiveLongSetValue : PrimitiveSetValue<Long>
|
|||||||
* @see [CompositeMapValue]
|
* @see [CompositeMapValue]
|
||||||
* @see [PrimitiveMapValue]
|
* @see [PrimitiveMapValue]
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface MapValue<K, V> : CompositeValue<Map<K, V>>
|
public interface MapValue<K, V> : CompositeValue<Map<K, V>>
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface CompositeMapValue<K, V> : MapValue<K, V>
|
public interface CompositeMapValue<K, V> : MapValue<K, V>
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveMapValue<K, V> : MapValue<K, V>
|
public interface PrimitiveMapValue<K, V> : MapValue<K, V>
|
||||||
|
|
||||||
|
|
||||||
//// region PrimitiveMapValue CODEGEN ////
|
//// region PrimitiveMapValue CODEGEN ////
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveIntIntMapValue : PrimitiveMapValue<Int, Int>
|
public interface PrimitiveIntIntMapValue : PrimitiveMapValue<Int, Int>
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PrimitiveIntLongMapValue : PrimitiveMapValue<Int, Long>
|
public interface PrimitiveIntLongMapValue : PrimitiveMapValue<Int, Long>
|
||||||
// TODO + codegen
|
// TODO + codegen
|
||||||
|
|
||||||
//// endregion PrimitiveSetValue CODEGEN ////
|
//// endregion PrimitiveSetValue CODEGEN ////
|
||||||
|
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface ReferenceValue<T> : Value<T>
|
public interface ReferenceValue<T> : Value<T>
|
@ -13,18 +13,18 @@ import net.mamoe.mirai.console.extensions.PermissionServiceProvider
|
|||||||
import net.mamoe.mirai.console.extensions.PluginLoaderProvider
|
import net.mamoe.mirai.console.extensions.PluginLoaderProvider
|
||||||
import net.mamoe.mirai.console.extensions.SingletonExtensionSelector
|
import net.mamoe.mirai.console.extensions.SingletonExtensionSelector
|
||||||
import net.mamoe.mirai.console.extensions.SingletonExtensionSelector.ExtensionPoint.selectSingleton
|
import net.mamoe.mirai.console.extensions.SingletonExtensionSelector.ExtensionPoint.selectSingleton
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个扩展.
|
* 表示一个扩展.
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface Extension
|
public interface Extension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加一些函数 (方法)的扩展
|
* 增加一些函数 (方法)的扩展
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface FunctionExtension : Extension
|
public interface FunctionExtension : Extension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +34,7 @@ public interface FunctionExtension : Extension
|
|||||||
*
|
*
|
||||||
* @see PermissionServiceProvider
|
* @see PermissionServiceProvider
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface SingletonExtension<T> : Extension {
|
public interface SingletonExtension<T> : Extension {
|
||||||
public val instance: T
|
public val instance: T
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ public interface SingletonExtension<T> : Extension {
|
|||||||
*
|
*
|
||||||
* @see PluginLoaderProvider
|
* @see PluginLoaderProvider
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface InstanceExtension<T> : Extension {
|
public interface InstanceExtension<T> : Extension {
|
||||||
public val instance: T
|
public val instance: T
|
||||||
}
|
}
|
||||||
|
@ -12,18 +12,18 @@
|
|||||||
package net.mamoe.mirai.console.extension
|
package net.mamoe.mirai.console.extension
|
||||||
|
|
||||||
import net.mamoe.mirai.console.plugin.PluginLoader
|
import net.mamoe.mirai.console.plugin.PluginLoader
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import kotlin.reflect.full.isSubclassOf
|
import kotlin.reflect.full.isSubclassOf
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface ExtensionPoint<T : Extension> {
|
public interface ExtensionPoint<T : Extension> {
|
||||||
public val type: KClass<T>
|
public val type: KClass<T>
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public inline fun <reified T : Extension> ExtensionPoint<*>.isFor(exactType: Boolean = false): Boolean {
|
public inline fun <reified T : Extension> ExtensionPoint<*>.isFor(exactType: Boolean = false): Boolean {
|
||||||
return if (exactType) {
|
return if (exactType) {
|
||||||
T::class == type
|
T::class == type
|
||||||
@ -32,15 +32,15 @@ public interface ExtensionPoint<T : Extension> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface SingletonExtensionPoint<T : SingletonExtension<*>> : ExtensionPoint<T>
|
public interface SingletonExtensionPoint<T : SingletonExtension<*>> : ExtensionPoint<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表示一个扩展点
|
* 表示一个扩展点
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public open class AbstractExtensionPoint<T : Extension>(
|
public open class AbstractExtensionPoint<T : Extension>(
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public override val type: KClass<T>,
|
public override val type: KClass<T>,
|
||||||
) : ExtensionPoint<T>
|
) : ExtensionPoint<T>
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public open class AbstractExtensionPoint<T : Extension>(
|
|||||||
* @see PluginLoader.disable
|
* @see PluginLoader.disable
|
||||||
* @see PluginLoader.description
|
* @see PluginLoader.description
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public open class ExtensionException : RuntimeException {
|
public open class ExtensionException : RuntimeException {
|
||||||
public constructor() : super()
|
public constructor() : super()
|
||||||
public constructor(message: String?) : super(message)
|
public constructor(message: String?) : super(message)
|
||||||
|
@ -14,7 +14,7 @@ import net.mamoe.mirai.console.extension.*
|
|||||||
import net.mamoe.mirai.console.internal.extensions.BuiltInSingletonExtensionSelector
|
import net.mamoe.mirai.console.internal.extensions.BuiltInSingletonExtensionSelector
|
||||||
import net.mamoe.mirai.console.plugin.Plugin
|
import net.mamoe.mirai.console.plugin.Plugin
|
||||||
import net.mamoe.mirai.console.plugin.name
|
import net.mamoe.mirai.console.plugin.name
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.utils.info
|
import net.mamoe.mirai.utils.info
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ import kotlin.reflect.KClass
|
|||||||
*
|
*
|
||||||
* 如有多个 [SingletonExtensionSelector] 注册, 将会停止服务器.
|
* 如有多个 [SingletonExtensionSelector] 注册, 将会停止服务器.
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface SingletonExtensionSelector : FunctionExtension {
|
public interface SingletonExtensionSelector : FunctionExtension {
|
||||||
public data class Registry<T : Extension>(
|
public data class Registry<T : Extension>(
|
||||||
val plugin: Plugin,
|
val plugin: Plugin,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:OptIn(ConsoleExperimentalAPI::class)
|
@file:OptIn(ConsoleExperimentalApi::class)
|
||||||
|
|
||||||
package net.mamoe.mirai.console.internal
|
package net.mamoe.mirai.console.internal
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ import net.mamoe.mirai.console.plugin.PluginLoader
|
|||||||
import net.mamoe.mirai.console.plugin.PluginManager
|
import net.mamoe.mirai.console.plugin.PluginManager
|
||||||
import net.mamoe.mirai.console.plugin.center.PluginCenter
|
import net.mamoe.mirai.console.plugin.center.PluginCenter
|
||||||
import net.mamoe.mirai.console.plugin.jvm.AbstractJvmPlugin
|
import net.mamoe.mirai.console.plugin.jvm.AbstractJvmPlugin
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.console.util.ConsoleInput
|
import net.mamoe.mirai.console.util.ConsoleInput
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
@ -93,7 +93,7 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI
|
|||||||
|
|
||||||
override fun createLogger(identity: String?): MiraiLogger = instance.createLogger(identity)
|
override fun createLogger(identity: String?): MiraiLogger = instance.createLogger(identity)
|
||||||
|
|
||||||
@OptIn(ConsoleExperimentalAPI::class, ExperimentalPermission::class)
|
@OptIn(ConsoleExperimentalApi::class, ExperimentalPermission::class)
|
||||||
@Suppress("RemoveRedundantBackticks")
|
@Suppress("RemoveRedundantBackticks")
|
||||||
internal fun doStart() {
|
internal fun doStart() {
|
||||||
phase `greeting`@{
|
phase `greeting`@{
|
||||||
|
@ -15,7 +15,7 @@ import net.mamoe.mirai.console.data.PluginDataHolder
|
|||||||
import net.mamoe.mirai.console.data.PluginDataStorage
|
import net.mamoe.mirai.console.data.PluginDataStorage
|
||||||
import net.mamoe.mirai.console.internal.command.qualifiedNameOrTip
|
import net.mamoe.mirai.console.internal.command.qualifiedNameOrTip
|
||||||
import net.mamoe.mirai.console.permission.ExperimentalPermission
|
import net.mamoe.mirai.console.permission.ExperimentalPermission
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.utils.MiraiLogger
|
import net.mamoe.mirai.utils.MiraiLogger
|
||||||
import net.mamoe.mirai.utils.SilentLogger
|
import net.mamoe.mirai.utils.SilentLogger
|
||||||
import net.mamoe.mirai.utils.debug
|
import net.mamoe.mirai.utils.debug
|
||||||
@ -63,7 +63,7 @@ internal open class MultiFilePluginDataStorageImpl(
|
|||||||
return file.toFile().also { it.createNewFile() }
|
return file.toFile().also { it.createNewFile() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public override fun store(holder: PluginDataHolder, instance: PluginData) {
|
public override fun store(holder: PluginDataHolder, instance: PluginData) {
|
||||||
@OptIn(ExperimentalPermission::class)
|
@OptIn(ExperimentalPermission::class)
|
||||||
val yaml =/* if (instance.saveName == "PermissionService") Json {
|
val yaml =/* if (instance.saveName == "PermissionService") Json {
|
||||||
|
@ -15,7 +15,7 @@ import kotlinx.serialization.KSerializer
|
|||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
import net.mamoe.mirai.console.internal.data.map
|
import net.mamoe.mirai.console.internal.data.map
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -109,7 +109,7 @@ public sealed class AbstractPermissibleIdentifier(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public object AsStringSerializer : KSerializer<AbstractPermissibleIdentifier> by String.serializer().map(
|
public object AsStringSerializer : KSerializer<AbstractPermissibleIdentifier> by String.serializer().map(
|
||||||
serializer = { it.toString() },
|
serializer = { it.toString() },
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.console.permission
|
package net.mamoe.mirai.console.permission
|
||||||
|
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,7 +49,7 @@ public val RootConsoleBuiltInPermission: Permission by lazy {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
@ExperimentalPermission
|
@ExperimentalPermission
|
||||||
public fun Permission.parentsWithSelfSequence(): Sequence<Permission> =
|
public fun Permission.parentsWithSelfSequence(): Sequence<Permission> =
|
||||||
generateSequence(this) { p ->
|
generateSequence(this) { p ->
|
||||||
|
@ -11,14 +11,14 @@ package net.mamoe.mirai.console.plugin.center
|
|||||||
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public interface PluginCenter {
|
public interface PluginCenter {
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public data class PluginInsight(
|
public data class PluginInsight(
|
||||||
val name: String,
|
val name: String,
|
||||||
val version: String,
|
val version: String,
|
||||||
@ -32,7 +32,7 @@ public interface PluginCenter {
|
|||||||
val commands: List<String>
|
val commands: List<String>
|
||||||
)
|
)
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
@Serializable
|
@Serializable
|
||||||
public data class PluginInfo(
|
public data class PluginInfo(
|
||||||
val name: String,
|
val name: String,
|
||||||
|
@ -15,7 +15,7 @@ import net.mamoe.mirai.console.data.AutoSavePluginDataHolder
|
|||||||
import net.mamoe.mirai.console.data.PluginConfig
|
import net.mamoe.mirai.console.data.PluginConfig
|
||||||
import net.mamoe.mirai.console.data.PluginData
|
import net.mamoe.mirai.console.data.PluginData
|
||||||
import net.mamoe.mirai.console.internal.plugin.JvmPluginInternal
|
import net.mamoe.mirai.console.internal.plugin.JvmPluginInternal
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.utils.minutesToMillis
|
import net.mamoe.mirai.utils.minutesToMillis
|
||||||
import net.mamoe.mirai.utils.secondsToMillis
|
import net.mamoe.mirai.utils.secondsToMillis
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
@ -30,7 +30,7 @@ import kotlin.coroutines.EmptyCoroutineContext
|
|||||||
public abstract class AbstractJvmPlugin @JvmOverloads constructor(
|
public abstract class AbstractJvmPlugin @JvmOverloads constructor(
|
||||||
parentCoroutineContext: CoroutineContext = EmptyCoroutineContext,
|
parentCoroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||||
) : JvmPlugin, JvmPluginInternal(parentCoroutineContext), AutoSavePluginDataHolder {
|
) : JvmPlugin, JvmPluginInternal(parentCoroutineContext), AutoSavePluginDataHolder {
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public final override val dataHolderName: String
|
public final override val dataHolderName: String
|
||||||
get() = this.description.name
|
get() = this.description.name
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public abstract class AbstractJvmPlugin @JvmOverloads constructor(
|
|||||||
@JvmName("reloadPluginConfig")
|
@JvmName("reloadPluginConfig")
|
||||||
public fun <T : PluginConfig> T.reload(): Unit = loader.configStorage.load(this@AbstractJvmPlugin, this)
|
public fun <T : PluginConfig> T.reload(): Unit = loader.configStorage.load(this@AbstractJvmPlugin, this)
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public override val autoSaveIntervalMillis: LongRange = 30.secondsToMillis..10.minutesToMillis
|
public override val autoSaveIntervalMillis: LongRange = 30.secondsToMillis..10.minutesToMillis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,23 +13,23 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import net.mamoe.mirai.console.data.PluginDataStorage
|
import net.mamoe.mirai.console.data.PluginDataStorage
|
||||||
import net.mamoe.mirai.console.internal.plugin.JarPluginLoaderImpl
|
import net.mamoe.mirai.console.internal.plugin.JarPluginLoaderImpl
|
||||||
import net.mamoe.mirai.console.plugin.FilePluginLoader
|
import net.mamoe.mirai.console.plugin.FilePluginLoader
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内建的 Jar (JVM) 插件加载器
|
* 内建的 Jar (JVM) 插件加载器
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI("classname might change")
|
@ConsoleExperimentalApi("classname might change")
|
||||||
public interface JarPluginLoader : CoroutineScope, FilePluginLoader<JvmPlugin, JvmPluginDescription> {
|
public interface JarPluginLoader : CoroutineScope, FilePluginLoader<JvmPlugin, JvmPluginDescription> {
|
||||||
/**
|
/**
|
||||||
* [JvmPlugin.reloadPluginData] 默认使用的实例
|
* [JvmPlugin.reloadPluginData] 默认使用的实例
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public val dataStorage: PluginDataStorage
|
public val dataStorage: PluginDataStorage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [JvmPlugin.reloadPluginData] 默认使用的实例
|
* [JvmPlugin.reloadPluginData] 默认使用的实例
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public val configStorage: PluginDataStorage
|
public val configStorage: PluginDataStorage
|
||||||
|
|
||||||
public companion object INSTANCE : JarPluginLoader by JarPluginLoaderImpl {
|
public companion object INSTANCE : JarPluginLoader by JarPluginLoaderImpl {
|
||||||
|
@ -20,7 +20,7 @@ import kotlin.annotation.AnnotationTarget.*
|
|||||||
@Retention(AnnotationRetention.SOURCE)
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||||
@Target(PROPERTY, FUNCTION, TYPE, CLASS)
|
@Target(PROPERTY, FUNCTION, TYPE, CLASS)
|
||||||
internal annotation class JavaFriendlyAPI
|
internal annotation class JavaFriendlyApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标记为一个仅供 mirai-console 内部使用的 API.
|
* 标记为一个仅供 mirai-console 内部使用的 API.
|
||||||
@ -32,8 +32,8 @@ internal annotation class JavaFriendlyAPI
|
|||||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||||
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR, CLASS, FUNCTION, PROPERTY)
|
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR, CLASS, FUNCTION, PROPERTY)
|
||||||
@MustBeDocumented
|
@MustBeDocumented
|
||||||
public annotation class ConsoleInternalAPI(
|
public annotation class ConsoleInternalApi(
|
||||||
val message: String = ""
|
val message: String = "",
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,6 +46,6 @@ public annotation class ConsoleInternalAPI(
|
|||||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||||
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
|
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
|
||||||
@MustBeDocumented
|
@MustBeDocumented
|
||||||
public annotation class ConsoleExperimentalAPI(
|
public annotation class ConsoleExperimentalApi(
|
||||||
val message: String = ""
|
val message: String = "",
|
||||||
)
|
)
|
@ -18,7 +18,7 @@ import net.mamoe.mirai.contact.Member
|
|||||||
/**
|
/**
|
||||||
* 为简化操作提供的一些工具
|
* 为简化操作提供的一些工具
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public object ContactUtils {
|
public object ContactUtils {
|
||||||
/**
|
/**
|
||||||
* 获取一个 [Bot] 的好友, 群, 或群员.
|
* 获取一个 [Bot] 的好友, 群, 或群员.
|
||||||
@ -31,7 +31,7 @@ public object ContactUtils {
|
|||||||
*/
|
*/
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun Bot.getContact(id: Long, includeMembers: Boolean = false): Contact {
|
public fun Bot.getContact(id: Long, includeMembers: Boolean = false): Contact {
|
||||||
return getContactOrNull(id, includeMembers)
|
return getContactOrNull(id, includeMembers)
|
||||||
?: throw NoSuchElementException("Contact $id not found for bot ${this.id}")
|
?: throw NoSuchElementException("Contact $id not found for bot ${this.id}")
|
||||||
@ -44,7 +44,7 @@ public object ContactUtils {
|
|||||||
*/
|
*/
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun Bot.getContactOrNull(id: Long, includeMembers: Boolean = false): Contact? {
|
public fun Bot.getContactOrNull(id: Long, includeMembers: Boolean = false): Contact? {
|
||||||
return getFriendOrGroupOrNull(id) ?: kotlin.run {
|
return getFriendOrGroupOrNull(id) ?: kotlin.run {
|
||||||
if (includeMembers) {
|
if (includeMembers) {
|
||||||
@ -60,7 +60,7 @@ public object ContactUtils {
|
|||||||
* 访问顺序为 [Bot.friends] -> [Bot.groups]
|
* 访问顺序为 [Bot.friends] -> [Bot.groups]
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun Bot.getFriendOrGroup(id: Long): Contact {
|
public fun Bot.getFriendOrGroup(id: Long): Contact {
|
||||||
return getFriendOrGroupOrNull(id)
|
return getFriendOrGroupOrNull(id)
|
||||||
?: throw NoSuchElementException("Friend or Group $id not found for bot ${this.id}")
|
?: throw NoSuchElementException("Friend or Group $id not found for bot ${this.id}")
|
||||||
@ -72,7 +72,7 @@ public object ContactUtils {
|
|||||||
* 访问顺序为 [Bot.friends] -> [Bot.groups]
|
* 访问顺序为 [Bot.friends] -> [Bot.groups]
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun Bot.getFriendOrGroupOrNull(id: Long): Contact? {
|
public fun Bot.getFriendOrGroupOrNull(id: Long): Contact? {
|
||||||
return this.friends.getOrNull(id) ?: this.groups.getOrNull(id)
|
return this.friends.getOrNull(id) ?: this.groups.getOrNull(id)
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,15 @@ import kotlinx.coroutines.*
|
|||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.coroutines.EmptyCoroutineContext
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public object CoroutineScopeUtils {
|
public object CoroutineScopeUtils {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun CoroutineContext.overrideWithSupervisorJob(name: String? = null): CoroutineContext =
|
public fun CoroutineContext.overrideWithSupervisorJob(name: String? = null): CoroutineContext =
|
||||||
this + NamedSupervisorJob(name ?: "<unnamed>", this[Job])
|
this + NamedSupervisorJob(name ?: "<unnamed>", this[Job])
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun CoroutineScope.childScope(
|
public fun CoroutineScope.childScope(
|
||||||
name: String? = null,
|
name: String? = null,
|
||||||
context: CoroutineContext = EmptyCoroutineContext
|
context: CoroutineContext = EmptyCoroutineContext
|
||||||
@ -31,7 +31,7 @@ public object CoroutineScopeUtils {
|
|||||||
CoroutineScope(this.childScopeContext(name, context))
|
CoroutineScope(this.childScopeContext(name, context))
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public fun CoroutineScope.childScopeContext(
|
public fun CoroutineScope.childScopeContext(
|
||||||
name: String? = null,
|
name: String? = null,
|
||||||
context: CoroutineContext = EmptyCoroutineContext
|
context: CoroutineContext = EmptyCoroutineContext
|
||||||
@ -42,7 +42,7 @@ public object CoroutineScopeUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public class NamedSupervisorJob @JvmOverloads constructor(
|
public class NamedSupervisorJob @JvmOverloads constructor(
|
||||||
private val name: String,
|
private val name: String,
|
||||||
parent: Job? = null
|
parent: Job? = null
|
||||||
|
@ -104,7 +104,7 @@ public interface MessageScope {
|
|||||||
*
|
*
|
||||||
* @suppress 此 API 不稳定, 可能在任何时间被修改
|
* @suppress 此 API 不稳定, 可能在任何时间被修改
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
public val realTarget: Any?
|
public val realTarget: Any?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +18,9 @@ import net.mamoe.mirai.console.data.PluginDataStorage
|
|||||||
import net.mamoe.mirai.console.plugin.DeferredPluginLoader
|
import net.mamoe.mirai.console.plugin.DeferredPluginLoader
|
||||||
import net.mamoe.mirai.console.plugin.PluginLoader
|
import net.mamoe.mirai.console.plugin.PluginLoader
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JarPluginLoader
|
import net.mamoe.mirai.console.plugin.jvm.JarPluginLoader
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.console.util.ConsoleInput
|
import net.mamoe.mirai.console.util.ConsoleInput
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
import net.mamoe.mirai.message.data.Message
|
import net.mamoe.mirai.message.data.Message
|
||||||
import net.mamoe.mirai.utils.BotConfiguration
|
import net.mamoe.mirai.utils.BotConfiguration
|
||||||
import net.mamoe.mirai.utils.LoginSolver
|
import net.mamoe.mirai.utils.LoginSolver
|
||||||
@ -32,12 +32,12 @@ import kotlin.coroutines.CoroutineContext
|
|||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
import kotlin.test.assertNotNull
|
import kotlin.test.assertNotNull
|
||||||
|
|
||||||
@OptIn(ConsoleInternalAPI::class)
|
@OptIn(ConsoleInternalApi::class)
|
||||||
fun initTestEnvironment() {
|
fun initTestEnvironment() {
|
||||||
object : MiraiConsoleImplementation {
|
object : MiraiConsoleImplementation {
|
||||||
override val rootPath: Path = createTempDir().toPath()
|
override val rootPath: Path = createTempDir().toPath()
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
override val frontEndDescription: MiraiConsoleFrontEndDescription
|
override val frontEndDescription: MiraiConsoleFrontEndDescription
|
||||||
get() = object : MiraiConsoleFrontEndDescription {
|
get() = object : MiraiConsoleFrontEndDescription {
|
||||||
override val name: String
|
override val name: String
|
||||||
|
@ -12,12 +12,12 @@ package net.mamoe.mirai.console.data
|
|||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
|
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
|
||||||
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
|
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertSame
|
import kotlin.test.assertSame
|
||||||
|
|
||||||
@OptIn(ConsoleInternalAPI::class)
|
@OptIn(ConsoleInternalApi::class)
|
||||||
internal class PluginDataTest {
|
internal class PluginDataTest {
|
||||||
|
|
||||||
object MyPlugin : KotlinPlugin(
|
object MyPlugin : KotlinPlugin(
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
object Versions {
|
object Versions {
|
||||||
const val core = "1.2.2"
|
const val core = "1.2.3"
|
||||||
const val console = "1.0-M4-dev-5"
|
const val console = "1.0-M4-dev-5"
|
||||||
const val consoleGraphical = "0.0.7"
|
const val consoleGraphical = "0.0.7"
|
||||||
const val consoleTerminal = "0.1.0"
|
const val consoleTerminal = "0.1.0"
|
||||||
|
@ -20,14 +20,14 @@ import net.mamoe.mirai.console.command.CommandExecuteStatus
|
|||||||
import net.mamoe.mirai.console.command.CommandManager
|
import net.mamoe.mirai.console.command.CommandManager
|
||||||
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.executeCommand
|
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.executeCommand
|
||||||
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
import net.mamoe.mirai.console.util.requestInput
|
import net.mamoe.mirai.console.util.requestInput
|
||||||
import net.mamoe.mirai.utils.DefaultLogger
|
import net.mamoe.mirai.utils.DefaultLogger
|
||||||
import org.jline.reader.UserInterruptException
|
import org.jline.reader.UserInterruptException
|
||||||
|
|
||||||
val consoleLogger by lazy { DefaultLogger("console") }
|
val consoleLogger by lazy { DefaultLogger("console") }
|
||||||
|
|
||||||
@OptIn(ConsoleInternalAPI::class)
|
@OptIn(ConsoleInternalApi::class)
|
||||||
internal fun startupConsoleThread() {
|
internal fun startupConsoleThread() {
|
||||||
MiraiConsole.launch(CoroutineName("Input")) {
|
MiraiConsole.launch(CoroutineName("Input")) {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
"INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER_WARNING",
|
"INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER_WARNING",
|
||||||
"EXPOSED_SUPER_CLASS"
|
"EXPOSED_SUPER_CLASS"
|
||||||
)
|
)
|
||||||
@file:OptIn(ConsoleInternalAPI::class, ConsoleFrontEndImplementation::class)
|
@file:OptIn(ConsoleInternalApi::class, ConsoleFrontEndImplementation::class)
|
||||||
|
|
||||||
package net.mamoe.mirai.console.pure
|
package net.mamoe.mirai.console.pure
|
||||||
|
|
||||||
@ -34,9 +34,9 @@ import net.mamoe.mirai.console.plugin.DeferredPluginLoader
|
|||||||
import net.mamoe.mirai.console.plugin.PluginLoader
|
import net.mamoe.mirai.console.plugin.PluginLoader
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JarPluginLoader
|
import net.mamoe.mirai.console.plugin.jvm.JarPluginLoader
|
||||||
import net.mamoe.mirai.console.pure.ConsoleInputImpl.requestInput
|
import net.mamoe.mirai.console.pure.ConsoleInputImpl.requestInput
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.console.util.ConsoleInput
|
import net.mamoe.mirai.console.util.ConsoleInput
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
import net.mamoe.mirai.console.util.NamedSupervisorJob
|
import net.mamoe.mirai.console.util.NamedSupervisorJob
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
import org.fusesource.jansi.Ansi
|
import org.fusesource.jansi.Ansi
|
||||||
@ -58,7 +58,7 @@ import java.util.*
|
|||||||
*
|
*
|
||||||
* @see MiraiConsolePureLoader CLI 入口点
|
* @see MiraiConsolePureLoader CLI 入口点
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
class MiraiConsoleImplementationPure
|
class MiraiConsoleImplementationPure
|
||||||
@JvmOverloads constructor(
|
@JvmOverloads constructor(
|
||||||
override val rootPath: Path = Paths.get("."),
|
override val rootPath: Path = Paths.get("."),
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"INVISIBLE_GETTER",
|
"INVISIBLE_GETTER",
|
||||||
"INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER",
|
"INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER",
|
||||||
)
|
)
|
||||||
@file:OptIn(ConsoleInternalAPI::class)
|
@file:OptIn(ConsoleInternalApi::class)
|
||||||
|
|
||||||
package net.mamoe.mirai.console.pure
|
package net.mamoe.mirai.console.pure
|
||||||
|
|
||||||
@ -26,8 +26,8 @@ import net.mamoe.mirai.console.MiraiConsole
|
|||||||
import net.mamoe.mirai.console.MiraiConsoleImplementation
|
import net.mamoe.mirai.console.MiraiConsoleImplementation
|
||||||
import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start
|
import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start
|
||||||
import net.mamoe.mirai.console.data.AutoSavePluginDataHolder
|
import net.mamoe.mirai.console.data.AutoSavePluginDataHolder
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScope
|
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScope
|
||||||
import net.mamoe.mirai.message.data.Message
|
import net.mamoe.mirai.message.data.Message
|
||||||
import net.mamoe.mirai.utils.DefaultLogger
|
import net.mamoe.mirai.utils.DefaultLogger
|
||||||
@ -51,7 +51,7 @@ object MiraiConsolePureLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
fun startAsDaemon(instance: MiraiConsoleImplementationPure = MiraiConsoleImplementationPure()) {
|
fun startAsDaemon(instance: MiraiConsoleImplementationPure = MiraiConsoleImplementationPure()) {
|
||||||
instance.start()
|
instance.start()
|
||||||
overrideSTD()
|
overrideSTD()
|
||||||
@ -61,10 +61,10 @@ object MiraiConsolePureLoader {
|
|||||||
|
|
||||||
internal object ConsoleDataHolder : AutoSavePluginDataHolder,
|
internal object ConsoleDataHolder : AutoSavePluginDataHolder,
|
||||||
CoroutineScope by MiraiConsole.childScope("ConsoleDataHolder") {
|
CoroutineScope by MiraiConsole.childScope("ConsoleDataHolder") {
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
override val autoSaveIntervalMillis: LongRange = 1.minutesToMillis..10.minutesToMillis
|
override val autoSaveIntervalMillis: LongRange = 1.minutesToMillis..10.minutesToMillis
|
||||||
|
|
||||||
@ConsoleExperimentalAPI
|
@ConsoleExperimentalApi
|
||||||
override val dataHolderName: String
|
override val dataHolderName: String
|
||||||
get() = "Pure"
|
get() = "Pure"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user