bedrock-portal 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/src/index.js +25 -11
package/README.md CHANGED
@@ -65,7 +65,7 @@ Options:
65
65
  - **autoInvite**: boolean - Automatically invites recently added friends to the game (default: false)
66
66
 
67
67
  ```js
68
- const { Modules } = require('bedrock-portal');
68
+ const { BedrockPortal, Modules } = require('bedrock-portal');
69
69
 
70
70
  const portal = new BedrockPortal(auth, { ... })
71
71
 
@@ -82,7 +82,7 @@ portal.use(Modules.autoFriendAdd, {
82
82
 
83
83
  Creating a module is easy. You can create a module by extending the `Module` class.
84
84
 
85
- Note: The `stopped` property is set to `true` when the module is stopped. You can use this to stop the module's loop (if one is present) else the process will not exit.
85
+ Note: The `stopped` property is set to `true` when the portal is stopped. You can use this to stop the module's loop (if one is present) else the process will not exit.
86
86
 
87
87
  ```js
88
88
  const { Module } = require('bedrock-portal');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bedrock-portal",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Creates a joinable session in Minecraft Bedrock Edition that can route players to their a specified host",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -4,6 +4,7 @@ const { XboxRTA } = require('xbox-rta');
4
4
  const { EventEmitter } = require('events');
5
5
 
6
6
  const { altCheck } = require('./common/util');
7
+ const { version: pkgVersion } = require('../package.json');
7
8
  const { SessionConfig, Endpoints, Joinability } = require('./common/constants');
8
9
 
9
10
  const Rest = require('./rest');
@@ -20,14 +21,27 @@ module.exports = class BedrockPortal extends EventEmitter {
20
21
  #rest;#rta;
21
22
  constructor(authflow, options = {}) {
22
23
  super();
23
- const name = options.sessionName || uuidV4();
24
- this.validateOptions(options);
24
+ this.options = {
25
+ port: 19132,
26
+ disableAltCheck: false,
27
+ joinability: Joinability.friends_of_friends,
28
+ ...options,
29
+ world: {
30
+ hostName: `Bedrock Portal v${pkgVersion}`,
31
+ worldName: 'By LucienHH',
32
+ version: pkgVersion,
33
+ memberCount: 0,
34
+ maxMemberCount: 10,
35
+ ...options.world,
36
+ },
37
+ };
38
+ this.validateOptions(this.options);
25
39
  this.#rest = new Rest(authflow);
26
40
  this.#rta = new XboxRTA(authflow);
27
- this.options = options;
41
+ const uuid = uuidV4();
28
42
  this.session = {
29
- url: `https://sessiondirectory.xboxlive.com/serviceconfigs/${SessionConfig.MinecraftSCID}/sessionTemplates/${SessionConfig.MinecraftTemplateName}/sessions/${name}`,
30
- name,
43
+ url: `https://sessiondirectory.xboxlive.com/serviceconfigs/${SessionConfig.MinecraftSCID}/sessionTemplates/${SessionConfig.MinecraftTemplateName}/sessions/${uuid}`,
44
+ name: uuid,
31
45
  subscriptionId: uuidV4(),
32
46
  };
33
47
  this.players = [];
@@ -238,11 +252,11 @@ module.exports = class BedrockPortal extends EventEmitter {
238
252
  closed: false,
239
253
  },
240
254
  custom: {
241
- hostName: String(this.options.world?.hostName || `${this.sessionOwner.gamertag}'s Portal`),
242
- worldName: String(this.options.world?.name || 'BedrockPortal'),
243
- version: String(this.options.world?.version || require('../package.json').version),
244
- MemberCount: Number(this.options.world?.memberCount ?? 0),
245
- MaxMemberCount: Number(this.options.world?.maxMemberCount ?? 10),
255
+ hostName: String(this.options.world.hostName),
256
+ worldName: String(this.options.world.name),
257
+ version: String(this.options.world.version),
258
+ MemberCount: Number(this.options.world.memberCount),
259
+ MaxMemberCount: Number(this.options.world.maxMemberCount),
246
260
  Joinability: joinability.joinability,
247
261
  ownerId: this.sessionOwner.xuid,
248
262
  rakNetGUID: genRaknetGUID(),
@@ -257,7 +271,7 @@ module.exports = class BedrockPortal extends EventEmitter {
257
271
  {
258
272
  ConnectionType: 6,
259
273
  HostIpAddress: this.options.ip,
260
- HostPort: Number(this.options.port ?? 19132),
274
+ HostPort: Number(this.options.port),
261
275
  RakNetGUID: '',
262
276
  },
263
277
  ],