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