From d2dffef44cf78ac9b49762ef6eb48512325e04e4 Mon Sep 17 00:00:00 2001 From: Him188 Date: Tue, 27 Oct 2020 20:39:38 +0800 Subject: [PATCH] 1.0-RC Code review --- .../mirai/console/MiraiConsoleImplementation.kt | 2 +- .../mamoe/mirai/console/command/AbstractCommand.kt | 14 ++++++++++---- .../net/mamoe/mirai/console/command/Command.kt | 3 +++ .../mirai/console/command/CommandExecuteResult.kt | 9 +++++++++ .../console/command/CommandExecutionException.kt | 6 ++---- .../mamoe/mirai/console/command/CommandOwner.kt | 9 +++++---- .../command/CommandPermissionDeniedException.kt | 4 +--- .../mirai/console/command/CompositeCommand.kt | 3 +-- .../net/mamoe/mirai/console/command/RawCommand.kt | 4 ++-- .../mamoe/mirai/console/command/SimpleCommand.kt | 3 +-- .../mirai/console/command/java/JRawCommand.kt | 4 ++-- .../mamoe/mirai/console/data/AbstractPluginData.kt | 3 +++ .../mirai/console/data/AutoSavePluginConfig.kt | 8 +------- .../mamoe/mirai/console/data/AutoSavePluginData.kt | 9 --------- .../net/mamoe/mirai/console/data/PluginData.kt | 5 ++++- .../mamoe/mirai/console/data/ValueDescription.kt | 7 ++++++- .../console/data/java/JAutoSavePluginConfig.kt | 8 +------- .../mirai/console/data/java/JAutoSavePluginData.kt | 7 +------ .../mirai/console/extension/ExtensionPoint.kt | 6 ++++-- .../extensions/CommandCallParserProvider.kt | 4 ++-- .../extensions/CommandCallResolverProvider.kt | 4 ++-- .../console/extensions/PostStartupExtension.kt | 4 ++-- .../extensions/SingletonExtensionSelector.kt | 5 ++++- .../internal/MiraiConsoleImplementationBridge.kt | 3 +++ .../console/internal/command/CommandReflector.kt | 11 ++++++++++- .../mirai/console/internal/command/internal.kt | 3 ++- .../internal/data/builtins/AutoLoginConfig.kt | 9 +++++++++ .../extension/BuiltInSingletonExtensionSelector.kt | 9 +++++++++ .../console/internal/plugin/ExportManagerImpl.kt | 8 +++----- .../internal/util/JavaPluginSchedulerImpl.kt | 5 ++--- .../console/permission/PermissionIdNamespace.kt | 2 +- .../net/mamoe/mirai/console/plugin/Plugin.kt | 2 +- .../mamoe/mirai/console/plugin/PluginManager.kt | 12 ++++++++++++ .../console/plugin/jvm/JavaPluginScheduler.kt | 8 +++++--- .../net/mamoe/mirai/console/util/ConsoleInput.kt | 2 +- .../net/mamoe/mirai/console/util/MessageScope.kt | 5 +++++ .../net/mamoe/mirai/console/command/TestCommand.kt | 1 + 37 files changed, 131 insertions(+), 80 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt index c2cab53e7..9950ae12d 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt @@ -47,7 +47,7 @@ public annotation class ConsoleFrontEndImplementation /** * 实现 [MiraiConsole] 的接口 * - * **注意**: 随着 Console 的更新, 在版本号 `x.y.z` 的 `y` 修改时此接口可能就会变动. 意味着前端实现着需要跟随 Console 更新. + * **注意**: 随着 Console 的更新, 在版本号 `x.y.z` 的 `y` 修改时此接口可能就会发生 ABI 变动. 意味着前端实现着需要跟随 Console 更新. * * @see MiraiConsoleImplementation.start 启动 */ diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/AbstractCommand.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/AbstractCommand.kt index 7de3bd955..940c50294 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/AbstractCommand.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/AbstractCommand.kt @@ -7,9 +7,12 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ +@file:Suppress("unused") + package net.mamoe.mirai.console.command -import net.mamoe.mirai.console.internal.command.createOrFindCommandPermission +import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors +import net.mamoe.mirai.console.internal.command.findOrCreateCommandPermission import net.mamoe.mirai.console.permission.Permission /** @@ -26,14 +29,17 @@ public abstract class AbstractCommand public final override val secondaryNames: Array, public override val description: String = "", parentPermission: Permission = owner.parentPermission, - /** 为 `true` 时表示 [指令前缀][CommandManager.commandPrefix] 可选 */ - public override val prefixOptional: Boolean = false, ) : Command { + + @ExperimentalCommandDescriptors + override val prefixOptional: Boolean + get() = false + init { Command.checkCommandName(primaryName) secondaryNames.forEach(Command.Companion::checkCommandName) } public override val usage: String get() = description - public override val permission: Permission by lazy { createOrFindCommandPermission(parentPermission) } + public override val permission: Permission by lazy { findOrCreateCommandPermission(parentPermission) } } \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt index a73e2f842..f1f44cbd9 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt @@ -77,6 +77,9 @@ public interface Command { * 为 `true` 时表示 [指令前缀][CommandManager.commandPrefix] 可选. * * 会影响聊天语境中的解析. + * + * #### 实验性 API + * 由于指令解析允许被扩展, 此属性可能不适用所有解析器, 因此还未决定是否保留. */ @ExperimentalCommandDescriptors @ConsoleExperimentalApi diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandExecuteResult.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandExecuteResult.kt index 9697dd4d7..2e7c79c4a 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandExecuteResult.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandExecuteResult.kt @@ -21,6 +21,8 @@ import kotlin.contracts.contract /** * 指令的执行返回 * + * 注意: 现阶段 + * * @see CommandExecuteStatus */ @ConsoleExperimentalApi("Not yet implemented") @@ -144,12 +146,14 @@ public sealed class CommandExecuteResult { } } +@ExperimentalCommandDescriptors @Suppress("RemoveRedundantQualifierName") public typealias CommandExecuteStatus = CommandExecuteResult.CommandExecuteStatus /** * 当 [this] 为 [CommandExecuteResult.Success] 时返回 `true` */ +@ExperimentalCommandDescriptors @JvmSynthetic public fun CommandExecuteResult.isSuccess(): Boolean { contract { @@ -162,6 +166,7 @@ public fun CommandExecuteResult.isSuccess(): Boolean { /** * 当 [this] 为 [CommandExecuteResult.IllegalArgument] 时返回 `true` */ +@ExperimentalCommandDescriptors @JvmSynthetic public fun CommandExecuteResult.isIllegalArgument(): Boolean { contract { @@ -174,6 +179,7 @@ public fun CommandExecuteResult.isIllegalArgument(): Boolean { /** * 当 [this] 为 [CommandExecuteResult.ExecutionFailed] 时返回 `true` */ +@ExperimentalCommandDescriptors @JvmSynthetic public fun CommandExecuteResult.isExecutionException(): Boolean { contract { @@ -186,6 +192,7 @@ public fun CommandExecuteResult.isExecutionException(): Boolean { /** * 当 [this] 为 [CommandExecuteResult.PermissionDenied] 时返回 `true` */ +@ExperimentalCommandDescriptors @JvmSynthetic public fun CommandExecuteResult.isPermissionDenied(): Boolean { contract { @@ -198,6 +205,7 @@ public fun CommandExecuteResult.isPermissionDenied(): Boolean { /** * 当 [this] 为 [CommandExecuteResult.UnresolvedCall] 时返回 `true` */ +@ExperimentalCommandDescriptors @JvmSynthetic public fun CommandExecuteResult.isCommandNotFound(): Boolean { contract { @@ -210,6 +218,7 @@ public fun CommandExecuteResult.isCommandNotFound(): Boolean { /** * 当 [this] 为 [CommandExecuteResult.ExecutionFailed], [CommandExecuteResult.IllegalArgument] 或 [CommandExecuteResult.UnresolvedCall] 时返回 `true` */ +@ExperimentalCommandDescriptors @JvmSynthetic public fun CommandExecuteResult.isFailure(): Boolean { contract { diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandExecutionException.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandExecutionException.kt index 1998b71b0..dd3d0c761 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandExecutionException.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandExecutionException.kt @@ -11,10 +11,8 @@ package net.mamoe.mirai.console.command -import net.mamoe.mirai.console.command.CommandManager.INSTANCE.executeCommand - /** - * 在 [CommandManager.executeCommand] 中, [Command.onCommand] 抛出异常时包装的异常. + * 在 [CommandManager.executeCommand] 中抛出异常时包装的异常. */ public class CommandExecutionException( /** @@ -29,7 +27,7 @@ public class CommandExecutionException( * 匹配到的指令名 */ public val name: String, - cause: Throwable + cause: Throwable, ) : RuntimeException( "Exception while executing command '${command.primaryName}'", cause diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandOwner.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandOwner.kt index f59033c95..0c5ea4eaa 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandOwner.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandOwner.kt @@ -9,7 +9,6 @@ package net.mamoe.mirai.console.command -import net.mamoe.mirai.console.command.CommandManager.INSTANCE.unregisterAllCommands import net.mamoe.mirai.console.compiler.common.ResolveContext import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.PERMISSION_NAME import net.mamoe.mirai.console.permission.Permission @@ -34,11 +33,13 @@ public interface CommandOwner : PermissionIdNamespace { /** * 代表控制台所有者. 所有的 mirai-console 内建的指令都属于 [ConsoleCommandOwner]. + * + * 插件注册指令时不应该使用 [ConsoleCommandOwner]. */ -internal object ConsoleCommandOwner : CommandOwner { - override val parentPermission: Permission get() = BuiltInCommands.parentPermission +public object ConsoleCommandOwner : CommandOwner { + public override val parentPermission: Permission get() = BuiltInCommands.parentPermission - override fun permissionId( + public override fun permissionId( @ResolveContext(PERMISSION_NAME) name: String, ): PermissionId = PermissionId("console", name) } \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandPermissionDeniedException.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandPermissionDeniedException.kt index f966ce96d..309f1528a 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandPermissionDeniedException.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandPermissionDeniedException.kt @@ -9,8 +9,6 @@ package net.mamoe.mirai.console.command -import net.mamoe.mirai.console.command.CommandManager.INSTANCE.executeCommand - /** * 在 [CommandManager.executeCommand] 中, [CommandSender] 未拥有 [Command.permission] 所要求的权限时抛出的异常. * @@ -24,7 +22,7 @@ public class CommandPermissionDeniedException( /** * 执行过程发生异常的指令 */ - public val command: Command + public val command: Command, ) : RuntimeException("Permission denied while executing command '${command.primaryName}'") { public override fun toString(): String = "CommandPermissionDeniedException(command=$command)" diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CompositeCommand.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CompositeCommand.kt index efec2b5d1..d88b41559 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CompositeCommand.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CompositeCommand.kt @@ -87,9 +87,8 @@ public abstract class CompositeCommand( @ResolveContext(COMMAND_NAME) vararg secondaryNames: String, description: String = "no description available", parentPermission: Permission = owner.parentPermission, - prefixOptional: Boolean = false, overrideContext: CommandArgumentContext = EmptyCommandArgumentContext, -) : Command, AbstractCommand(owner, primaryName, secondaryNames = secondaryNames, description, parentPermission, prefixOptional), +) : Command, AbstractCommand(owner, primaryName, secondaryNames = secondaryNames, description, parentPermission), CommandArgumentContextAware { private val reflector by lazy { CommandReflector(this, CompositeCommandSubCommandAnnotationResolver) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/RawCommand.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/RawCommand.kt index 4b17e51e2..850c55320 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/RawCommand.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/RawCommand.kt @@ -15,7 +15,7 @@ import net.mamoe.mirai.console.command.descriptor.* import net.mamoe.mirai.console.command.java.JRawCommand import net.mamoe.mirai.console.compiler.common.ResolveContext import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME -import net.mamoe.mirai.console.internal.command.createOrFindCommandPermission +import net.mamoe.mirai.console.internal.command.findOrCreateCommandPermission import net.mamoe.mirai.console.internal.data.typeOf0 import net.mamoe.mirai.console.permission.Permission import net.mamoe.mirai.message.data.Message @@ -53,7 +53,7 @@ public abstract class RawCommand( @OptIn(ExperimentalCommandDescriptors::class) public override val prefixOptional: Boolean = false, ) : Command { - public override val permission: Permission by lazy { createOrFindCommandPermission(parentPermission) } + public override val permission: Permission by lazy { findOrCreateCommandPermission(parentPermission) } @ExperimentalCommandDescriptors override val overloads: List = listOf( diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/SimpleCommand.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/SimpleCommand.kt index 48ce42f7c..9d0465ee0 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/SimpleCommand.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/SimpleCommand.kt @@ -58,9 +58,8 @@ public abstract class SimpleCommand( @ResolveContext(COMMAND_NAME) vararg secondaryNames: String, description: String = "no description available", parentPermission: Permission = owner.parentPermission, - prefixOptional: Boolean = false, overrideContext: CommandArgumentContext = EmptyCommandArgumentContext, -) : Command, AbstractCommand(owner, primaryName, secondaryNames = secondaryNames, description, parentPermission, prefixOptional), +) : Command, AbstractCommand(owner, primaryName, secondaryNames = secondaryNames, description, parentPermission), CommandArgumentContextAware { private val reflector by lazy { CommandReflector(this, SimpleCommandSubCommandAnnotationResolver) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/java/JRawCommand.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/java/JRawCommand.kt index 70b62e680..8d6358050 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/java/JRawCommand.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/java/JRawCommand.kt @@ -16,7 +16,7 @@ import net.mamoe.mirai.console.command.CommandOwner import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors import net.mamoe.mirai.console.compiler.common.ResolveContext import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME -import net.mamoe.mirai.console.internal.command.createOrFindCommandPermission +import net.mamoe.mirai.console.internal.command.findOrCreateCommandPermission import net.mamoe.mirai.console.permission.Permission /** @@ -65,7 +65,7 @@ public abstract class JRawCommand protected set /** 指令权限 */ - public final override var permission: Permission = createOrFindCommandPermission(parentPermission) + public final override var permission: Permission = findOrCreateCommandPermission(parentPermission) protected set /** 为 `true` 时表示 [指令前缀][CommandManager.commandPrefix] 可选 */ diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt index 90b22bd06..435a666eb 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt @@ -23,6 +23,9 @@ import kotlin.reflect.KProperty /** * [PluginData] 的默认实现. 支持使用 `by value()` 等委托方法创建 [Value] 并跟踪其改动. * + * ### 实现注意 + * 此类型处于实验性阶段. 使用其中定义的属性和函数是安全的, 但将来可能会新增成员抽象函数. + * * @see PluginData */ public abstract class AbstractPluginData : PluginData, PluginDataImpl() { diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginConfig.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginConfig.kt index 1e3793e5a..749c9b60f 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginConfig.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginConfig.kt @@ -23,10 +23,4 @@ import kotlinx.coroutines.Job * @see PluginConfig * @see AutoSavePluginData */ -public open class AutoSavePluginConfig : AutoSavePluginData, PluginConfig { - @Deprecated("请手动指定保存名称. 此构造器将在 1.0.0 删除", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("AutoSavePluginConfig(\"把我改成保存名称\")")) - @Suppress("DEPRECATION_ERROR") - public constructor() : super() - - public constructor(saveName: String) : super(saveName) -} +public open class AutoSavePluginConfig public constructor(saveName: String) : AutoSavePluginData(saveName), PluginConfig \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt index f081af4d2..3fe5c0bc9 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt @@ -18,7 +18,6 @@ import net.mamoe.mirai.console.internal.data.qualifiedNameOrTip import net.mamoe.mirai.console.internal.plugin.updateWhen import net.mamoe.mirai.console.util.ConsoleExperimentalApi import net.mamoe.mirai.utils.* -import kotlin.reflect.full.findAnnotation /** * 链接自动保存的 [PluginData]. @@ -46,14 +45,6 @@ public open class AutoSavePluginData private constructor( _saveName = saveName } - @Deprecated("请手动指定保存名称. 此构造器将在 1.0.0 删除", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("AutoSavePluginData(\"把我改成保存名称\")")) - public constructor() : this(null) { - val clazz = this::class - _saveName = clazz.findAnnotation()?.value - ?: clazz.qualifiedName - ?: throw IllegalArgumentException("Cannot find a serial name for ${this::class}") - } - @ConsoleExperimentalApi override fun onInit(owner: PluginDataHolder, storage: PluginDataStorage) { check(owner is AutoSavePluginDataHolder) { "owner must be AutoSavePluginDataHolder for AutoSavePluginData" } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt index 174170e1b..05d6ffe43 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt @@ -98,13 +98,16 @@ import kotlin.reflect.KType * ``` * // MyPluginData.nestedMap: MutableMap> by value() * val newList = MyPluginData.map.getOrPut(1, ::mutableListOf) - * newList.add(1) // 不会添加到 MyPluginData.nestedMap 中, 因为 `mutableListOf` 创建的 MutableList 被非引用地添加进了 MyPluginData.nestedMap + * newList.add(1) // 不会添加到 MyPluginData.nestedMap 中, 因为 `mutableListOf` 创建的 MutableList 被非引用 (浅拷贝) 地添加进了 MyPluginData.nestedMap * ``` * * 一个解决方案是对 [SerializerAwareValue] 做映射或相关修改. 如 [PluginDataExtensions]. * * 要查看详细的解释,请查看 [docs/PluginData.md](https://github.com/mamoe/mirai-console/blob/master/docs/PluginData.md) * + * ## 实现注意 + * 此类型处于实验性阶段. 使用其中定义的属性和函数是安全的, 但将来可能会新增成员抽象函数. + * * @see AbstractJvmPlugin.reloadPluginData 通过 [JvmPlugin] 获取指定 [PluginData] 实例. * @see PluginDataStorage [PluginData] 存储仓库 * @see PluginDataExtensions 相关 [SerializerAwareValue] 映射函数 diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/ValueDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/ValueDescription.kt index 907944766..1b4c02a13 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/ValueDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/ValueDescription.kt @@ -35,4 +35,9 @@ import kotlinx.serialization.SerialInfo @SerialInfo @Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) -public annotation class ValueDescription(val value: String) \ No newline at end of file +public annotation class ValueDescription( + /** + * 将会被 [String.trimIndent] 处理. + */ + val value: String, +) \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/java/JAutoSavePluginConfig.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/java/JAutoSavePluginConfig.kt index 1ca820466..568ad2530 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/java/JAutoSavePluginConfig.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/java/JAutoSavePluginConfig.kt @@ -37,10 +37,4 @@ import net.mamoe.mirai.console.data.PluginData * @see JAutoSavePluginData * @see PluginConfig */ -public abstract class JAutoSavePluginConfig : AutoSavePluginConfig, PluginConfig { - @Deprecated("请手动指定保存名称. 此构造器将在 1.0.0 删除", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("JAutoSavePluginConfig(\"把我改成保存名称\")")) - @Suppress("DEPRECATION_ERROR") - public constructor() : super() - - public constructor(saveName: String) : super(saveName) -} +public abstract class JAutoSavePluginConfig public constructor(saveName: String) : AutoSavePluginConfig(saveName), PluginConfig \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/java/JAutoSavePluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/java/JAutoSavePluginData.kt index 442f19cc9..8ec168756 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/java/JAutoSavePluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/java/JAutoSavePluginData.kt @@ -66,12 +66,7 @@ import kotlin.reflect.full.createType * * @see PluginData */ -public abstract class JAutoSavePluginData : AutoSavePluginData, PluginConfig { - @Deprecated("请手动指定保存名称. 此构造器将在 1.0.0 删除", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("JAutoSavePluginData(\"把我改成保存名称\")")) - @Suppress("DEPRECATION_ERROR") - public constructor() : super() - - public constructor(saveName: String) : super(saveName) +public abstract class JAutoSavePluginData public constructor(saveName: String) : AutoSavePluginData(saveName), PluginConfig { //// region JPluginData_value_primitives CODEGEN //// diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionPoint.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionPoint.kt index b5580db83..04a772cf5 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionPoint.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionPoint.kt @@ -50,7 +50,8 @@ public interface InstanceExtensionPoint> : ExtensionPoi public interface FunctionExtensionPoint : ExtensionPoint -public abstract class AbstractInstanceExtensionPoint, T>( +public abstract class AbstractInstanceExtensionPoint, T> +@ConsoleExperimentalApi constructor( extensionType: KClass, /** * 内建的实现列表. @@ -59,7 +60,8 @@ public abstract class AbstractInstanceExtensionPoint, T public vararg val builtinImplementations: E, ) : AbstractExtensionPoint(extensionType) -public abstract class AbstractSingletonExtensionPoint, T>( +public abstract class AbstractSingletonExtensionPoint, T> +@ConsoleExperimentalApi constructor( extensionType: KClass, /** * 内建的实现. diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/CommandCallParserProvider.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/CommandCallParserProvider.kt index 51cc23a9f..b543edf89 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/CommandCallParserProvider.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/CommandCallParserProvider.kt @@ -30,6 +30,6 @@ public interface CommandCallParserProvider : InstanceExtension CommandCallParser) : CommandCallParserProvider { - override val instance: CommandCallParser by lazy(instanceCalculator) +public class CommandCallParserProviderImplLazy(initializer: () -> CommandCallParser) : CommandCallParserProvider { + override val instance: CommandCallParser by lazy(initializer) } \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/CommandCallResolverProvider.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/CommandCallResolverProvider.kt index 43e2a6fca..5081e21b3 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/CommandCallResolverProvider.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/CommandCallResolverProvider.kt @@ -26,6 +26,6 @@ public interface CommandCallResolverProvider : InstanceExtension CommandCallResolver) : CommandCallResolverProvider { - override val instance: CommandCallResolver by lazy(instanceCalculator) +public class CommandCallResolverProviderImplLazy(initializer: () -> CommandCallResolver) : CommandCallResolverProvider { + override val instance: CommandCallResolver by lazy(initializer) } \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PostStartupExtension.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PostStartupExtension.kt index f18185e17..ab5d563e2 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PostStartupExtension.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PostStartupExtension.kt @@ -24,10 +24,10 @@ public fun interface PostStartupExtension : FunctionExtension { /** * 将在 Console 主线程执行. * - * @throws Exception 所有抛出的 [Exception] 都会被捕获并包装为 [ExtensionException] 抛出, 并停止 [MiraiConsole] - * * #### 内部实现细节 * 在 [MiraiConsoleImplementationBridge.doStart] 所有 [MiraiConsoleImplementationBridge.phase] 执行完成后顺序调用. + * + * @throws Exception 所有抛出的 [Exception] 都会被捕获并包装为 [ExtensionException] 抛出, 并停止 [MiraiConsole] */ @Throws(Exception::class) public operator fun invoke() diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/SingletonExtensionSelector.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/SingletonExtensionSelector.kt index 2dfce8f6c..869cfff2c 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/SingletonExtensionSelector.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/SingletonExtensionSelector.kt @@ -28,13 +28,16 @@ import kotlin.reflect.KClass * 如有多个 [SingletonExtensionSelector] 注册, 将会停止服务器. */ public interface SingletonExtensionSelector : FunctionExtension { + /** + * 表示一个插件注册的 [Extension] + */ public data class Registry( val plugin: Plugin?, val extension: T, ) /** - * @return null 表示使用 builtin + * @return `null` 表示使用 Console 内置的 [SingletonExtensionSelector] */ public fun selectSingleton( extensionType: KClass, diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleImplementationBridge.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleImplementationBridge.kt index 6b98780cc..9c1119d5a 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleImplementationBridge.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleImplementationBridge.kt @@ -226,6 +226,9 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI @DslMarker internal annotation class ILoveOmaeKumikoForever + /** + * 表示一个初始化阶段, 无实际作用. + */ @ILoveOmaeKumikoForever private inline fun phase(block: () -> Unit) { contract { diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt index a85a7a8f8..e65c0103c 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt @@ -1,3 +1,12 @@ +/* + * Copyright 2019-2020 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + */ + package net.mamoe.mirai.console.internal.command import net.mamoe.mirai.console.command.* @@ -149,7 +158,7 @@ internal class CommandReflector( append(" ") } append(subcommand.valueParameters.joinToString(" ") { it.render() }) - annotationResolver.getDescription(command, subcommand.originFunction).let { description -> + annotationResolver.getDescription(command, subcommand.originFunction)?.let { description -> append(" ") append(description) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/internal.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/internal.kt index a1ebfbf2e..42eead40c 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/internal.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/internal.kt @@ -58,6 +58,7 @@ internal fun Group.fuzzySearchMember( disambiguationRate: Double = 0.1, ): List> { val candidates = (this.members + botAsMember) + .asSequence() .associateWith { it.nameCard.fuzzyMatchWith(nameCardTarget) } .filter { it.value >= minRate } .toList() @@ -79,7 +80,7 @@ internal fun Group.fuzzySearchMember( } } -internal fun Command.createOrFindCommandPermission(parent: Permission): Permission { +internal fun Command.findOrCreateCommandPermission(parent: Permission): Permission { val id = owner.permissionId("command.$primaryName") return PermissionService.INSTANCE[id] ?: PermissionService.INSTANCE.register(id, description, parent) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/data/builtins/AutoLoginConfig.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/data/builtins/AutoLoginConfig.kt index 5cf269874..a78aa6ef5 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/data/builtins/AutoLoginConfig.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/data/builtins/AutoLoginConfig.kt @@ -1,3 +1,12 @@ +/* + * Copyright 2019-2020 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + */ + package net.mamoe.mirai.console.internal.data.builtins import net.mamoe.mirai.console.data.AutoSavePluginConfig diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/extension/BuiltInSingletonExtensionSelector.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/extension/BuiltInSingletonExtensionSelector.kt index d096341ed..1d313ca6d 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/extension/BuiltInSingletonExtensionSelector.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/extension/BuiltInSingletonExtensionSelector.kt @@ -1,3 +1,12 @@ +/* + * Copyright 2019-2020 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + */ + package net.mamoe.mirai.console.internal.extension import kotlinx.coroutines.runBlocking diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/ExportManagerImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/ExportManagerImpl.kt index 5797aece0..787f7bd80 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/ExportManagerImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/ExportManagerImpl.kt @@ -1,12 +1,10 @@ /* - * Copyright (c) 2018-2020 Karlatemp. All rights reserved. - * @author Karlatemp - * - * LuckPerms-Mirai/mirai-console.mirai-console.main/ExportManagerImpl.kt + * Copyright 2019-2020 Mamoe Technologies and contributors. * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link. * - * https://github.com/Karlatemp/LuckPerms-Mirai/blob/master/LICENSE + * https://github.com/mamoe/mirai/blob/master/LICENSE */ package net.mamoe.mirai.console.internal.plugin diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/util/JavaPluginSchedulerImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/util/JavaPluginSchedulerImpl.kt index 23af98223..7385df2ae 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/util/JavaPluginSchedulerImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/util/JavaPluginSchedulerImpl.kt @@ -43,11 +43,10 @@ internal class JavaPluginSchedulerImpl internal constructor(parentCoroutineConte } } - override fun delayed(delayMillis: Long, runnable: Callable): CompletableFuture { + override fun delayed(delayMillis: Long, callable: Callable): CompletableFuture { return future { delay(delayMillis) - withContext(Dispatchers.IO) { runnable.call() } - null + withContext(Dispatchers.IO) { callable.call() } } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionIdNamespace.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionIdNamespace.kt index 90a043608..ac0076b2b 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionIdNamespace.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionIdNamespace.kt @@ -20,7 +20,7 @@ public interface PermissionIdNamespace { /** * 创建一个此命名空间下的 [PermitteeId]. * - * 在指令初始化时, 会申请对应权限. 此时 [name] 为 "command.$primaryName` 其中 [primaryName][Command.primaryName]. + * 在指令初始化时, 会申请对应权限. 此时 [name] 为 `command.$primaryName` 其中 [primaryName][Command.primaryName]. */ public fun permissionId(@ResolveContext(PERMISSION_NAME) name: String): PermissionId } \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/Plugin.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/Plugin.kt index 9fd35e08b..0a7c2c05d 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/Plugin.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/Plugin.kt @@ -35,7 +35,7 @@ import kotlin.DeprecationLevel.ERROR */ public interface Plugin : CommandOwner { /** - * 判断此插件是否已启用 + * 当插件已启用时返回 `true`, 否则表示插件未启用. * * @see PluginManager.enablePlugin 启用一个插件 * @see PluginManager.disablePlugin 禁用一个插件 diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/PluginManager.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/PluginManager.kt index e5ad8140f..1b0804b39 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/PluginManager.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/PluginManager.kt @@ -140,16 +140,28 @@ public interface PluginManager { get() = this.loader as PluginLoader + /** + * @see getPluginDescription + */ @get:JvmSynthetic public inline val Plugin.description: PluginDescription get() = getPluginDescription(this) + /** + * @see disablePlugin + */ @JvmSynthetic public inline fun Plugin.disable(): Unit = disablePlugin(this) + /** + * @see enablePlugin + */ @JvmSynthetic public inline fun Plugin.enable(): Unit = enablePlugin(this) + /** + * @see loadPlugin + */ @JvmSynthetic public inline fun Plugin.load(): Unit = loadPlugin(this) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JavaPluginScheduler.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JavaPluginScheduler.kt index 684832703..d1f50470d 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JavaPluginScheduler.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JavaPluginScheduler.kt @@ -19,6 +19,7 @@ import java.util.concurrent.Callable import java.util.concurrent.CompletableFuture import java.util.concurrent.Future import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext /** @@ -48,9 +49,9 @@ public interface JavaPluginScheduler : CoroutineScope { /** * 新增一个 Delayed Task (延迟任务) * - * 在延迟 [delayMillis] 后执行 [runnable] + * 在延迟 [delayMillis] 后执行 [callable] */ - public fun delayed(delayMillis: Long, runnable: Callable): CompletableFuture + public fun delayed(delayMillis: Long, callable: Callable): CompletableFuture /** * 异步执行一个任务, 最终返回 [Future], 与 Java 使用方法无异, 但效率更高且可以在插件关闭时停止 @@ -68,7 +69,8 @@ public interface JavaPluginScheduler : CoroutineScope { */ @JvmStatic @JvmName("create") - public operator fun invoke(parentCoroutineContext: CoroutineContext): JavaPluginScheduler = + @JvmOverloads + public operator fun invoke(parentCoroutineContext: CoroutineContext = EmptyCoroutineContext): JavaPluginScheduler = JavaPluginSchedulerImpl(parentCoroutineContext) } } \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/ConsoleInput.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/ConsoleInput.kt index dc30c4d81..ed79e4c76 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/ConsoleInput.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/ConsoleInput.kt @@ -18,7 +18,7 @@ import net.mamoe.mirai.console.MiraiConsole import net.mamoe.mirai.console.internal.util.ConsoleInputImpl /** - * Console 输入. 由于 console 接管了 [stdin][System. in], [readLine] 等操作需要在这里进行. + * Console 输入. 由于 console 接管了 [标准输入][System. in], [readLine] 等操作需要在这里进行. */ public interface ConsoleInput { /** diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt index 92a82a616..a8fd52195 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/MessageScope.kt @@ -72,6 +72,7 @@ import kotlin.internal.LowPriorityInOverloadResolution * val duration = Random.nextInt(1, 15) * target.mute(duration) * + * * // 不使用 MessageScope, 无用的样板代码 * val thisGroup = this.getGroupOrNull() * val message = "${this.name} 禁言 ${target.nameCardOrNick} $duration 秒" @@ -80,12 +81,14 @@ import kotlin.internal.LowPriorityInOverloadResolution * } * sendMessage(message) * + * * // 使用 MessageScope, 清晰逻辑 * // 表示至少发送给 `this`, 当 `this` 的真实发信对象与 `target.group` 不同时, 还额外发送给 `target.group` * this.scopeWith(target.group) { * sendMessage("${name} 禁言了 ${target.nameCardOrNick} $duration 秒") * } * + * * // 同样地, 可以扩展用法, 同时私聊指令执行者: * // this.scopeWith( * // target, @@ -132,6 +135,8 @@ public inline operator fun MS.invoke(action: MS.() -> R): /* * 实现提示: 以下所有代码都通过 codegen 模块中 net.mamoe.mirai.console.codegen.MessageScopeCodegen 生成. 请不要手动修改它们. + * + * 建议阅读 [MessageScope] 的文档. */ //// region MessageScopeBuilders CODEGEN //// diff --git a/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/command/TestCommand.kt b/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/command/TestCommand.kt index bf3b7c796..f9cf618dc 100644 --- a/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/command/TestCommand.kt +++ b/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/command/TestCommand.kt @@ -77,6 +77,7 @@ internal class TestCommand { @Test fun testRegister() { + error(TestCompositeCommand.usage) try { unregisterAllCommands(ConsoleCommandOwner) // builtins unregisterCommand(TestSimpleCommand)