diff --git a/README.md b/README.md index 5bed4ab..ab54031 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ npm install prismarine-realms ### RealmAPI -#### .from(authflow: Authflow, platform: 'bedrock' | 'java') +#### .from(authflow: Authflow, platform: 'bedrock' | 'java', options: Options) Takes an **Authflow** instance from [prismarine-auth](https://github.com/PrismarineJS/prismarine-auth), you can see the documentation for this [here.](https://github.com/PrismarineJS/prismarine-auth#authflow) diff --git a/docs/API.md b/docs/API.md index 0105c1e..b2a7153 100644 --- a/docs/API.md +++ b/docs/API.md @@ -60,6 +60,11 @@ - [writeToDirectory](#writeToDirectory) - [getBuffer](#getBuffer) +## Options +Used for `RealmAPI.from()` +| Param | Type | Description | +| --------------- | -------------------- | --------------------------------------------------------------------- | +| usePreview | `Boolean` | If the Preview Realms API should be used (Only bedrock) | --- ## Constructor @@ -70,7 +75,7 @@ const { RealmAPI } = require('prismarine-realms') const authflow = new Authflow() -const api = RealmAPI.from(authflow, 'bedrock' | 'java') +const api = RealmAPI.from(authflow, 'bedrock' | 'java', options) ``` --- diff --git a/index.d.ts b/index.d.ts index d3eb97e..3bfe840 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,15 +2,21 @@ import { Authflow } from "prismarine-auth"; declare module 'prismarine-realms' { + export class Options { + skipAuth?: Boolean + maxRetries?: Number + usePreview?: Boolean // Bedrock only + } + export class RealmAPI { /** * Creates a new RealmAPI instance, which handles and authenticates calls to the Realms API * @param authflow An Authflow instance from [prismarine-auth](https://github.com/PrismarineJS/prismarine-auth). * @param platform Which platforms API to access */ - constructor(authflow: Authflow, platform: 'bedrock' | 'java') + constructor(authflow: Authflow, platform: 'bedrock' | 'java', options?: Options) - static from(authflow: Authflow, platform: 'bedrock' | 'java'): BedrockRealmAPI | JavaRealmAPI + static from(authflow: Authflow, platform: 'bedrock' | 'java', options?: Options): BedrockRealmAPI | JavaRealmAPI getRealms(): Promise getRealm(realmId: string): Promise diff --git a/src/rest.js b/src/rest.js index fea2031..f2719c2 100644 --- a/src/rest.js +++ b/src/rest.js @@ -43,6 +43,13 @@ module.exports = class Rest { 'User-Agent': this.userAgent } + // Minecraft Bedrock has two types of realms: Regular and Preview + // Regular realms can be only be accessed by the normal MCBE client, and Preview realms can only be accessed by the Preview (Beta) MCBE Client + // These versions have completely different worlds attached + if (this.options.usePreview && this.platform === 'bedrock') { + headers['is-prerelease'] = true + } + if (!this.options.skipAuth) { const [key, value] = await this.getAuth() headers[key] = value