diff --git a/gradle.properties b/gradle.properties index ef4fa75..361a69a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=com.github.xbaimiao.shoppro -version=1.0.3 \ No newline at end of file +version=1.0.4 \ No newline at end of file diff --git a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/Item.kt b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/Item.kt index dce4728..a378ccb 100644 --- a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/Item.kt +++ b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/Item.kt @@ -28,25 +28,27 @@ interface Item { fun buildItem(): ItemStack fun update(player: Player): ItemStack - fun exeCommands(player: Player) { - commands.map { it.replace("%player%", player.name) }.forEach { command -> - if (command.startsWith("[tell] ")) { - player.sendMessage(command.substring(7).colored()) - } else if (command.startsWith("[console] ")) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.substring(10)) - } else if (command.startsWith("[player] ")) { - Bukkit.dispatchCommand(player, command.substring(9)) - } else if (command.startsWith("[open] ")) { - val shop = ShopManager.shops.firstOrNull { it.getName() == command.substring(7) } - shop?.open(player) - } else if (command.startsWith("[op] ")) { - Bukkit.dispatchCommand(object : Player by player { - override fun isOp() = true - override fun hasPermission(p0: Permission) = true - override fun hasPermission(p0: String) = true - }, command.substring(5)) - } else if (command == "close" || command.startsWith("[close]")) { - player.closeInventory() + fun exeCommands(player: Player, amount: Int) { + for (a in 1..amount){ + commands.map { it.replace("%player%", player.name) }.forEach { command -> + if (command.startsWith("[tell] ")) { + player.sendMessage(command.substring(7).colored()) + } else if (command.startsWith("[console] ")) { + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.substring(10)) + } else if (command.startsWith("[player] ")) { + Bukkit.dispatchCommand(player, command.substring(9)) + } else if (command.startsWith("[open] ")) { + val shop = ShopManager.shops.firstOrNull { it.getName() == command.substring(7) } + shop?.open(player) + } else if (command.startsWith("[op] ")) { + Bukkit.dispatchCommand(object : Player by player { + override fun isOp() = true + override fun hasPermission(p0: Permission) = true + override fun hasPermission(p0: String) = true + }, command.substring(5)) + } else if (command == "close" || command.startsWith("[close]")) { + player.closeInventory() + } } } } 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 1931884..b9ee625 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 @@ -162,7 +162,7 @@ class ShopImpl(private val configuration: Configuration) : Shop() { } } else { onClick(item.key) { - item.exeCommands(player) + item.exeCommands(player, 1) } } } @@ -188,7 +188,7 @@ class ShopImpl(private val configuration: Configuration) : Shop() { } Bukkit.getPluginManager().callEvent(ShopProBuyEvent(item, amount, player)) ShopPro.database.addAmount(item, player, LimitData(amount.toLong(), 0L)) - item.exeCommands(player) + item.exeCommands(player, amount) player.sendLang("buy-item", amount, item.name, item.price * amount) } else { player.sendLang("not-money")