change command structure

This commit is contained in:
jiahua.liu 2020-05-17 13:30:11 +08:00
parent 7a7b30766a
commit 1e4035c7a4
2 changed files with 5 additions and 5 deletions

View File

@ -97,6 +97,10 @@ abstract class RawCommand(name:String, alias: Array<String> = arrayOf()):Command
} }
@Command.Permission(CommandPermission.Default::class)
abstract fun onCommand(list: List<Message>)
} }
/** /**
* 解析完成的指令实际参数列表. 参数顺序与 [Command.descriptor] [CommandDescriptor.params] 相同. * 解析完成的指令实际参数列表. 参数顺序与 [Command.descriptor] [CommandDescriptor.params] 相同.

View File

@ -28,7 +28,6 @@ interface CommandPermission {
*/ */
fun CommandSender.hasPermission(): Boolean fun CommandSender.hasPermission(): Boolean
/** /**
* 满足两个权限其中一个即可使用指令 * 满足两个权限其中一个即可使用指令
*/ // no extension for Java */ // no extension for Java
@ -39,7 +38,6 @@ interface CommandPermission {
*/ // no extension for Java */ // no extension for Java
infix fun and(another: CommandPermission): CommandPermission = AndCommandPermission(this, another) infix fun and(another: CommandPermission): CommandPermission = AndCommandPermission(this, another)
/** /**
* 任何人都可以使用这个指令 * 任何人都可以使用这个指令
*/ */
@ -55,7 +53,7 @@ interface CommandPermission {
} }
/** /**
* 来自任何 [Bot] 的任何一个管理员或群主都可以使用这个指令 * 来自任何 [Bot] 的任何一个管理员或群主都可以使用这个指令
*/ */
object Operator : CommandPermission { object Operator : CommandPermission {
override fun CommandSender.hasPermission(): Boolean { override fun CommandSender.hasPermission(): Boolean {
@ -117,10 +115,8 @@ inline fun AnonymousCommandPermission(crossinline block: CommandSender.() -> Boo
inline fun CommandSender.hasPermission(permission: CommandPermission): Boolean = inline fun CommandSender.hasPermission(permission: CommandPermission): Boolean =
permission.run { this@hasPermission.hasPermission() } permission.run { this@hasPermission.hasPermission() }
inline fun CommandPermission.hasPermission(sender: CommandSender): Boolean = this.run { sender.hasPermission() } inline fun CommandPermission.hasPermission(sender: CommandSender): Boolean = this.run { sender.hasPermission() }
internal class OrCommandPermission( internal class OrCommandPermission(
private val first: CommandPermission, private val first: CommandPermission,
private val second: CommandPermission private val second: CommandPermission