更新命令权限

This commit is contained in:
小白
2022-10-02 14:27:15 +08:00
parent 3fefb62a8b
commit e72a7305bf
4 changed files with 12 additions and 7 deletions
@@ -27,9 +27,13 @@ object Commands {
}
execute<Player> { sender, _, argument ->
val shop = ShopManager.shops.first { it.getName() == argument }
if (!sender.hasPermission("shoppro.command.open.${shop.getName()}")){
sender.sendLang("shop-not-permission")
return@execute
}
shop.open(sender)
}
dynamic("玩家", permission = "admin") {
dynamic("玩家", permission = "shoppro.command.open.admin") {
suggestion<CommandSender> { _, _ ->
onlinePlayers.map { it.name }
}
@@ -44,7 +48,7 @@ object Commands {
@CommandBody
val sellAll = subCommand {
dynamic("name") {
dynamic("name", permission = "shoppro.command.sellall") {
suggestion<CommandSender> { _, _ ->
ShopManager.shops.map { it.getName() }
}
@@ -52,7 +56,7 @@ object Commands {
val shop = ShopManager.shops.first { it.getName() == argument }
sellAll(sender, shop)
}
dynamic("玩家", permission = "admin") {
dynamic("玩家", permission = "shoppro.command.sellall.admin") {
suggestion<CommandSender> { _, _ ->
onlinePlayers.map { it.name }
}
@@ -73,7 +77,7 @@ object Commands {
shop.sellAll(player)
}
@CommandBody(permission = "admin")
@CommandBody(permission = "shoppro.resetlimit")
val resetLimit = subCommand {
execute<CommandSender> { sender, _, _ ->
ShopPro.database.reset()
@@ -81,7 +85,7 @@ object Commands {
}
}
@CommandBody(permission = "admin")
@CommandBody(permission = "shoppro.reload")
val reload = subCommand {
execute<CommandSender> { sender, _, _ ->
ShopPro.reload()
@@ -73,7 +73,7 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
val amount = player.inventory.howManyItems {
shopItem.equal(it)
}
if (amount >= 0) {
if (amount > 0) {
sell(amount, shopItem, player)
}
}
+1
View File
@@ -1,4 +1,5 @@
shop-not-found: "&7[&e&l!&7] 你需要打开什么商店呢"
shop-not-permission: "&7[&e&l!&7] 你没有权限打开这个商店"
not-item: "&7[&e&l!&7] 你没有足够的可以出售的物品"
sell-item: "&7[&e&l!&7] 你出售了§6 {0}个 §7{1}§7获得了§6 {2}"
sell-limit-player: "&7[&e&l!&7] 此物品每人每日限制收购{0}个,已达到今日收购限制"