Limit with out Permission

This commit is contained in:
Him188 2020-05-16 20:43:55 +08:00
parent 7a7b30766a
commit 35407acaf7

View File

@ -12,12 +12,9 @@
package net.mamoe.mirai.console.command package net.mamoe.mirai.console.command
import net.mamoe.mirai.console.command.CommandDescriptor.SubCommandDescriptor import net.mamoe.mirai.console.command.CommandDescriptor.SubCommandDescriptor
import net.mamoe.mirai.message.data.Message
import kotlin.reflect.KClass import kotlin.reflect.KClass
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
internal const val FOR_BINARY_COMPATIBILITY = "for binary compatibility"
/** /**
* 指令 * 指令
* 通常情况下, 你的指令应继承 @see CompositeCommand/SimpleCommand * 通常情况下, 你的指令应继承 @see CompositeCommand/SimpleCommand
@ -25,11 +22,12 @@ internal const val FOR_BINARY_COMPATIBILITY = "for binary compatibility"
*/ */
interface Command { interface Command {
val descriptor: CommandDescriptor val descriptor: CommandDescriptor
/** /**
* Permission of the command * Permission of the command
*/ */
@Target(AnnotationTarget.FUNCTION) @Target(AnnotationTarget.FUNCTION)
annotation class Permission(val permission:KClass<*>) annotation class Permission(val permission: KClass<out Permission>)
/** /**
* If a command is prefix optional * If a command is prefix optional
@ -37,7 +35,7 @@ interface Command {
* mute work as (/mute) if prefix optional or vise versa * mute work as (/mute) if prefix optional or vise versa
*/ */
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
annotation class PrefixOptional() annotation class PrefixOptional
} }
/** /**
@ -80,7 +78,8 @@ abstract class CompositeCommand(val name:String, val alias:Array<String> = array
} }
abstract class SimpleCommand(val name: String, val alias: Array<String> = arrayOf() abstract class SimpleCommand(
val name: String, val alias: Array<String> = arrayOf()
) : Command { ) : Command {
override val descriptor: CommandDescriptor by lazy { override val descriptor: CommandDescriptor by lazy {
CommandDescriptor() CommandDescriptor()
@ -98,6 +97,7 @@ abstract class RawCommand(name:String, alias: Array<String> = arrayOf()):Command
} }
/** /**
* 解析完成的指令实际参数列表. 参数顺序与 [Command.descriptor] [CommandDescriptor.params] 相同. * 解析完成的指令实际参数列表. 参数顺序与 [Command.descriptor] [CommandDescriptor.params] 相同.
*/ */