Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented a slue of new functions to interact with the realms API #40

Merged
merged 12 commits into from
Jan 12, 2024
345 changes: 345 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -26,14 +29,30 @@
- [getPendingInvites](#getpendinginvites)
- [acceptRealmInvitation](#acceptrealminvitation)
- [rejectRealmInvitation](#rejectrealminvitation)
- [removePlayerFromRealm](#removeplayerfromrealm)
- [resetRealm](#resetrealm)
- [changeRealmConfiguration](#changerealmconfiguration)
- [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)
- [getSubscriptionInfoDetailed](#getsubscriptioninfodetailed)
- [changeActiveSlot](#changeactiveslot)
- [changeNameAndDescription](#changenameanddescription)
- [Backup](#backup)
- [getDownload](#getDownload)
- [restore](#restore)
Expand Down Expand Up @@ -287,8 +306,12 @@ Accepts a pending invite for the authenticating account
await api.acceptRealmInvitation('1234567')
```

<summary>Output</summary>

No output

</details>

---

### rejectRealmInvitation
Expand All @@ -301,8 +324,222 @@ Rejects a pending invite for the authenticating account
await api.rejectRealmInvitation('1234567')
```

<details>
<summary>Output</summary>

No output

</details>

---

### removePlayerFromRealm

(realmId: string, xuid: string) => Promise\<Realm>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why specifically return a Realm here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the bedrock Realm API docs, it states it returns all information about the Realm. Should we not be returning all the Realm's information as states in the API docs?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, ignore that. I understand now. Thank you


Removes a player from the Realm

```js
await api.removePlayerFromRealm('1234567', 'a8005260a332457097a50bdbe48a9a21')
```

<details>
<summary>Output</summary>

[Realm](#realm)

</details>

---

### resetRealm

(realmId: string) => Promise\<void>

Resets a Realm to its default, or brand new state

```js
await api.resetRealm('1234567')
```

<details>
<summary>Output</summary>

No output

</details>

---

### changeRealmConfiguration

(realmId: string, configuration: string) => Promise\<void>

Updates a Realms configuration. This can be gamerules or general Realm settings

```js
await api.changeRealmConfiguration('1234567', '{ "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}}}}')
```

<details>
<summary>Output</summary>

No output

</details>

---

### opRealmPlayer

(realmId: string, uuid: string) => Promise\<void>

OPs a player on the Realm

```js
await api.opRealmPlayer('1234567', 'a8005260a332457097a50bdbe48a9a21')
```

<details>
<summary>Output</summary>

No output

</details>

---

### deopRealmPlayer

(realmId: string, uuid: string) => Promise\<void>

DEOPs a player on the Realm

```js
await api.deopRealmPlayer('1234567', 'a8005260a332457097a50bdbe48a9a21')
```

<details>
<summary>Output</summary>

No output

</details>

---

### banPlayerFromRealm

(realmId: string, uuid: string) => Promise\<void>

Bans a player from the Realm

```js
await api.banPlayerFromRealm('1234567', 'a8005260a332457097a50bdbe48a9a21')
```

<details>
<summary>Output</summary>

No output

</details>

---

### unbanPlayerFromRealm

(realmId: string, uuid: string) => Promise\<void>

Unbans a player from the Realm

```js
await api.unbanPlayerFromRealm('1234567', 'a8005260a332457097a50bdbe48a9a21')
```

<details>
<summary>Output</summary>

No output

</details>

---

### removeRealmFromJoinedList

(realmId: string) => Promise\<void>

Removes the Realm from your joined list

```js
await api.removeRealmFromJoinedList('1234567')
```

<details>
<summary>Output</summary>

No output

</details>

---

### changeIsTexturePackRequired

(realmId: string, forced: boolean) => Promise\<Realm>

Changes if a texture pack is required to be applied when joining

```js
await api.changeIsTexturePackRequired('1234567', true)
```

<details>
<summary>Output</summary>

[Realm](#realm)

</details>

---

### changeRealmDefaultPermission

(realmId: string, permission: string) => Promise\<Realm>

Changes the Realms default permission. Permission can be VISITOR, MEMBER, or OPERATOR

```js
await api.changeRealmDefaultPermission('1234567', 'MEMBER')
```

<details>
<summary>Output</summary>

[Realm](#realm)

</details>

---

### changeRealmPlayerPermission

(realmId: string, permission: string, uuid: string) => Promise\<void>

Changes the a players permission. Permission can be VISITOR, MEMBER, or OPERATOR

```js
await api.changeRealmPlayerPermission('1234567', 'MEMBER', 'a8005260a332457097a50bdbe48a9a21')
```

<details>
<summary>Output</summary>

No output

</details>

---

## Structures
Expand Down Expand Up @@ -433,6 +670,20 @@ No output

---

#### delete

() => Promise\<void>

Deletes a Realm. This removes all worlds and the Realm itself beyond recovery

```js
await realm.delete()
```

No output

---

#### getBackups

() => Promise\<Backup[]>
Expand Down Expand Up @@ -471,6 +722,100 @@ await realm.getWorldDownload()

---

#### getSubscriptionInfo

() => Promise\<RealmSubscriptionInfo>

Gets the basic subscription

```js
await realm.getSubscriptionInfo()
```

<details>
<summary>Output</summary>

```ts
{
startDate: number
daysLeft: number
subscriptionType: string
}
```

</details>

---

#### getSubscriptionInfoDetailed

() => Promise\<RealmSubscriptionInfoDetailed>

Gets the detailed subscription info

```js
await realm.getSubscriptionInfoDetailed()
IanTapply22 marked this conversation as resolved.
Show resolved Hide resolved
```

<details>
<summary>Output</summary>

```ts
{
type: string
store: string
startDate: number
endDate: number
renewalPeriod: number
daysLeft: number
subscriptionId: string
}
```

</details>

---

---

#### changeActiveSlot

(realmId: string, slotId, number) => Promise\<void>

Changes the active world slot. Slot ID can be 1, 2, or 3

```js
await realm.changeActiveSlot('1234567', 1)
```

<details>
<summary>Output</summary>

No output

</details>

---

#### changeNameAndDescription

(realmId: string, name: string, description: string) => Promise\<void>

Changes the name and description of the Realm

```js
await realm.changeNameAndDescription('1234567', 'Hello', 'World!')
```

<details>
<summary>Output</summary>

No output

</details>

---

### Backup

```js
Expand Down
Loading