From 1d84b30b52ad14036857b8b90d39d22cb32d54d6 Mon Sep 17 00:00:00 2001 From: Hashim Date: Fri, 2 Aug 2024 09:28:13 -0400 Subject: [PATCH] minecraft: Read serverSubName from index 7 & append trailing 0 to pong data (#231) --- minecraft/listener.go | 5 +++-- minecraft/server_status_provider.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/minecraft/listener.go b/minecraft/listener.go index e2c58414..001860bb 100644 --- a/minecraft/listener.go +++ b/minecraft/listener.go @@ -210,9 +210,10 @@ func (listener *Listener) Close() error { // server name of the listener, provided the listener isn't currently hijacking the pong of another server. func (listener *Listener) updatePongData() { s := listener.status() - listener.listener.PongData([]byte(fmt.Sprintf("MCPE;%v;%v;%v;%v;%v;%v;%s;%v;%v;%v;%v;", + listener.listener.PongData([]byte(fmt.Sprintf("MCPE;%v;%v;%v;%v;%v;%v;%v;%v;%v;%v;%v;%v;", s.ServerName, protocol.CurrentProtocol, protocol.CurrentVersion, s.PlayerCount, s.MaxPlayers, - listener.listener.ID(), listener.status().ServerSubName, "Creative", 1, listener.Addr().(*net.UDPAddr).Port, listener.Addr().(*net.UDPAddr).Port, + listener.listener.ID(), s.ServerSubName, "Creative", 1, listener.Addr().(*net.UDPAddr).Port, listener.Addr().(*net.UDPAddr).Port, + 0, ))) } diff --git a/minecraft/server_status_provider.go b/minecraft/server_status_provider.go index 317fd911..6710ba22 100644 --- a/minecraft/server_status_provider.go +++ b/minecraft/server_status_provider.go @@ -126,7 +126,7 @@ func parsePongData(pong []byte) ServerStatus { return ServerStatus{ServerName: "Invalid pong data"} } serverName := frag[1] - serverSubName := frag[6] + serverSubName := frag[7] online, err := strconv.Atoi(frag[4]) if err != nil { return ServerStatus{ServerName: "Invalid player count"}