Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions src/MinecraftQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,29 @@ private function GetBedrockStatus( )

// TODO: What are the 2 bytes after the magic?
$Data = \substr( $Data, 35 );

// TODO: If server-name contains a ';' it is not escaped, and will break this parsing
$Data = \explode( ';', $Data );

$this->Info =
[
$offset = \count($data) - 13;
$Info = [
'GameName' => $Data[ 0 ] ?? null,
'HostName' => $Data[ 1 ] ?? null,
'Protocol' => $Data[ 2 ] ?? null,
'Version' => $Data[ 3 ] ?? null,
'Players' => isset( $Data[ 4 ] ) ? (int)$Data[ 4 ] : 0,
'MaxPlayers' => isset( $Data[ 5 ] ) ? (int)$Data[ 5 ] : 0,
'ServerId' => $Data[ 6 ] ?? null,
'Map' => $Data[ 7 ] ?? null,
'GameMode' => $Data[ 8 ] ?? null,
'NintendoLimited' => $Data[ 9 ] ?? null,
'IPv4Port' => isset( $Data[ 10 ] ) ? (int)$Data[ 10 ] : 0,
'IPv6Port' => isset( $Data[ 11 ] ) ? (int)$Data[ 11 ] : 0,
'Extra' => $Data[ 12 ] ?? null, // What is this?
'HostName' => [],
'Protocol' => $Data[ 2+$offset ] ?? null,
'Version' => $Data[ 3+$offset ] ?? null,
'Players' => isset( $Data[ 4+$offset ] ) ? (int)$Data[ 4+$offset ] : 0,
'MaxPlayers' => isset( $Data[ 5+$offset ] ) ? (int)$Data[ 5+$offset ] : 0,
'ServerId' => $Data[ 6+$offset ] ?? null,
'Map' => $Data[ 7+$offset ] ?? null,
'GameMode' => $Data[ 8+$offset ] ?? null,
'NintendoLimited' => $Data[ 9+$offset ] ?? null,
'IPv4Port' => isset( $Data[ 10+$offset ] ) ? (int)$Data[ 10+$offset ] : 0,
'IPv6Port' => isset( $Data[ 11+$offset ] ) ? (int)$Data[ 11+$offset ] : 0,
'Extra' => $Data[ 12+$offset ] ?? null, // What is this?
];

for ($i = 0; $i <= $offset; $i++)
$Info['HostName'][] = $Data[ 1+$i ];

$Info['HostName'] = implode( ';', $Info['HostName'] );
$this->Info = $Info;
$this->Players = null;
}

Expand Down