Compare commits

...

3 Commits

Author SHA1 Message Date
80d58ea4e2 🐛 Fix join first 2025-10-06 12:06:57 +08:00
770a58fb1d 🐛 Fix bugs 2025-10-06 03:22:38 +08:00
1862ce4f65 🔇 Toggable websocket packet 2025-10-06 01:00:53 +08:00
6 changed files with 9 additions and 17 deletions

View File

@@ -39,7 +39,8 @@ 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) {
logger.info("Received WebSocket packet: type=${packet.type}") if (config.getBoolean("debug"))
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 {
when (packet.type) { when (packet.type) {

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

@@ -27,9 +27,8 @@ class SnChatListener(
@Suppress("SENSELESS_COMPARISON") @Suppress("SENSELESS_COMPARISON")
@EventHandler() @EventHandler()
fun onPlayerJoin(event: PlayerJoinEvent) { fun onPlayerJoin(event: PlayerJoinEvent) {
val user = CMI.getInstance().playerManager.getUser(event.player); val firstTime = Bukkit.getOfflinePlayer(event.player.uniqueId) == null;
val firstTime = user.playerTime == 0L; val templateKey = if (!firstTime) "join" else "join_first";
val templateKey = if (!firstTime) "join" else "joinFirst";
val template = messages[templateKey] val template = messages[templateKey]
?: if (!firstTime) "➡️ {player} joined the game." else "➡️ {player} first time joined the game." ?: if (!firstTime) "➡️ {player} joined the game." else "➡️ {player} first time joined the game."
val message = template.replace("{player}", event.player.name) val message = template.replace("{player}", event.player.name)

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
} }
} }
} }

View File

@@ -1,5 +1,5 @@
join: "➡️ {player} joined the game." join: "➡️ {player} joined the game."
joinFirst: "➡️ {player} first time joined the game." join_first: "➡️ {player} first time joined the game."
quit: "⬅️ {player} left the game." quit: "⬅️ {player} left the game."
death: "💀 {player} {message}" death: "💀 {player} {message}"
advancement: "🎉 {player} unlocked advancement: {advancement}" advancement: "🎉 {player} unlocked advancement: {advancement}"

View File

@@ -1,5 +1,5 @@
join: "➡️ {player} 加入了游戏。" join: "➡️ {player} 加入了游戏。"
joinFirst: "➡️ {player} 首次加入了游戏。" join_first: "➡️ {player} 首次加入了游戏。"
quit: "⬅️ {player} 离开了游戏。" quit: "⬅️ {player} 离开了游戏。"
death: "💀 {player} {message}" death: "💀 {player} {message}"
advancement: "🎉 {player} 解锁成就:{advancement}" advancement: "🎉 {player} 解锁成就:{advancement}"