diff --git a/src/main/kotlin/main/vp_server_integration/Vp_server_integration.kt b/src/main/kotlin/main/vp_server_integration/Vp_server_integration.kt index 7445b5e..4e3230a 100644 --- a/src/main/kotlin/main/vp_server_integration/Vp_server_integration.kt +++ b/src/main/kotlin/main/vp_server_integration/Vp_server_integration.kt @@ -113,7 +113,7 @@ class Vp_server_integration() : JavaPlugin(), CommandExecutor { COMMAND_REMOVE_MODE = properties.getProperty("command_remove_mode", DEFAULT_COMMAND_REMOVE_MODE).replace("'", "") COMMAND_REMOVE_COINS = properties.getProperty("command_remove_coins", DEFAULT_COMMAND_REMOVE_COINS).replace("'", "") COMMAND_REMOVE_ERROR = properties.getProperty("command_remove_error", DEFAULT_COMMAND_REMOVE_ERROR).replace("'", "") - LOCAL_CURRENCY_MINIMUM = properties.getProperty("command_remove_error", DEFAULT_LOCAL_CURRENCY_MINIMUM.toString()).replace("'", "").toDouble() + LOCAL_CURRENCY_MINIMUM = properties.getProperty("local_currency_minimum", DEFAULT_LOCAL_CURRENCY_MINIMUM.toString()).replace("'", "").toDouble() COURSE_MODE = properties.getProperty("course_mode", DEFAULT_COURSE_MODE).replace("'", "") COURSE_STATIC_VALUE = properties.getProperty("course_static_value", DEFAULT_COURSE_STATIC_VALUE.toString()).replace("'", "").toDouble() COURSE_DYNAMIC_COMMAND = properties.getProperty("course_dynamic_command", DEFAULT_COURSE_DYNAMIC_COMMAND).replace("'", "") @@ -313,8 +313,8 @@ invoice_timeout_seconds=$DEFAULT_INVOICE_TIMEOUT_SECONDS } when (direction) { - "vpc" -> handleVpcConversion(sender, amount, course, args) - "lc" -> handleLcConversion(sender, amount, course, args) + "vpc" -> handleVpcConversion(sender, Utils.round(amount, NUM_AFTER_DOT), course, args) + "lc" -> handleLcConversion(sender, Utils.round(amount, NUM_AFTER_DOT), course, args) } } @@ -373,7 +373,10 @@ invoice_timeout_seconds=$DEFAULT_INVOICE_TIMEOUT_SECONDS return } - if (amountVPC < 0.0001 || amount < 1) + if (amountVPC < 0.0001 || amount < LOCAL_CURRENCY_MINIMUM) { + Utils.send(sender, "&cСлишком маленькая входная или выходная сумма.") + return + } if (args.size == 4) { // Execute confirmed conversion @@ -415,9 +418,14 @@ invoice_timeout_seconds=$DEFAULT_INVOICE_TIMEOUT_SECONDS } LOGGER.info("Amount: $amount, Course: $course") - val amountLC = amount * course * (1 + COURSE_COMMISSION / 100) + val amountLC = Utils.round(amount * course * (1 + COURSE_COMMISSION / 100), NUM_AFTER_DOT) LOGGER.info("Converted amount: $amountLC") + if (amount < 0.0001 || amountLC < LOCAL_CURRENCY_MINIMUM) { + Utils.send(sender, "&cСлишком маленькая входная или выходная сумма.") + return + } + // Create new invoice val invoiceId = VpcApi.create_invoice(amount).toString() TO_PAY_INVOICES[sender.name] = invoiceId