From e72a7305bf6a35c77e20cb46f201817b1c98d74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD?= <3104026189@qq.com> Date: Sun, 2 Oct 2022 14:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=91=BD=E4=BB=A4=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../com/github/xbaimiao/shoppro/core/Commands.kt | 14 +++++++++----- .../github/xbaimiao/shoppro/core/shop/ShopImpl.kt | 2 +- src/main/resources/lang/zh_CN.yml | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 00b25c2..2d9016b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=com.github.xbaimiao.shoppro -version=1.0.7 +version=1.0.9-beta diff --git a/src/main/kotlin/com/github/xbaimiao/shoppro/core/Commands.kt b/src/main/kotlin/com/github/xbaimiao/shoppro/core/Commands.kt index 7c7abfe..2eb648a 100644 --- a/src/main/kotlin/com/github/xbaimiao/shoppro/core/Commands.kt +++ b/src/main/kotlin/com/github/xbaimiao/shoppro/core/Commands.kt @@ -27,9 +27,13 @@ object Commands { } execute { 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 { _, _ -> onlinePlayers.map { it.name } } @@ -44,7 +48,7 @@ object Commands { @CommandBody val sellAll = subCommand { - dynamic("name") { + dynamic("name", permission = "shoppro.command.sellall") { suggestion { _, _ -> 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 { _, _ -> onlinePlayers.map { it.name } } @@ -73,7 +77,7 @@ object Commands { shop.sellAll(player) } - @CommandBody(permission = "admin") + @CommandBody(permission = "shoppro.resetlimit") val resetLimit = subCommand { execute { sender, _, _ -> ShopPro.database.reset() @@ -81,7 +85,7 @@ object Commands { } } - @CommandBody(permission = "admin") + @CommandBody(permission = "shoppro.reload") val reload = subCommand { execute { sender, _, _ -> ShopPro.reload() diff --git a/src/main/kotlin/com/github/xbaimiao/shoppro/core/shop/ShopImpl.kt b/src/main/kotlin/com/github/xbaimiao/shoppro/core/shop/ShopImpl.kt index eaca5b6..ed35bfd 100644 --- a/src/main/kotlin/com/github/xbaimiao/shoppro/core/shop/ShopImpl.kt +++ b/src/main/kotlin/com/github/xbaimiao/shoppro/core/shop/ShopImpl.kt @@ -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) } } diff --git a/src/main/resources/lang/zh_CN.yml b/src/main/resources/lang/zh_CN.yml index cbf85fa..2b3a5bd 100644 --- a/src/main/resources/lang/zh_CN.yml +++ b/src/main/resources/lang/zh_CN.yml @@ -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}个,已达到今日收购限制"