From 90d12fa6969390ec47b27e0d719b317dcc04fa22 Mon Sep 17 00:00:00 2001 From: JammSpread <61063879+JammSpread@users.noreply.github.com> Date: Fri, 11 Jun 2021 18:45:54 -0400 Subject: [PATCH] fix: type definition errors found related to ServerAdvertisements. (#103) * fix: online/max player count type definition. Fixes the type definition of the online/max players to be an immediate child of the ServerAdvertisement class so that it can be accessed properly on TypeScript. Signed-off-by: JK * feat: implement advertisementFn type definition. Adds the type definition for the 'advertisementFn' server option. Signed-off-by: JK * fix: minor advertisementFn typo in API docs. Fixes a minor typo found in the API docs that misspells 'advertisementFn' as 'advertismentFn'. Signed-off-by: JK * feat: add skipPing to the API docs. Adds the 'skipPing' client option to the API docs. Signed-off-by: JK * feat: add connectTimeout type definition. Adds the 'connectTimeout' client option to the package type definitions. Signed-off-by: JK --- docs/API.md | 5 +++-- index.d.ts | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/API.md b/docs/API.md index a38da60..051ea09 100644 --- a/docs/API.md +++ b/docs/API.md @@ -17,7 +17,8 @@ Returns a `Client` instance and connects to the server. | connectTimeout | *optional* | default to **9000ms**. How long to wait in milliseconds while trying to connect to server. | | onMsaCode | *optional* | Callback called when signing in with a microsoft account with device code auth, `data` is an object documented [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code#device-authorization-response) | | profilesFolder | *optional* | Where to store cached authentication tokens. Defaults to .minecraft, or the node_modules folder if not found. | -| autoInitPlayer | optional | default to true, If we should send SetPlayerInitialized to the server after getting play_status spawn. | +| autoInitPlayer | *optional* | default to true, If we should send SetPlayerInitialized to the server after getting play_status spawn. | +| skipPing | *optional* | Whether pinging the server to check its version should be skipped. | ## be.createServer(options) : Server @@ -36,7 +37,7 @@ authenticated unless offline is set to true. | maxPlayers | *optional* | default to **3**. Set this to change the maximum number of players connected. | | kickTimeout | *[Future][1]* | How long to wait before kicking a unresponsive client. | | motd | *optional* | The "message of the day" for the server, the message shown to players in the server list. See usage below. | -| advertismentFn | *optional* | optional. Custom function to call that should return a ServerAdvertisement, used for setting the RakNet server PONG data. Overrides `motd`. | +| advertisementFn | *optional* | optional. Custom function to call that should return a ServerAdvertisement, used for setting the RakNet server PONG data. Overrides `motd`. | ## be.ping({ host, port }) : ServerAdvertisement diff --git a/index.d.ts b/index.d.ts index 34fee07..d59c8fd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -23,6 +23,8 @@ declare module "bedrock-protocol" { viewDistance?: number, // Specifies which game edition to sign in as. Optional, but some servers verify this. authTitle?: title | string, + // How long to wait in milliseconds while trying to connect to the server. + connectTimeout?: number // whether to skip initial ping and immediately connect skipPing?: boolean } @@ -36,6 +38,7 @@ declare module "bedrock-protocol" { // The sub-header for the MOTD shown in the server list. levelName: string } + advertisementFn: () => ServerAdvertisement } enum ClientStatus { @@ -145,10 +148,8 @@ declare module "bedrock-protocol" { name: string protocol: number version: string - players: { - online: number, - max: number - } + playersOnline: number + playersMax: number gamemode: string serverId: string }