From 57dc685c5dbc7a0fa8f9447b5b9527938ed4e4a2 Mon Sep 17 00:00:00 2001 From: justuser-31 Date: Sun, 30 Nov 2025 16:01:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=B4?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B8=20=D0=BE=D0=BF?= =?UTF-8?q?=D0=BB=D0=B0=D1=82=D1=8B=20=D0=BF=D0=BE=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D1=87=D0=BA=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/main/VpcSpigotIntegration/SignHandler.kt | 9 +++++++-- .../main/VpcSpigotIntegration/VpcServerIntegration.kt | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/main/VpcSpigotIntegration/SignHandler.kt b/src/main/kotlin/main/VpcSpigotIntegration/SignHandler.kt index 684b651..cc56e89 100644 --- a/src/main/kotlin/main/VpcSpigotIntegration/SignHandler.kt +++ b/src/main/kotlin/main/VpcSpigotIntegration/SignHandler.kt @@ -94,7 +94,12 @@ class SignHandler: Listener { LOGGER.info("Container block: $cordX $cordY $cordZ") val container: Chest = containerBlock.state as Chest - val firstItem = container.blockInventory.contents[0] + LOGGER.info("Content: ${container.blockInventory.contents}") + var firstItem = container.blockInventory.contents.filterNotNull().firstOrNull() + if (firstItem == null) { + Utils.send(event.player,"&cВ контейнере нет предметов для покупки.") + } + firstItem = firstItem as ItemStack LOGGER.info("firstItem: ${firstItem.type} | amount: ${firstItem.amount}") // Get info @@ -150,7 +155,7 @@ class SignHandler: Listener { var coloredLine: String // Check if some data is missing - if (vpcUsername.isEmpty() || cost == null || amount == null) { + if (vpcUsername.isEmpty() || cost == null || amount == null || amount < 0 || cost < 0) { coloredLine = ChatColor.translateAlternateColorCodes('&', "$PREFIX&cError") event.setLine(0, coloredLine) return diff --git a/src/main/kotlin/main/VpcSpigotIntegration/VpcServerIntegration.kt b/src/main/kotlin/main/VpcSpigotIntegration/VpcServerIntegration.kt index 67eec6f..2368b0c 100644 --- a/src/main/kotlin/main/VpcSpigotIntegration/VpcServerIntegration.kt +++ b/src/main/kotlin/main/VpcSpigotIntegration/VpcServerIntegration.kt @@ -712,10 +712,12 @@ pay_by_sign=${DEFAULT_PAY_BY_SIGN} val availableAmount = paymentInfo.container.inventory.all(type).values.sumOf { it.amount } if (availableAmount < paymentInfo.amount) { LOGGER.error("Not enough items after pay invoice, try to return VPC...") + Utils.send(paymentInfo.player, "&cВ контейнере недостаточно предметов, попытка вернуть VPC...") val vpcUsername = DataManager.getPlayerVPCUsername(paymentInfo.player.name).toString() val transferResult = VpcApi.transfer_coins(vpcUsername, paymentInfo.cost).toString() if (transferResult != "OK") { LOGGER.error("Can't return VPC, result: $transferResult") + Utils.send(paymentInfo.player, "&cНевозможно вернуть VPC, обратитесь к администратору: $transferResult") } } else { // If we have needed items