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.
- package/README.md +2 -2
- package/package.json +1 -1
- 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
|
|
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
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
41
|
+
const uuid = uuidV4();
|
|
28
42
|
this.session = {
|
|
29
|
-
url: `https://sessiondirectory.xboxlive.com/serviceconfigs/${SessionConfig.MinecraftSCID}/sessionTemplates/${SessionConfig.MinecraftTemplateName}/sessions/${
|
|
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
|
|
242
|
-
worldName: String(this.options.world
|
|
243
|
-
version: String(this.options.world
|
|
244
|
-
MemberCount: Number(this.options.world
|
|
245
|
-
MaxMemberCount: Number(this.options.world
|
|
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
|
|
274
|
+
HostPort: Number(this.options.port),
|
|
261
275
|
RakNetGUID: '',
|
|
262
276
|
},
|
|
263
277
|
],
|