Compare commits

...

2 Commits

Author SHA1 Message Date
770a58fb1d 🐛 Fix bugs 2025-10-06 03:22:38 +08:00
1862ce4f65 🔇 Toggable websocket packet 2025-10-06 01:00:53 +08:00
3 changed files with 5 additions and 12 deletions

View File

@@ -39,6 +39,7 @@ class SolarNetworkConnect : JavaPlugin() {
private var playerSolarpassMap: MutableMap<String, String?> = mutableMapOf() private var playerSolarpassMap: MutableMap<String, String?> = mutableMapOf()
private fun handleWebSocketPacket(packet: WebSocketPacket) { private fun handleWebSocketPacket(packet: WebSocketPacket) {
if (config.getBoolean("debug"))
logger.info("Received WebSocket packet: type=${packet.type}") logger.info("Received WebSocket packet: type=${packet.type}")
if (packet.type.startsWith("messages") && packet.data != null) { if (packet.type.startsWith("messages") && packet.data != null) {
try { try {

View File

@@ -187,15 +187,11 @@ class SnCommand(
try { try {
val transactionSrv = SnBalanceService(sn); val transactionSrv = SnBalanceService(sn);
val transaction = transactionSrv.addBalance(amount, "Withdraw from GoatCraft", accountId); 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 + "#${ ?: "Done! ")
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)

View File

@@ -47,7 +47,7 @@ class SnBalanceService(private val sn: SnService) {
ignoreUnknownKeys = true ignoreUnknownKeys = true
} }
fun addBalance(amount: Double, remark: String, accountID: String): SnTransaction { fun addBalance(amount: Double, remark: String, accountID: String) {
val body = SnTransactionRequest( val body = SnTransactionRequest(
amount = amount, amount = amount,
remark = remark, remark = remark,
@@ -65,10 +65,6 @@ class SnBalanceService(private val sn: SnService) {
sn.client.newCall(request).execute().use { response -> sn.client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response") if (!response.isSuccessful) throw IOException("Unexpected code $response")
val responseBody = response.body!!.string()
val out = json.decodeFromString<SnTransaction>(responseBody)
return out
} }
} }
} }