From c735604c38cb1c230100f5d7876aa5163d223cc1 Mon Sep 17 00:00:00 2001 From: xzeldon Date: Sat, 30 Mar 2024 16:41:42 +0300 Subject: [PATCH] fix: #5 add gameVersion field for Bedrock Add gameVersion field in BedrockPingResponse Closes: #5 --- lib/bedrock.js | 7 +++++-- types/lib/bedrock.d.ts | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/bedrock.js b/lib/bedrock.js index f100e75..c1426d6 100644 --- a/lib/bedrock.js +++ b/lib/bedrock.js @@ -40,7 +40,7 @@ const readStringFromBuffer = (buffer, offset) => { */ const parseAdvertiseString = (advertiseStr) => { const parts = advertiseStr.split(';'); - return { + const parsedParts = { gameId: parts[0], description: parts[1], protocolVersion: parts[2], @@ -50,6 +50,8 @@ const parseAdvertiseString = (advertiseStr) => { name: parts[7], mode: parts[8] }; + + return parsedParts; }; /** @@ -144,8 +146,9 @@ const ping = (host, port = 19132, cb, timeout = 5000) => { case 0x1c: { const pong = UNCONNECTED_PONG(msg); const clientData = { + name: pong.name, version: { - name: pong.name, + gameVersion: pong.gameVersion, protocol: pong.protocolVersion }, players: { diff --git a/types/lib/bedrock.d.ts b/types/lib/bedrock.d.ts index cf8e823..127e446 100644 --- a/types/lib/bedrock.d.ts +++ b/types/lib/bedrock.d.ts @@ -8,8 +8,9 @@ export type BedrockPingOptions = { }; export type BedrockPingResponse = { + name: string; version: { - name: string; + gameVersion: string; protocol: string; }; players: {