Мелкие доработки оплаты по табличке.
This commit is contained in:
parent
5bd184ec2a
commit
57dc685c5d
@ -94,7 +94,12 @@ class SignHandler: Listener {
|
|||||||
LOGGER.info("Container block: $cordX $cordY $cordZ")
|
LOGGER.info("Container block: $cordX $cordY $cordZ")
|
||||||
|
|
||||||
val container: Chest = containerBlock.state as Chest
|
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}")
|
LOGGER.info("firstItem: ${firstItem.type} | amount: ${firstItem.amount}")
|
||||||
|
|
||||||
// Get info
|
// Get info
|
||||||
@ -150,7 +155,7 @@ class SignHandler: Listener {
|
|||||||
|
|
||||||
var coloredLine: String
|
var coloredLine: String
|
||||||
// Check if some data is missing
|
// 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")
|
coloredLine = ChatColor.translateAlternateColorCodes('&', "$PREFIX&cError")
|
||||||
event.setLine(0, coloredLine)
|
event.setLine(0, coloredLine)
|
||||||
return
|
return
|
||||||
|
|||||||
@ -712,10 +712,12 @@ pay_by_sign=${DEFAULT_PAY_BY_SIGN}
|
|||||||
val availableAmount = paymentInfo.container.inventory.all(type).values.sumOf { it.amount }
|
val availableAmount = paymentInfo.container.inventory.all(type).values.sumOf { it.amount }
|
||||||
if (availableAmount < paymentInfo.amount) {
|
if (availableAmount < paymentInfo.amount) {
|
||||||
LOGGER.error("Not enough items after pay invoice, try to return VPC...")
|
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 vpcUsername = DataManager.getPlayerVPCUsername(paymentInfo.player.name).toString()
|
||||||
val transferResult = VpcApi.transfer_coins(vpcUsername, paymentInfo.cost).toString()
|
val transferResult = VpcApi.transfer_coins(vpcUsername, paymentInfo.cost).toString()
|
||||||
if (transferResult != "OK") {
|
if (transferResult != "OK") {
|
||||||
LOGGER.error("Can't return VPC, result: $transferResult")
|
LOGGER.error("Can't return VPC, result: $transferResult")
|
||||||
|
Utils.send(paymentInfo.player, "&cНевозможно вернуть VPC, обратитесь к администратору: $transferResult")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If we have needed items
|
// If we have needed items
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user