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 new file mode 100644 index 000000000..7de3bd955 --- /dev/null +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/AbstractCommand.kt @@ -0,0 +1,39 @@ +/* + * 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.command + +import net.mamoe.mirai.console.internal.command.createOrFindCommandPermission +import net.mamoe.mirai.console.permission.Permission + +/** + * [Command] 的基础实现 + * + * @see SimpleCommand + * @see CompositeCommand + * @see RawCommand + */ +public abstract class AbstractCommand +@JvmOverloads constructor( + public final override val owner: CommandOwner, + public final override val primaryName: String, + 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 { + 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) } +} \ 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 9d39cfa7e..37e4f3f69 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 @@ -17,7 +17,6 @@ import net.mamoe.mirai.console.command.CommandManager.INSTANCE.register import net.mamoe.mirai.console.command.java.JCommand 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.permission.Permission import net.mamoe.mirai.console.permission.PermissionId import net.mamoe.mirai.message.data.MessageChain @@ -125,28 +124,3 @@ public interface Command { public suspend inline fun Command.onCommand(sender: CommandSender, args: MessageChain): Unit = sender.onCommand(args) -/** - * [Command] 的基础实现 - * - * @see SimpleCommand - * @see CompositeCommand - * @see RawCommand - */ -public abstract class AbstractCommand -@JvmOverloads constructor( - public final override val owner: CommandOwner, - public final override val primaryName: String, - 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 { - init { - Command.checkCommandName(primaryName) - secondaryNames.forEach(Command::checkCommandName) - } - - public override val usage: String get() = description - public override val permission: Permission by lazy { createOrFindCommandPermission(parentPermission) } -} \ No newline at end of file