From 866ce6af503c29ecb29e9b4a3dfe05191ef34a1a Mon Sep 17 00:00:00 2001 From: Ian Tapply Date: Fri, 12 Jan 2024 17:39:54 -0500 Subject: [PATCH] Expand API and expose more realm config data (#40) * Added near full coverage of bedrock realm API (missing misc) * Removed some unneeded returning of realm object Copied bedrock realm API functions that also apply to Java over to Java Updated Realm object and BedrockRealmAPI class * Fixed linting failure * Renamed texture pack required function Removed removeAllRealmPlayers function due to invalid request Added params to methods in Realm.js Created tests and responses for the new functions Added documentation for the new functions * Removed removeAllRealmPlayers from table of contents * Renamed removeRealmInvite function Fixed body of userPermission request Moved functions that are the same into RealmAPI class Renamed removePlayerFromRealm uuid param to xuid * Made detailed a param for getSubscriptionInfo Changed configuration parameter to be an Object instead of a String * No need for a custom configuration constructor * Fixed missing type returns in index.ts Updated docs to reflect type changes Formatted what functions return to reflect their custom types * Fixed lint fail * Fixed failing tests * comment out changeRealmConfiguration method --------- Co-authored-by: extremeheat --- docs/API.md | 354 ++++++++++++++++++++++++++++++++++++- index.d.ts | 84 ++++++--- src/bedrock/api.js | 88 ++++++++- src/index.js | 43 +++++ src/java/api.js | 4 - src/structures/Realm.js | 16 ++ test/bedrockAPI.js | 274 +++++++++++++++++++++++++++- test/common/responses.json | 16 +- 8 files changed, 837 insertions(+), 42 deletions(-) diff --git a/docs/API.md b/docs/API.md index cb1fefc..0105c1e 100644 --- a/docs/API.md +++ b/docs/API.md @@ -10,6 +10,9 @@ | username | `string` | The username of player | | uuid | `string` | The unique ID of the player, without hyphens | | xuid | `string` | The Xbox User ID of the targeted player | +| configuration | `string` | The array of configurations that can change gamerules and Realm features | +| slotId | `string` | The ID of one of the Realm world slots. This value can be either 1, 2, or 3 | +| permission | `string` | The permission that can be added to a players. This can resolve to VISITOR, MEMBER, or OPERATOR | ## Table of Contents - [Bedrock & Java](#bedrock--java) @@ -25,15 +28,31 @@ - [getPendingInviteCount](#getpendinginvitecount) - [getPendingInvites](#getpendinginvites) - [acceptRealmInvitation](#acceptrealminvitation) + - [acceptRealmInviteFromCode](#acceptrealminvitefromcode) - [rejectRealmInvitation](#rejectrealminvitation) + - [removePlayerFromRealm](#removeplayerfromrealm) + - [resetRealm](#resetrealm) + + - [opRealmPlayer](#oprealmplayer) + - [deopRealmPlayer](#deoprealmplayer) + - [banPlayerFromRealm](#banplayerfromrealm) + - [unbanPlayerFromRealm](#unbanplayerfromrealm) + - [removeRealmFromJoinedList](#removerealmfromjoinedlist) + - [changeIsTexturePackRequired](#changeistexturepackrequired) + - [changeRealmDefaultPermission](#changerealmdefaultpermission) + - [changeRealmPlayerPermission](#changerealmplayerpermission) - [Structures](#structures) - [Realm](#realm) - [getAddress](#getaddress) - [invitePlayer](#inviteplayer) - [open](#open) - [close](#close) + - [delete](#delete) - [getBackups](#getbackups) - [getWorldDownload](#getworlddownload) + - [getSubscriptionInfo](#getsubscriptioninfo) + - [changeActiveSlot](#changeactiveslot) + - [changeNameAndDescription](#changenameanddescription) - [Backup](#backup) - [getDownload](#getDownload) - [restore](#restore) @@ -116,7 +135,7 @@ await api.getRealmBackups('1234567', '1') ### restoreRealmFromBackup -(realmId: string, slotId: string, backupId: string) => Promise\ +(realmId: string, slotId: string, backupId: string) => Promise\ Restores a Realm from a backup @@ -124,7 +143,7 @@ Restores a Realm from a backup await api.restoreRealmFromBackup('1234567', '1', '1970-01-01T00:00:00.000Z') ``` -No output +Either 'Retry again later' or 'true'. Always seems to return 'Retry again later' on the first try. --- @@ -287,8 +306,29 @@ Accepts a pending invite for the authenticating account await api.acceptRealmInvitation('1234567') ``` +Output + No output + + +--- + +### acceptRealmInviteFromCode + +(realmInviteCode: string) => Promise\ + +Accepts a Realm invite from an invite link or code. +```js +await api.acceptRealmInviteFromCode('1234567') +``` + +Output + +[Realm](#realm) + + + --- ### rejectRealmInvitation @@ -301,8 +341,223 @@ Rejects a pending invite for the authenticating account await api.rejectRealmInvitation('1234567') ``` +
+Output + +No output + +
+ +--- + +### removePlayerFromRealm + +(realmId: string, xuid: string) => Promise\ + +Removes a player from the Realm + +```js +await api.removePlayerFromRealm('1234567', 'a8005260a332457097a50bdbe48a9a21') +``` + +
+Output + +[Realm](#realm) + +
+ +--- + +### resetRealm + +(realmId: string) => Promise\ + +Resets a Realm to its default, or brand new state + +```js +await api.resetRealm('1234567') +``` + +
+Output + No output +
+ +--- + +--- + +### opRealmPlayer + +(realmId: string, uuid: string) => Promise\ + +OPs a player on the Realm + +```js +await api.opRealmPlayer('1234567', 'a8005260a332457097a50bdbe48a9a21') +``` + +
+Output + +[Realm](#realm) + +
+ +--- + +### deopRealmPlayer + +(realmId: string, uuid: string) => Promise\ + +DEOPs a player on the Realm + +```js +await api.deopRealmPlayer('1234567', 'a8005260a332457097a50bdbe48a9a21') +``` + +
+Output + +[Realm](#realm) + +
+ +--- + +### banPlayerFromRealm + +(realmId: string, uuid: string) => Promise\ + +Bans a player from the Realm + +```js +await api.banPlayerFromRealm('1234567', 'a8005260a332457097a50bdbe48a9a21') +``` + +
+Output + +No output + +
+ +--- + +### unbanPlayerFromRealm + +(realmId: string, uuid: string) => Promise\ + +Unbans a player from the Realm + +```js +await api.unbanPlayerFromRealm('1234567', 'a8005260a332457097a50bdbe48a9a21') +``` + +
+Output + +No output + +
+ +--- + +### removeRealmFromJoinedList + +(realmId: string) => Promise\ + +Removes the Realm from your joined list + +```js +await api.removeRealmFromJoinedList('1234567') +``` + +
+Output + +No output + +
+ +--- + +### changeIsTexturePackRequired + +(realmId: string, forced: boolean) => Promise\ + +Changes if a texture pack is required to be applied when joining + +```js +await api.changeIsTexturePackRequired('1234567', true) +``` + +
+Output + +No output + +
+ +--- + +### changeRealmDefaultPermission + +(realmId: string, permission: string) => Promise\ + +Changes the Realms default permission. Permission can be VISITOR, MEMBER, or OPERATOR + +```js +await api.changeRealmDefaultPermission('1234567', 'MEMBER') +``` + +
+Output + +No output + +
+ +--- + +### changeRealmPlayerPermission + +(realmId: string, permission: string, uuid: string) => Promise\ + +Changes the a players permission. Permission can be VISITOR, MEMBER, or OPERATOR + +```js +await api.changeRealmPlayerPermission('1234567', 'MEMBER', 'a8005260a332457097a50bdbe48a9a21') +``` + +
+Output + +No output + +
+ --- ## Structures @@ -407,7 +662,7 @@ await realm.invitePlayer('a8005260a332457097a50bdbe48a9a21', 'Steve') #### open -() => Promise\ +() => Promise\ Opens a Realm. Allows players to join @@ -415,13 +670,13 @@ Opens a Realm. Allows players to join await realm.open() ``` -No output +True if the world has opened --- #### close -() => Promise\ +() => Promise\ Closes a Realm. Removes all current players and restricts joining @@ -429,6 +684,20 @@ Closes a Realm. Removes all current players and restricts joining await realm.close() ``` +True if the world has closed + +--- + +#### delete + +() => Promise\ + +Deletes a Realm. This removes all worlds and the Realm itself beyond recovery + +```js +await realm.delete() +``` + No output --- @@ -471,6 +740,81 @@ await realm.getWorldDownload() --- +#### getSubscriptionInfo + +(detailed: boolean) => Promise\ + +Gets the subscription info of the Realm + +```js +await realm.getSubscriptionInfo(true) +``` + +
+Output + +```ts +Basic Subscription Info: +{ + startDate: number + daysLeft: number + subscriptionType: string +} + +Detailed Subscription Info: +{ + type: string + store: string + startDate: number + endDate: number + renewalPeriod: number + daysLeft: number + subscriptionId: string +} +``` + +
+ +--- + +#### changeActiveSlot + +(realmId: string, slotId, number) => Promise\ + +Changes the active world slot. Slot ID can be 1, 2, or 3 (or 4 for Java Edition) + +```js +await realm.changeActiveSlot('1234567', 1) +``` + +
+Output + +True if the active world is changed + +
+ +--- + +#### changeNameAndDescription + +(realmId: string, name: string, description: string) => Promise\ + +Changes the name and description of the Realm + +```js +await realm.changeNameAndDescription('1234567', 'Hello', 'World!') +``` + +
+Output + +No output + +
+ +--- + ### Backup ```js diff --git a/index.d.ts b/index.d.ts index 8e6b69f..d3eb97e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -10,15 +10,19 @@ declare module 'prismarine-realms' { */ constructor(authflow: Authflow, platform: 'bedrock' | 'java') - static from(authflow: Authflow, platform: 'bedrock' | 'java'): BedrockRealmAPI | JavaRealmAPI + static from(authflow: Authflow, platform: 'bedrock' | 'java'): BedrockRealmAPI | JavaRealmAPI getRealms(): Promise getRealm(realmId: string): Promise getRealmAddress(realmId: string): Promise
getRealmBackups(realmId: string, slotId: string): Promise getRealmWorldDownload(realmId: string, slotId: string, backupId?: string | 'latest'): Promise - restoreRealmFromBackup(realmId: string, slotId: string, backupId: string): Promise - changeRealmState(realmId: string, state: 'open' | 'close'): Promise + restoreRealmFromBackup(realmId: string, slotId: string, backupId: string): Promise + changeRealmState(realmId: string, state: 'open' | 'close'): Promise + getRealmSubscriptionInfo(realmId: string, detailed: boolean): Promise + changeRealmActiveSlot(realmId: string, slotId: number): Promise + changeRealmNameAndDescription(realmId: string, name: string, description: string): Promise + deleteRealm(realmId: string): Promise } @@ -31,7 +35,18 @@ declare module 'prismarine-realms' { getPendingInvites(): Promise acceptRealmInvitation(invitationId: string): Promise rejectRealmInvitation(invitationId: string): Promise - acceptRealmInviteFromCode(realmInviteCode: string): Promise + acceptRealmInviteFromCode(realmInviteCode: string): Promise + resetRealm(realmId: string): Promise + // changeRealmConfiguration(realmId: string, configuration: any): Promise + removePlayerFromRealm(realmId: string, xuid: string): Promise + opRealmPlayer(realmId: string, uuid: string): Promise + deopRealmPlayer(realmId: string, uuid: string): Promise + banPlayerFromRealm(realmId: string, uuid: string): Promise + unbanPlayerFromRealm(realmId: string, uuid: string): Promise + removeRealmFromJoinedList(realmId: string): Promise + changeIsTexturePackRequired(realmId: string, forced: boolean): Promise + changeRealmDefaultPermission(realmId: string, permission: string): Promise + changeRealmPlayerPermission(realmId: string, permission: string, uuid: string): Promise } export class JavaRealmAPI extends RealmAPI { @@ -41,10 +56,14 @@ declare module 'prismarine-realms' { export interface Realm { getAddress(): Promise
invitePlayer(uuid: string, name: string): Promise - open(): Promise - close(): Promise + open(): Promise + close(): Promise + delete(): Promise getBackups(): Promise getWorldDownload(): Promise + getSubscriptionInfo(): Promise + changeActiveSlot(): Promise + changeNameAndDescription(): Promise id: number remoteSubscriptionId: string owner: string | null @@ -77,16 +96,16 @@ declare module 'prismarine-realms' { lastModifiedDate: number size: number metadata: { - gameDifficulty: string - name: string - gameServerVersion: string - enabledPacks: { - resourcePack: string - behaviorPack: string - } - description: string | null - gamemode: string - worldType: string + gameDifficulty: string + name: string + gameServerVersion: string + enabledPacks: { + resourcePack: string + behaviorPack: string + } + description: string | null + gamemode: string + worldType: string } } @@ -101,6 +120,22 @@ declare module 'prismarine-realms' { token?: string // Bedrock only } + export interface RealmSubscriptionInfo { + startDate: number + daysLeft: number + subscriptionType: string + } + + export interface RealmSubscriptionInfoDetailed { + type: string + store: string + startDate: number + endDate: number + renewalPeriod: number + daysLeft: number + subscriptionId: string + } + export interface RealmPlayerInvite { invitationId: string worldName: string @@ -120,22 +155,21 @@ declare module 'prismarine-realms' { } export interface RealmPlayer { - uuid: string, - name: string, - operator: boolean, - accepted: boolean, - online: boolean, - permission: string + uuid: string, + name: string, + operator: boolean, + accepted: boolean, + online: boolean, + permission: string } export interface Slot { - options: string - slotId: number + options: string + slotId: number } export interface Address { host: string port: number } - } diff --git a/src/bedrock/api.js b/src/bedrock/api.js index 247dd5d..969122b 100644 --- a/src/bedrock/api.js +++ b/src/bedrock/api.js @@ -76,7 +76,8 @@ module.exports = class BedrockRealmAPI extends RealmAPI { async acceptRealmInviteFromCode (inviteCode) { if (!inviteCode) throw new Error('Need to provide a realm invite code/link') const clean = inviteCode.replace(/https:\/\/realms.gg\//g, '') - await this.rest.post(`/invites/v1/link/accept/${clean}`) + const data = await this.rest.post(`/invites/v1/link/accept/${clean}`) + return new Realm(this, data) } async invitePlayer (realmId, uuid) { @@ -90,12 +91,89 @@ module.exports = class BedrockRealmAPI extends RealmAPI { return new Realm(this, data) } - async changeRealmState (realmId, state) { - return await this.rest.put(`/worlds/${realmId}/${state}`) - } - async getRealmWorldDownload (realmId, slotId, backupId = 'latest') { const data = await this.rest.get(`/archive/download/world/${realmId}/${slotId}/${backupId}`) // if backupId = latest will get the world as it is now not the most recent backup return new Download(this, data) } + + async resetRealm (realmId) { + await this.rest.put(`/worlds/${realmId}/reset`) + } + + // Reference https://github.com/PrismarineJS/prismarine-realms/issues/34 for configuration structure + // async changeRealmConfiguration (realmId, configuration) { + // await this.rest.put(`/worlds/${realmId}/configuration`, { + // body: configuration + // }) + // } + + async removePlayerFromRealm (realmId, xuid) { + const data = await this.rest.put(`/invites/${realmId}/invite/update`, { + body: { + invites: { + [xuid]: 'REMOVE' + } + } + }) + return new Realm(this, data) + } + + async opRealmPlayer (realmId, uuid) { + const data = await this.rest.put(`/invites/${realmId}/invite/update`, { + body: { + invites: { + [uuid]: 'OP' + } + } + }) + return new Realm(this, data) + } + + async deopRealmPlayer (realmId, uuid) { + const data = await this.rest.put(`/invites/${realmId}/invite/update`, { + body: { + invites: { + [uuid]: 'DEOP' + } + } + }) + return new Realm(this, data) + } + + async banPlayerFromRealm (realmId, uuid) { + await this.rest.post(`/worlds/${realmId}/blocklist/${uuid}`) + } + + async unbanPlayerFromRealm (realmId, uuid) { + await this.rest.delete(`/worlds/${realmId}/blocklist/${uuid}`) + } + + async removeRealmFromJoinedList (realmId) { + await this.rest.delete(`/invites/${realmId}`) + } + + async changeIsTexturePackRequired (realmId, forced) { + if (forced) { + await this.rest.put(`/world/${realmId}/content/texturePacksRequired`) + } else { + await this.rest.delete(`/world/${realmId}/content/texturePacksRequired`) + } + } + + async changeRealmDefaultPermission (realmId, permission) { + await this.rest.put(`/world/${realmId}/defaultPermission`, { + body: { + permission: permission.toUpperCase() + } + }) + } + + async changeRealmPlayerPermission (realmId, permission, uuid) { + await this.rest.put(`/world/${realmId}/userPermission`, { + body: { + permission: permission.toUpperCase(), + xuid: uuid + } + }) + } } diff --git a/src/index.js b/src/index.js index 3b4a62d..2c91ff9 100644 --- a/src/index.js +++ b/src/index.js @@ -34,6 +34,49 @@ class RealmAPI { async restoreRealmFromBackup (realmId, backupId) { return await this.rest.put(`/worlds/${realmId}/backups?backupId=${encodeURIComponent(backupId)}&clientSupportsRetries`) } + + async getRealmSubscriptionInfo (realmId, detailed = false) { + if (detailed) { + const data = await this.rest.get(`/subscriptions/${realmId}/details`) + return { + type: data.type, + store: data.store, + startDate: data.startDate, + endDate: data.endDate, + renewalPeriod: data.renewalPeriod, + daysLeft: data.daysLeft, + subscriptionId: data.subscriptionId + } + } else { + const data = await this.rest.get(`/subscriptions/${realmId}`) + return { + startDate: data.startDate, + daysLeft: data.daysLeft, + subscriptionType: data.subscriptionType + } + } + } + + async changeRealmState (realmId, state) { + return await this.rest.put(`/worlds/${realmId}/${state}`) + } + + async changeRealmActiveSlot (realmId, slotId) { + return await this.rest.put(`/worlds/${realmId}/slot/${slotId}`) + } + + async changeRealmNameAndDescription (realmId, name, description) { + await this.rest.post(`/worlds/${realmId}`, { + body: { + name, + description + } + }) + } + + async deleteRealm (realmId) { + await this.rest.delete(`/worlds/${realmId}`) + } } module.exports = RealmAPI diff --git a/src/java/api.js b/src/java/api.js index fc7a326..0f103af 100644 --- a/src/java/api.js +++ b/src/java/api.js @@ -20,10 +20,6 @@ module.exports = class JavaRealmAPI extends RealmAPI { return new Realm(this, data) } - async changeRealmState (realmId, state) { - return await this.rest.put(`/worlds/${realmId}/${state}`) - } - async getRealmWorldDownload (realmId, slotId) { const data = await this.rest.get(`/worlds/${realmId}/slot/${slotId}/download`) return new Download(this, data) diff --git a/src/structures/Realm.js b/src/structures/Realm.js index bf2fb6d..0725a0c 100644 --- a/src/structures/Realm.js +++ b/src/structures/Realm.js @@ -45,6 +45,10 @@ module.exports = class Realm { return this.#api.changeRealmState(this.id, 'close') } + async delete () { + return this.#api.deleteRealm(this.id) + } + async getWorldDownload () { return this.#api.getRealmWorldDownload(this.id, this.activeSlot, 'latest') } @@ -52,4 +56,16 @@ module.exports = class Realm { async getBackups () { return this.#api.getRealmBackups(this.id, this.activeSlot) } + + async getSubscriptionInfo (detailed = false) { + return this.#api.getRealmSubscriptionInfo(this.id, detailed) + } + + async changeActiveSlot (slotId) { + return this.#api.changeRealmActiveSlot(this.id, slotId) + } + + async changeNameAndDescription (name, description) { + return this.#api.changeRealmNameAndDescription(this.id, name, description) + } } diff --git a/test/bedrockAPI.js b/test/bedrockAPI.js index e80cfdf..be11cb5 100644 --- a/test/bedrockAPI.js +++ b/test/bedrockAPI.js @@ -6,7 +6,7 @@ const chaiAsPromised = require('chai-as-promised') use(chaiAsPromised) -const { World, Join, RealmInvite, RealmInviteModified, PendingInvites, PendingInvitesModified, PendingInvitesCount, BedrockWorldDownload, Backups } = require('./common/responses.json') +const { World, Join, RealmInvite, RealmInviteModified, PendingInvites, PendingInvitesModified, PendingInvitesCount, BedrockWorldDownload, Backups, SubscriptionInfoDetailed, SubscriptionInfo } = require('./common/responses.json') const { RealmAPI } = require('prismarine-realms') const { Authflow } = require('prismarine-auth') @@ -32,8 +32,10 @@ nock('https://pocket.realms.minecraft.net') .get('/worlds') .reply(200, { servers: [World] }) .get(`/worlds/${config.realmId}`) - .times(9) + .times(10) .reply(200, World) + .post(`/worlds/${config.realmId}`) + .reply(204) .get(`/worlds/v1/link/${config.realmInviteCode}`) .times(2) .reply(200, World) @@ -71,6 +73,33 @@ nock('https://pocket.realms.minecraft.net') .put(`/worlds/${config.realmId}/backups?backupId=${config.backupId}&clientSupportsRetries`) .times(2) .reply(204) + .persist() + .delete(`/worlds/${config.realmId}`) + .reply(204) + .get(`/subscriptions/${config.realmId}/details`) + .reply(200, SubscriptionInfoDetailed) + .get(`/subscriptions/${config.realmId}`) + .reply(200, SubscriptionInfo) + .put(`/worlds/${config.realmId}/slot/2`) + .reply(200, true) + .put(`/worlds/${config.realmId}`) + .reply(200, World) + .put(`/worlds/${config.realmId}/reset`) + .reply(200, true) + .put(`/worlds/${config.realmId}/configuration`) + .reply(204) + .post(`/worlds/${config.realmId}/blocklist/${config.xuid}`) + .reply(204) + .delete(`/worlds/${config.realmId}/blocklist/${config.xuid}`) + .reply(204) + .delete(`/invites/${config.realmId}`) + .reply(204) + .put(`/world/${config.realmId}/content/texturePacksRequired`) + .reply(204) + .put(`/world/${config.realmId}/defaultPermission`) + .reply(204) + .put(`/world/${config.realmId}/userPermission`) + .reply(204) describe('Bedrock', () => { describe('getRealms', () => { @@ -184,4 +213,245 @@ describe('Bedrock', () => { expect(await realm.getWorldDownload()).to.deep.equal(new Download({ platform: 'bedrock' }, BedrockWorldDownload)) }) }) + describe('Realm Delete', () => { + it('should return void indicating Realm is successfully deleted', async () => { + const realm = await api.getRealm(config.realmId) + await realm.delete() + }) + }) + describe('Realm getSubscriptionInfo', () => { + it('should return an array of basic subscription info', async () => { + const realm = await api.getRealm(config.realmId) + expect(await realm.getSubscriptionInfo()).to.deep.equal(SubscriptionInfo) + }) + it('should return an array of detailed subscription info', async () => { + const realm = await api.getRealm(config.realmId) + expect(await realm.getSubscriptionInfo(true)).to.deep.equal(SubscriptionInfoDetailed) + }) + }) + describe('Realm changeActiveRealmSlot', () => { + it('should return true to indicate the change has been made', async () => { + const realm = await api.getRealm(config.realmId) + expect(await realm.changeActiveSlot(2)).to.deep.equal(true) + }) + }) + describe('Realm changeNameAndDescription', () => { + it('should return void', async () => { + const realm = await api.getRealm(config.realmId) + await realm.changeNameAndDescription(config.realmId, 'Hello', 'World!') + }) + }) + describe('Realm reset', () => { + it('should return void', async () => { + await api.resetRealm(config.realmId) + }) + }) + // describe('Realm changeConfiguration', () => { + // it('should return void', async () => { + // const configuration = { + // description: { + // description: '', + // name: '', + // options: { + // slotName: 'Test', + // pvp: true, + // spawnAnimals: true, + // spawnMonsters: true, + // spawnNPCs: true, + // spawnProtection: 0, + // commandBlocks: false, + // forceGameMode: false, + // gameMode: 0, + // difficulty: 2, + // worldTemplateId: -1, + // worldTemplateImage: '', + // adventureMap: false, + // resourcePackHash: null, + // incompatibilities: [], + // versionRef: '', + // versionLock: false, + // cheatsAllowed: true, + // texturePacksRequired: true, + // timeRequest: null, + // enabledPacks: { + // resourcePacks: [''], + // behaviorPacks: [''] + // }, + // customGameServerGlobalProperties: null, + // worldSettings: { + // sendcommandfeedback: { + // type: 0, + // value: true + // }, + // commandblocksenabled: { + // type: 0, + // value: true + // }, + // dodaylightcycle: { + // type: 0, + // value: true + // }, + // randomtickspeed: { + // type: 1, + // value: 3 + // }, + // naturalregeneration: { + // type: 0, + // value: true + // }, + // showtags: { + // type: 0, + // value: true + // }, + // commandblockoutput: { + // type: 0, + // value: true + // }, + // dofiretick: { + // type: 0, + // value: false + // }, + // maxcommandchainlength: { + // type: 1, + // value: 65535 + // }, + // falldamage: { + // type: 0, + // value: true + // }, + // tntexplodes: { + // type: 0, + // value: true + // }, + // drowningdamage: { + // type: 0, + // value: true + // }, + // domobloot: { + // type: 0, + // value: true + // }, + // domobspawning: { + // type: 0, + // value: true + // }, + // showbordereffect: { + // type: 0, + // value: true + // }, + // showdeathmessages: { + // type: 0, + // value: true + // }, + // respawnblocksexplode: { + // type: 0, + // value: true + // }, + // doweathercycle: { + // type: 0, + // value: true + // }, + // doentitydrops: { + // type: 0, + // value: true + // }, + // doimmediaterespawn: { + // type: 0, + // value: true + // }, + // freezedamage: { + // type: 0, + // value: true + // }, + // pvp: { + // type: 0, + // value: true + // }, + // keepinventory: { + // type: 0, + // value: false + // }, + // doinsomnia: { + // type: 0, + // value: true + // }, + // mobgriefing: { + // type: 0, + // value: true + // }, + // dotiledrops: { + // type: 0, + // value: true + // }, + // firedamage: { + // type: 0, + // value: true + // }, + // functioncommandlimit: { + // type: 1, + // value: 10000 + // }, + // spawnradius: { + // type: 1, + // value: 25 + // }, + // showcoordinates: { + // type: 0, + // value: true + // } + // } + // } + // } + // } + // await api.changeRealmConfiguration(config.realmId, configuration) + // }) + // }) + describe('Realm removePlayerFromRealm', () => { + it('should return a Realm object', async () => { + const removedInvite = await api.removePlayerFromRealm(config.realmId, config.xuid) + expect(removedInvite).to.deep.equal({ ...World, players: [{ uuid: config.xuid }] }) + }) + }) + describe('Realm opRealmPlayer', () => { + it('should return a Realm object', async () => { + const op = await api.opRealmPlayer(config.realmId, config.xuid) + expect(op).to.deep.equal({ ...World, players: [{ uuid: config.xuid }] }) + }) + }) + describe('Realm deopRealmPlayer', () => { + it('should return a Realm object', async () => { + const deop = await api.deopRealmPlayer(config.realmId, config.xuid) + expect(deop).to.deep.equal({ ...World, players: [{ uuid: config.xuid }] }) + }) + }) + describe('Realm banPlayerFromRealm', () => { + it('should return void', async () => { + await api.banPlayerFromRealm(config.realmId, config.xuid) + }) + }) + describe('Realm unbanPlayerFromRealm', () => { + it('should return void', async () => { + await api.unbanPlayerFromRealm(config.realmId, config.xuid) + }) + }) + describe('Realm removeRealmFromJoinedList', () => { + it('should return void', async () => { + await api.removeRealmFromJoinedList(config.realmId) + }) + }) + describe('Realm changeIsTexturePackRequired', () => { + it('should return void', async () => { + await api.changeIsTexturePackRequired(config.realmId, true) + }) + }) + describe('Realm changeRealmDefaultPermission', () => { + it('should return void', async () => { + await api.changeRealmDefaultPermission(config.realmId, 'MEMBER') + }) + }) + describe('Realm changeRealmPlayerPermission', () => { + it('should return void', async () => { + await api.changeRealmPlayerPermission(config.realmId, 'MEMBER', config.xuid) + }) + }) }) diff --git a/test/common/responses.json b/test/common/responses.json index 1fb7dbd..c689df5 100644 --- a/test/common/responses.json +++ b/test/common/responses.json @@ -77,7 +77,7 @@ "size": 10000, "metadata": { "game_difficulty": "0", - "name":"Test Realm", + "name": "Test Realm", "game_server_version": "1.19.0", "enabled_packs": "{\"resourcePacks\":[],\"behaviorPacks\":[\"4b45f411-9ca2-4d12-a2a8-4d2de8746538\"]}", "description": null, @@ -96,5 +96,19 @@ "downloadLink": "https://wsjavaprodeus.blob.core.windows.net/worlds/1112223/mcr_world_3.tar.gz?snapshot=1970-01-01T00:00:00.000Z", "resourcePackUrl": null, "resourcePackHash": null + }, + "SubscriptionInfoDetailed": { + "type": "SUBSCRIPTION", + "store": "xbox1.store", + "startDate": 1623908801932, + "endDate": 1626428175000, + "renewalPeriod": 30, + "daysLeft": 2, + "subscriptionId": "02ea6dec4d446c5b123dde157920453" + }, + "SubscriptionInfo": { + "startDate": 1623908801932, + "daysLeft": 2, + "subscriptionType": "RECURRING" } } \ No newline at end of file