Skip to content

Commit

Permalink
minecraft: Read serverSubName from index 7 & append trailing 0 to pon…
Browse files Browse the repository at this point in the history
…g data (#231)
  • Loading branch information
HashimTheArab authored Aug 2, 2024
1 parent 39e4906 commit 1d84b30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions minecraft/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)))
}

Expand Down
2 changes: 1 addition & 1 deletion minecraft/server_status_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down

0 comments on commit 1d84b30

Please sign in to comment.