From 30a7f3edf0dbe7eb870334701a291dbdbf6be0bb Mon Sep 17 00:00:00 2001 From: Alexander Zielonka Date: Thu, 15 Jan 2026 14:19:04 +0100 Subject: [PATCH] Fix Hytale player detection with correct log patterns - Join: [World|*] Player 'Name' joined world ... (UUID) - Leave: [PlayerSystems] Removing player 'Name (Name)' from world ... (UUID) Co-Authored-By: Claude Opus 4.5 --- gsm-backend/services/ssh.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gsm-backend/services/ssh.js b/gsm-backend/services/ssh.js index ff1f778..d90e18c 100644 --- a/gsm-backend/services/ssh.js +++ b/gsm-backend/services/ssh.js @@ -660,16 +660,16 @@ export async function getHytalePlayers(server) { const logFile = logFileResult.stdout.trim(); // Parse log for player joins and disconnects - // Join pattern: [Universe|P] Adding player 'PlayerName (UUID) - // Disconnect pattern: Search for connection closed or player removed - const result = await ssh.execCommand(`grep -E "\\[Universe\\|P\\] Adding player|Removing player|Connection.*closed|disconnect" ${logFile} 2>/dev/null | tail -200`); + // Join: [World|default] Player 'Alex47' joined world 'default' at location ... (UUID) + // Leave: [PlayerSystems] Removing player 'Alex47 (Alex47)' from world 'default' (UUID) + const result = await ssh.execCommand(`grep -E "\\[World\\|.*\\] Player .* joined world|\\[PlayerSystems\\] Removing player" ${logFile} 2>/dev/null | tail -200`); const players = new Map(); // UUID -> PlayerName const lines = result.stdout.split('\n'); for (const line of lines) { - // Check for player join - const joinMatch = line.match(/\[Universe\|P\] Adding player '([^']+) \(([a-f0-9-]+)\)/i); + // Check for player join: [World|default] Player 'Name' joined world ... (uuid) + const joinMatch = line.match(/\[World\|[^\]]+\] Player '([^']+)' joined world .* \(([a-f0-9-]+)\)/i); if (joinMatch) { const playerName = joinMatch[1]; const uuid = joinMatch[2]; @@ -677,10 +677,11 @@ export async function getHytalePlayers(server) { continue; } - // Check for player disconnect (various patterns) - const disconnectMatch = line.match(/Removing player.*\(([a-f0-9-]+)\)/i); - if (disconnectMatch) { - players.delete(disconnectMatch[1]); + // Check for player leave: [PlayerSystems] Removing player 'Name (Name)' from world ... (uuid) + const leaveMatch = line.match(/\[PlayerSystems\] Removing player '([^']+) \([^)]+\)' from world .* \(([a-f0-9-]+)\)/i); + if (leaveMatch) { + const uuid = leaveMatch[2]; + players.delete(uuid); } }