🐛 Bug fixes
This commit is contained in:
		@@ -132,8 +132,12 @@ class SolarNetworkConnect : JavaPlugin() {
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        // Send server start message
 | 
			
		||||
        destinationChatId?.let { chatId ->
 | 
			
		||||
            messageService?.sendMessage(chatId, messages["server_start"] ?: "🚀 Server started successfully")
 | 
			
		||||
        try {
 | 
			
		||||
            destinationChatId?.let { chatId ->
 | 
			
		||||
                messageService?.sendMessage(chatId, messages["server_start"] ?: "🚀 Server started successfully")
 | 
			
		||||
            }
 | 
			
		||||
        } catch (e: Exception) {
 | 
			
		||||
            logger.warning("Failed to send server start message: ${e.message}")
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -141,8 +145,12 @@ class SolarNetworkConnect : JavaPlugin() {
 | 
			
		||||
        logger.info(String.format("Disabled Version %s", description.version));
 | 
			
		||||
 | 
			
		||||
        // Send server stop message
 | 
			
		||||
        destinationChatId?.let { chatId ->
 | 
			
		||||
            messageService?.sendMessage(chatId, messages["server_stop"] ?: "⏹️ Server stopped")
 | 
			
		||||
        try {
 | 
			
		||||
            destinationChatId?.let { chatId ->
 | 
			
		||||
                messageService?.sendMessage(chatId, messages["server_stop"] ?: "⏹️ Server stopped")
 | 
			
		||||
            }
 | 
			
		||||
        } catch (e: Exception) {
 | 
			
		||||
            logger.warning("Failed to send server stop message: ${e.message}")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        sn?.disconnect()
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import net.md_5.bungee.api.chat.ClickEvent
 | 
			
		||||
import net.md_5.bungee.api.chat.TextComponent
 | 
			
		||||
import net.milkbowl.vault.economy.Economy
 | 
			
		||||
import net.milkbowl.vault.economy.EconomyResponse
 | 
			
		||||
import org.bukkit.Bukkit.getLogger
 | 
			
		||||
import org.bukkit.ChatColor
 | 
			
		||||
import org.bukkit.Sound
 | 
			
		||||
import org.bukkit.command.Command
 | 
			
		||||
@@ -13,7 +14,12 @@ import org.bukkit.command.CommandSender
 | 
			
		||||
import org.bukkit.command.TabCompleter
 | 
			
		||||
import org.bukkit.entity.Player
 | 
			
		||||
 | 
			
		||||
class SnCommand(private val sn: SnService, private val eco: Economy?, private val messages: Map<String, String>, private val playerSolarpassMap: MutableMap<String, String?>) :
 | 
			
		||||
class SnCommand(
 | 
			
		||||
    private val sn: SnService,
 | 
			
		||||
    private val eco: Economy?,
 | 
			
		||||
    private val messages: Map<String, String>,
 | 
			
		||||
    private val playerSolarpassMap: MutableMap<String, String?>
 | 
			
		||||
) :
 | 
			
		||||
    CommandExecutor {
 | 
			
		||||
    override fun onCommand(p0: CommandSender, p1: Command, p2: String, p3: Array<out String>): Boolean {
 | 
			
		||||
        if (p0 !is Player) {
 | 
			
		||||
@@ -45,6 +51,7 @@ class SnCommand(private val sn: SnService, private val eco: Economy?, private va
 | 
			
		||||
                    val order: SnOrder
 | 
			
		||||
                    try {
 | 
			
		||||
                        order = orderSrv.getOrder(orderNumber);
 | 
			
		||||
                        // The update validated the order is created by us
 | 
			
		||||
                        orderSrv.updateOrderStatus(orderNumber, false);
 | 
			
		||||
                    } catch (_: Exception) {
 | 
			
		||||
                        p0.sendMessage(
 | 
			
		||||
@@ -62,7 +69,7 @@ class SnCommand(private val sn: SnService, private val eco: Economy?, private va
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    val bal = order.amount.toDouble() * 100;
 | 
			
		||||
                    val bal = order.amount;
 | 
			
		||||
                    eco?.depositPlayer(p0.player, bal)
 | 
			
		||||
 | 
			
		||||
                    val doneComponent =
 | 
			
		||||
@@ -97,12 +104,13 @@ class SnCommand(private val sn: SnService, private val eco: Economy?, private va
 | 
			
		||||
 | 
			
		||||
                val order: SnOrder
 | 
			
		||||
                try {
 | 
			
		||||
                    order = orderSrv.createOrder("Deposit to Highland MC", amount / 100);
 | 
			
		||||
                } catch (_: Exception) {
 | 
			
		||||
                    order = orderSrv.createOrder("Deposit to GoatCraft", amount);
 | 
			
		||||
                } catch (e: Exception) {
 | 
			
		||||
                    p0.sendMessage(
 | 
			
		||||
                        ChatColor.RED.toString() + (messages["command_deposit_create_error"]
 | 
			
		||||
                            ?: "An error occurred while creating order. Try again later.")
 | 
			
		||||
                    )
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -116,7 +124,7 @@ class SnCommand(private val sn: SnService, private val eco: Economy?, private va
 | 
			
		||||
                val orderHintComponent =
 | 
			
		||||
                    TextComponent(
 | 
			
		||||
                        ChatColor.GRAY.toString() + (messages["command_deposit_order_created"]
 | 
			
		||||
                            ?: "Order created, number ") + ChatColor.WHITE + ChatColor.BOLD + "#${order.id}"
 | 
			
		||||
                            ?: "Order created, number ") + ChatColor.WHITE + ChatColor.BOLD + "#${order.id.take(6)}" + " "
 | 
			
		||||
                    )
 | 
			
		||||
                val followingComponent = TextComponent(
 | 
			
		||||
                    ChatColor.GRAY.toString() + (messages["command_deposit_to_payment_page"] ?: " to the payment page.")
 | 
			
		||||
@@ -166,8 +174,9 @@ class SnCommand(private val sn: SnService, private val eco: Economy?, private va
 | 
			
		||||
                        ?: "Making transaction, please stand by...")
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                val bal = amount / 100;
 | 
			
		||||
                val resp = eco?.withdrawPlayer(p0.player, "Withdraw to Source Point - $bal SRC", amount);
 | 
			
		||||
                // Takes extra 20% as fee
 | 
			
		||||
                val fee = amount * 0.2;
 | 
			
		||||
                val resp = eco?.withdrawPlayer(p0.player, amount + fee);
 | 
			
		||||
                if (resp?.type != EconomyResponse.ResponseType.SUCCESS) {
 | 
			
		||||
                    p0.sendMessage(
 | 
			
		||||
                        ChatColor.RED.toString() + (messages["command_withdraw_no_money"]
 | 
			
		||||
@@ -178,29 +187,28 @@ class SnCommand(private val sn: SnService, private val eco: Economy?, private va
 | 
			
		||||
 | 
			
		||||
                try {
 | 
			
		||||
                    val transactionSrv = SnBalanceService(sn);
 | 
			
		||||
                    val transaction = transactionSrv.addBalance(bal, "Withdraw from GoatCraft", accountId);
 | 
			
		||||
                    val transaction = transactionSrv.addBalance(amount, "Withdraw from GoatCraft", accountId);
 | 
			
		||||
                    val transactionHintComponent =
 | 
			
		||||
                        TextComponent(
 | 
			
		||||
                            ChatColor.GREEN.toString() + (messages["command_withdraw_done"]
 | 
			
		||||
                                ?: "Done! transaction number ") + ChatColor.WHITE + ChatColor.BOLD + "#${transaction.id}"
 | 
			
		||||
                                ?: "Done! transaction number ") + ChatColor.WHITE + ChatColor.BOLD + "#${
 | 
			
		||||
                                transaction.id.take(
 | 
			
		||||
                                    6
 | 
			
		||||
                                )
 | 
			
		||||
                            }"
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    p0.playSound(p0.player!!, Sound.BLOCK_ANVIL_PLACE, 1.0F, 1.0F)
 | 
			
		||||
                    p0.spigot().sendMessage(transactionHintComponent)
 | 
			
		||||
                } catch (_: Exception) {
 | 
			
		||||
                    eco?.depositPlayer(
 | 
			
		||||
                        p0.player,
 | 
			
		||||
                        (messages["command_withdraw_refund_reason"] ?: "Withdraw to Source Point Failed - Refund"),
 | 
			
		||||
                        amount
 | 
			
		||||
                    )
 | 
			
		||||
                } catch (e: Exception) {
 | 
			
		||||
                    eco.depositPlayer(p0.player, amount + fee)
 | 
			
		||||
                    p0.sendMessage(
 | 
			
		||||
                        ChatColor.RED.toString() + (messages["command_withdraw_error"]
 | 
			
		||||
                            ?: "An error occurred while making transaction. Make sure your wallet exists then try again later.")
 | 
			
		||||
                    )
 | 
			
		||||
                    e.printStackTrace()
 | 
			
		||||
                    return true
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            else -> {
 | 
			
		||||
 
 | 
			
		||||
@@ -50,16 +50,14 @@ data class SnOrder(
 | 
			
		||||
    @SerialName("deleted_at")
 | 
			
		||||
    val deletedAt: Instant? = null,
 | 
			
		||||
    val status: Long,
 | 
			
		||||
    val remark: String,
 | 
			
		||||
    val amount: String,
 | 
			
		||||
    val remarks: String,
 | 
			
		||||
    val amount: Double,
 | 
			
		||||
    @SerialName("payer_id")
 | 
			
		||||
    val payerID: Int? = null,
 | 
			
		||||
    val payerID: String? = null,
 | 
			
		||||
    @SerialName("payee_id")
 | 
			
		||||
    val payeeID: Int? = null,
 | 
			
		||||
    val payeeID: String? = null,
 | 
			
		||||
    @SerialName("transaction_id")
 | 
			
		||||
    val transactionID: Int? = null,
 | 
			
		||||
    @SerialName("client_id")
 | 
			
		||||
    val clientID: Long
 | 
			
		||||
    val transactionID: String? = null,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
class SnOrderService(private val sn: SnService) {
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ main: dev.solsynth.snConnect.SolarNetworkConnect
 | 
			
		||||
api-version: '1.21'
 | 
			
		||||
authors: [ LittleSheepOvO ]
 | 
			
		||||
description: Solar Network Connect provide features connect with Solar Network
 | 
			
		||||
loadbefore:
 | 
			
		||||
softdepend:
 | 
			
		||||
  - CMI
 | 
			
		||||
  - CMIEInjector
 | 
			
		||||
  - CMILib
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user