diff --git a/docs/API.md b/docs/API.md index 23de8f1..a38da60 100644 --- a/docs/API.md +++ b/docs/API.md @@ -10,7 +10,7 @@ Returns a `Client` instance and connects to the server. | ----------- | ----------- |-| | host | **Required** | host to connect to, for example `127.0.0.1`. | | port | *optional* | port to connect to, default to **19132** | -| version | *optional* | Version to connect as.
(Future feature, see [#69][1]) If not specified, should automatically match server version.
(Current feature) Defaults to latest version. | +| version | *optional* | Version to connect as. If not specified, automatically match server version. | | offline | *optional* | default to **false**. Set this to true to disable Microsoft/Xbox auth. | | username | Conditional | Required if `offline` set to true : Username to connect to server as. | | authTitle | *optional* | The title ID to connect as, see the README for usage. | @@ -160,5 +160,3 @@ relay.on('connect', player => { ``` 'Relay' emits 'clientbound' and 'serverbound' events, along with the data for the outgoing packet that can be modified. You can send a packet to the client with `player.queue()` or to the backend server with `player.upstream.queue()`. - -[1]: https://github.com/PrismarineJS/bedrock-protocol/issues/69 diff --git a/index.d.ts b/index.d.ts index e1187ca..e47c35c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -22,7 +22,9 @@ declare module "bedrock-protocol" { // The view distance in chunks viewDistance?: number, // Specifies which game edition to sign in as. Optional, but some servers verify this. - authTitle?: title | string + authTitle?: title | string, + // whether to skip initial ping and immediately connect + skipPing?: boolean } export interface ServerOptions extends Options { diff --git a/src/createClient.js b/src/createClient.js index 50009be..f8e205a 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -4,7 +4,7 @@ const assert = require('assert') const advertisement = require('./server/advertisement') const { sleep } = require('./datatypes/util') -/** @param {{ version?: number, host: string, port?: number, connectTimeout?: number }} options */ +/** @param {{ version?: number, host: string, port?: number, connectTimeout?: number, skipPing?: boolean }} options */ function createClient (options) { assert(options) const client = new Client({ port: 19132, ...options }) @@ -15,7 +15,7 @@ function createClient (options) { client.ping().then(data => { const advert = advertisement.fromServerName(data) console.log(`Connecting to server ${advert.motd} (${advert.name}), version ${advert.version}`) - // TODO: update connect version based on ping response + client.version = options.version ?? advert.version connect(client) }, client) }