bedrock-portal 0.8.14 → 0.9.0
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/dist/classes/Module.d.ts +2 -1
- package/dist/classes/Module.js +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/autoFriendAccept.d.ts +2 -2
- package/dist/modules/autoFriendAccept.js +7 -7
- package/dist/modules/autoFriendAdd.d.ts +2 -2
- package/dist/modules/autoFriendAdd.js +8 -8
- package/dist/modules/inviteOnMessage.d.ts +4 -10
- package/dist/modules/inviteOnMessage.js +16 -46
- package/dist/modules/multipleAccounts.d.ts +2 -2
- package/dist/modules/multipleAccounts.js +11 -11
- package/dist/modules/redirectFromRealm.d.ts +3 -3
- package/dist/modules/redirectFromRealm.js +8 -8
- package/dist/modules/serverFormList.d.ts +2 -2
- package/dist/modules/serverFormList.js +4 -4
- package/dist/modules/updateMemberCount.d.ts +2 -2
- package/dist/modules/updateMemberCount.js +6 -6
- package/package.json +2 -1
package/dist/classes/Module.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import debugFn from 'debug';
|
|
2
2
|
import { BedrockPortal } from '..';
|
|
3
3
|
export default class Module {
|
|
4
|
+
portal: BedrockPortal;
|
|
4
5
|
name: string;
|
|
5
6
|
description: string;
|
|
6
7
|
stopped: boolean;
|
|
7
8
|
options: any;
|
|
8
9
|
debug: debugFn.Debugger;
|
|
9
|
-
constructor(name: string, description: string);
|
|
10
|
+
constructor(portal: BedrockPortal, name: string, description: string);
|
|
10
11
|
applyOptions(options: any): void;
|
|
11
12
|
stop(): Promise<void>;
|
|
12
13
|
run(_portal: BedrockPortal): Promise<void>;
|
package/dist/classes/Module.js
CHANGED
|
@@ -5,12 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const debug_1 = __importDefault(require("debug"));
|
|
7
7
|
class Module {
|
|
8
|
+
portal;
|
|
8
9
|
name;
|
|
9
10
|
description;
|
|
10
11
|
stopped;
|
|
11
12
|
options;
|
|
12
13
|
debug;
|
|
13
|
-
constructor(name, description) {
|
|
14
|
+
constructor(portal, name, description) {
|
|
15
|
+
this.portal = portal;
|
|
14
16
|
this.name = name;
|
|
15
17
|
this.description = description;
|
|
16
18
|
this.stopped = false;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RESTSessionResponse, SessionRequest } from './types/sessiondirectory';
|
|
2
|
-
import type { Message } from '
|
|
2
|
+
import type { Message } from 'xbox-message';
|
|
3
3
|
import { EventResponse } from 'xbox-rta';
|
|
4
4
|
import { Authflow } from 'prismarine-auth';
|
|
5
5
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
package/dist/index.js
CHANGED
|
@@ -154,7 +154,7 @@ class BedrockPortal extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
154
154
|
* })
|
|
155
155
|
*/
|
|
156
156
|
use(mod, options) {
|
|
157
|
-
const constructed = new mod();
|
|
157
|
+
const constructed = new mod(this);
|
|
158
158
|
debug(`Enabled module: ${constructed.name}`);
|
|
159
159
|
if (!(constructed instanceof Module_1.default))
|
|
160
160
|
throw new Error('Module must extend the base module');
|
|
@@ -16,7 +16,7 @@ export default class AutoFriendAccept extends Module {
|
|
|
16
16
|
*/
|
|
17
17
|
conditionToMeet: (request: FriendRequestPerson) => boolean;
|
|
18
18
|
};
|
|
19
|
-
constructor();
|
|
20
|
-
run(
|
|
19
|
+
constructor(portal: BedrockPortal);
|
|
20
|
+
run(): Promise<void>;
|
|
21
21
|
stop(): Promise<void>;
|
|
22
22
|
}
|
|
@@ -8,14 +8,14 @@ const Player_1 = __importDefault(require("../classes/Player"));
|
|
|
8
8
|
const multipleAccounts_1 = __importDefault(require("./multipleAccounts"));
|
|
9
9
|
class AutoFriendAccept extends Module_1.default {
|
|
10
10
|
options;
|
|
11
|
-
constructor() {
|
|
12
|
-
super('autoFriendAccept', 'Automatically accept friend requests');
|
|
11
|
+
constructor(portal) {
|
|
12
|
+
super(portal, 'autoFriendAccept', 'Automatically accept friend requests');
|
|
13
13
|
this.options = {
|
|
14
14
|
inviteOnAdd: false,
|
|
15
15
|
conditionToMeet: () => true,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
async run(
|
|
18
|
+
async run() {
|
|
19
19
|
const addXboxFriend = async (host) => {
|
|
20
20
|
host.rta?.on('event', async (event) => {
|
|
21
21
|
if (event.data.NotificationType !== 'IncomingFriendRequestCountChanged')
|
|
@@ -29,23 +29,23 @@ class AutoFriendAccept extends Module_1.default {
|
|
|
29
29
|
const accept = await host.rest.acceptFriendRequests(requests.map(req => req.xuid));
|
|
30
30
|
this.debug(`Accepted ${accept.updatedPeople.length} friend request(s)`);
|
|
31
31
|
for (const person of requests.filter(req => accept.updatedPeople.includes(req.xuid))) {
|
|
32
|
-
portal.emit('friendAdded', new Player_1.default(person, null));
|
|
32
|
+
this.portal.emit('friendAdded', new Player_1.default(person, null));
|
|
33
33
|
this.debug(`Accepted ${person.gamertag}`);
|
|
34
34
|
if (this.options.inviteOnAdd) {
|
|
35
|
-
await portal.invitePlayer(person.xuid).catch(error => this.debug(`Error: Failed to invite ${person.gamertag}`, error));
|
|
35
|
+
await this.portal.invitePlayer(person.xuid).catch(error => this.debug(`Error: Failed to invite ${person.gamertag}`, error));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
await host.rta?.subscribe(`https://social.xboxlive.com/users/xuid(${host.profile?.xuid})/friends`);
|
|
40
40
|
};
|
|
41
|
-
const multipleAccounts = portal.modules.get('multipleAccounts');
|
|
41
|
+
const multipleAccounts = this.portal.modules.get('multipleAccounts');
|
|
42
42
|
if (multipleAccounts && multipleAccounts instanceof multipleAccounts_1.default) {
|
|
43
43
|
for (const account of multipleAccounts.peers.values()) {
|
|
44
44
|
addXboxFriend(account)
|
|
45
45
|
.catch(error => this.debug(`Error: ${error.message}`, error));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
addXboxFriend(portal.host)
|
|
48
|
+
addXboxFriend(this.portal.host)
|
|
49
49
|
.catch(error => this.debug(`Error: ${error.message}`, error));
|
|
50
50
|
}
|
|
51
51
|
async stop() {
|
|
@@ -10,8 +10,8 @@ const multipleAccounts_1 = __importDefault(require("./multipleAccounts"));
|
|
|
10
10
|
class AutoFriendAdd extends Module_1.default {
|
|
11
11
|
interval = null;
|
|
12
12
|
options;
|
|
13
|
-
constructor() {
|
|
14
|
-
super('autoFriendAdd', 'Automatically adds followers as friends');
|
|
13
|
+
constructor(portal) {
|
|
14
|
+
super(portal, 'autoFriendAdd', 'Automatically adds followers as friends');
|
|
15
15
|
this.options = {
|
|
16
16
|
inviteOnAdd: false,
|
|
17
17
|
conditionToMeet: () => true,
|
|
@@ -20,7 +20,7 @@ class AutoFriendAdd extends Module_1.default {
|
|
|
20
20
|
removeInterval: 2000,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
async run(
|
|
23
|
+
async run() {
|
|
24
24
|
const addXboxFriend = async (host) => {
|
|
25
25
|
this.debug('Checking for followers to add');
|
|
26
26
|
const followers = await host.rest.getXboxFollowers()
|
|
@@ -33,11 +33,11 @@ class AutoFriendAdd extends Module_1.default {
|
|
|
33
33
|
throw Error(`Failed to add ${account.gamertag}`);
|
|
34
34
|
});
|
|
35
35
|
if (this.options.inviteOnAdd) {
|
|
36
|
-
await portal.invitePlayer(account.xuid).catch(() => {
|
|
36
|
+
await this.portal.invitePlayer(account.xuid).catch(() => {
|
|
37
37
|
throw Error(`Failed to invite ${account.gamertag}`);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
portal.emit('friendAdded', new Player_1.default(account, null));
|
|
40
|
+
this.portal.emit('friendAdded', new Player_1.default(account, null));
|
|
41
41
|
this.debug(`Added & invited ${account.gamertag}`);
|
|
42
42
|
await (0, promises_1.setTimeout)(this.options.addInterval);
|
|
43
43
|
}
|
|
@@ -51,20 +51,20 @@ class AutoFriendAdd extends Module_1.default {
|
|
|
51
51
|
await host.rest.removeXboxFriend(account.xuid).catch(() => {
|
|
52
52
|
throw Error(`Failed to remove ${account.gamertag}`);
|
|
53
53
|
});
|
|
54
|
-
portal.emit('friendRemoved', new Player_1.default(account, null));
|
|
54
|
+
this.portal.emit('friendRemoved', new Player_1.default(account, null));
|
|
55
55
|
this.debug(`Removed ${account.gamertag}`);
|
|
56
56
|
await (0, promises_1.setTimeout)(this.options.removeInterval);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
this.interval = setInterval(() => {
|
|
60
|
-
const multipleAccounts = portal.modules.get('multipleAccounts');
|
|
60
|
+
const multipleAccounts = this.portal.modules.get('multipleAccounts');
|
|
61
61
|
if (multipleAccounts && multipleAccounts instanceof multipleAccounts_1.default) {
|
|
62
62
|
for (const account of multipleAccounts.peers.values()) {
|
|
63
63
|
addXboxFriend(account)
|
|
64
64
|
.catch(error => this.debug(`Error: ${error.message}`, error));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
addXboxFriend(portal.host)
|
|
67
|
+
addXboxFriend(this.portal.host)
|
|
68
68
|
.catch(error => this.debug(`Error: ${error.message}`, error));
|
|
69
69
|
}, this.options.checkInterval);
|
|
70
70
|
}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import type { BedrockPortal } from '../index';
|
|
2
|
-
import type { Conversation } from '../types/xblmessaging';
|
|
3
2
|
import Module from '../classes/Module';
|
|
3
|
+
import { XboxMessage } from 'xbox-message';
|
|
4
4
|
export default class IniteOnMessage extends Module {
|
|
5
|
-
interval: NodeJS.Timeout | null;
|
|
6
|
-
cache: Conversation[];
|
|
7
5
|
options: {
|
|
8
6
|
/**
|
|
9
7
|
* The message to look for in chat to trigger inviting the player
|
|
10
8
|
* @default 'invite'
|
|
11
9
|
*/
|
|
12
10
|
command: string;
|
|
13
|
-
/**
|
|
14
|
-
* How often to check for new messages in milliseconds
|
|
15
|
-
* @default 30000
|
|
16
|
-
*/
|
|
17
|
-
checkInterval: number;
|
|
18
11
|
};
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
client: XboxMessage;
|
|
13
|
+
constructor(portal: BedrockPortal);
|
|
14
|
+
run(): Promise<void>;
|
|
21
15
|
stop(): Promise<void>;
|
|
22
16
|
}
|
|
@@ -4,63 +4,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Module_1 = __importDefault(require("../classes/Module"));
|
|
7
|
+
const xbox_message_1 = require("xbox-message");
|
|
7
8
|
class IniteOnMessage extends Module_1.default {
|
|
8
|
-
interval = null;
|
|
9
|
-
cache;
|
|
10
9
|
options;
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
client;
|
|
11
|
+
constructor(portal) {
|
|
12
|
+
super(portal, 'initeOnMessage', 'Automatically invite players to the server when they message you');
|
|
13
13
|
this.options = {
|
|
14
14
|
command: 'invite',
|
|
15
|
-
checkInterval: 30000,
|
|
16
15
|
};
|
|
17
|
-
this.
|
|
16
|
+
this.client = new xbox_message_1.XboxMessage({ authflow: portal.authflow });
|
|
18
17
|
}
|
|
19
|
-
async run(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const contentMessages = messages.filter(message => message.lastMessage.type === 'ContentMessage');
|
|
25
|
-
this.debug(`Found ${contentMessages.length} content message(s)`);
|
|
26
|
-
if (this.cache.length === 0) {
|
|
27
|
-
this.cache = contentMessages;
|
|
18
|
+
async run() {
|
|
19
|
+
this.client.on('message', async (message) => {
|
|
20
|
+
this.debug(`Received message from ${message.userId}`);
|
|
21
|
+
const content = message.content;
|
|
22
|
+
if (!content)
|
|
28
23
|
return;
|
|
24
|
+
this.portal.emit('messageReceived', message);
|
|
25
|
+
if (content.toLowerCase() === this.options.command.toLowerCase()) {
|
|
26
|
+
await this.portal.invitePlayer(message.userId);
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.debug(`Found ${newMessages.length} new message(s)`);
|
|
33
|
-
if (newMessages.length === 0)
|
|
34
|
-
return;
|
|
35
|
-
for (const message of newMessages) {
|
|
36
|
-
if (portal.listenerCount('messageRecieved') > 0) {
|
|
37
|
-
console.warn('[Deprecation Warning]: The event \'messageRecieved\' is deprecated and will be removed in a future release. Please use \'messageReceived\' instead.');
|
|
38
|
-
portal.emit('messageRecieved', message.lastMessage);
|
|
39
|
-
}
|
|
40
|
-
portal.emit('messageReceived', message.lastMessage);
|
|
41
|
-
const senderXuid = message.lastMessage.sender;
|
|
42
|
-
if (senderXuid === '0')
|
|
43
|
-
continue;
|
|
44
|
-
this.debug(`Received message from ${senderXuid}`);
|
|
45
|
-
const content = message.lastMessage.contentPayload.content.parts.find(part => part.contentType === 'text')?.text;
|
|
46
|
-
if (!content)
|
|
47
|
-
continue;
|
|
48
|
-
if (content.toLowerCase() === this.options.command.toLowerCase()) {
|
|
49
|
-
await portal.invitePlayer(senderXuid);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
this.cache = contentMessages;
|
|
53
|
-
};
|
|
54
|
-
this.interval = setInterval(() => {
|
|
55
|
-
initeOnMessage()
|
|
56
|
-
.catch(error => this.debug(`Error: ${error.message}`, error));
|
|
57
|
-
}, this.options.checkInterval);
|
|
28
|
+
});
|
|
29
|
+
await this.client.connect();
|
|
58
30
|
}
|
|
59
31
|
async stop() {
|
|
60
32
|
super.stop();
|
|
61
|
-
|
|
62
|
-
clearInterval(this.interval);
|
|
63
|
-
}
|
|
33
|
+
this.client.destroy();
|
|
64
34
|
}
|
|
65
35
|
}
|
|
66
36
|
exports.default = IniteOnMessage;
|
|
@@ -17,7 +17,7 @@ export default class MultipleAccounts extends Module {
|
|
|
17
17
|
accounts: Authflow[];
|
|
18
18
|
};
|
|
19
19
|
peers: Map<string, Host>;
|
|
20
|
-
constructor();
|
|
21
|
-
run(
|
|
20
|
+
constructor(portal: BedrockPortal);
|
|
21
|
+
run(): Promise<void>;
|
|
22
22
|
stop(): Promise<void>;
|
|
23
23
|
}
|
|
@@ -8,21 +8,21 @@ const Host_1 = __importDefault(require("../classes/Host"));
|
|
|
8
8
|
class MultipleAccounts extends Module_1.default {
|
|
9
9
|
options;
|
|
10
10
|
peers;
|
|
11
|
-
constructor() {
|
|
12
|
-
super('multipleAccounts', 'Make the portal session joinable from multiple accounts');
|
|
11
|
+
constructor(portal) {
|
|
12
|
+
super(portal, 'multipleAccounts', 'Make the portal session joinable from multiple accounts');
|
|
13
13
|
this.options = {
|
|
14
14
|
accounts: [],
|
|
15
15
|
};
|
|
16
16
|
this.peers = new Map();
|
|
17
17
|
}
|
|
18
|
-
async run(
|
|
19
|
-
if (!portal.host || !portal.host.profile) {
|
|
18
|
+
async run() {
|
|
19
|
+
if (!this.portal.host || !this.portal.host.profile) {
|
|
20
20
|
this.debug('No host to connect to');
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
await Promise.all(this.options.accounts.map(account => account.getXboxToken()));
|
|
24
24
|
for (const account of this.options.accounts) {
|
|
25
|
-
const peer = new Host_1.default(portal, account);
|
|
25
|
+
const peer = new Host_1.default(this.portal, account);
|
|
26
26
|
await peer.connect();
|
|
27
27
|
if (!peer.profile || !peer.connectionId) {
|
|
28
28
|
this.debug(`Failed to connect to ${account.username}`);
|
|
@@ -30,20 +30,20 @@ class MultipleAccounts extends Module_1.default {
|
|
|
30
30
|
}
|
|
31
31
|
this.peers.set(peer.profile.xuid, peer);
|
|
32
32
|
this.debug(`Connected ${peer.profile.gamertag}`);
|
|
33
|
-
const hostAddPeer = await portal.host.rest.addXboxFriend(peer.profile.xuid)
|
|
33
|
+
const hostAddPeer = await this.portal.host.rest.addXboxFriend(peer.profile.xuid)
|
|
34
34
|
.catch(error => ({ error }));
|
|
35
|
-
const peerAddHost = await peer.rest.addXboxFriend(portal.host.profile.xuid)
|
|
35
|
+
const peerAddHost = await peer.rest.addXboxFriend(this.portal.host.profile.xuid)
|
|
36
36
|
.catch(error => ({ error }));
|
|
37
37
|
if ((hostAddPeer && 'error' in hostAddPeer) || (peerAddHost && 'error' in peerAddHost)) {
|
|
38
38
|
if (hostAddPeer)
|
|
39
39
|
this.debug(`Failed to add ${peer.profile.gamertag} as a friend - ${hostAddPeer.error.message}`);
|
|
40
40
|
if (peerAddHost)
|
|
41
|
-
this.debug(`Failed to add ${portal.host.profile.gamertag} as a friend - ${peerAddHost.error.message}`);
|
|
42
|
-
console.error(`Error creating a friendship between ${portal.host.profile.gamertag} and ${peer.profile.gamertag} - BedrockPortal will continue to run, but will not be joinable from ${peer.profile.gamertag}`);
|
|
41
|
+
this.debug(`Failed to add ${this.portal.host.profile.gamertag} as a friend - ${peerAddHost.error.message}`);
|
|
42
|
+
console.error(`Error creating a friendship between ${this.portal.host.profile.gamertag} and ${peer.profile.gamertag} - BedrockPortal will continue to run, but will not be joinable from ${peer.profile.gamertag}`);
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
|
-
await peer.rest.addConnection(portal.session.name, peer.profile.xuid, peer.connectionId, peer.subscriptionId);
|
|
46
|
-
await peer.rest.setActivity(portal.session.name);
|
|
45
|
+
await peer.rest.addConnection(this.portal.session.name, peer.profile.xuid, peer.connectionId, peer.subscriptionId);
|
|
46
|
+
await peer.rest.setActivity(this.portal.session.name);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
async stop() {
|
|
@@ -38,8 +38,8 @@ export default class RedirectFromRealm extends Module {
|
|
|
38
38
|
message: string;
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
constructor();
|
|
42
|
-
run(
|
|
43
|
-
initClient(options: any
|
|
41
|
+
constructor(portal: BedrockPortal);
|
|
42
|
+
run(): Promise<void>;
|
|
43
|
+
initClient(options: any): Promise<any>;
|
|
44
44
|
stop(): Promise<void>;
|
|
45
45
|
}
|
|
@@ -10,8 +10,8 @@ class RedirectFromRealm extends Module_1.default {
|
|
|
10
10
|
client;
|
|
11
11
|
heartbeat = null;
|
|
12
12
|
options;
|
|
13
|
-
constructor() {
|
|
14
|
-
super('redirectFromRealm', 'Automatically invite players to the server when they join a Realm');
|
|
13
|
+
constructor(portal) {
|
|
14
|
+
super(portal, 'redirectFromRealm', 'Automatically invite players to the server when they join a Realm');
|
|
15
15
|
this.options = {
|
|
16
16
|
clientOptions: {}, // Options for the bedrock-protocol client
|
|
17
17
|
overideDeviceOS: 7,
|
|
@@ -29,14 +29,14 @@ class RedirectFromRealm extends Module_1.default {
|
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
async run(
|
|
32
|
+
async run() {
|
|
33
33
|
const { clientOptions } = this.options;
|
|
34
|
-
const client = await this.initClient(clientOptions
|
|
34
|
+
const client = await this.initClient(clientOptions)
|
|
35
35
|
.catch(error => ({ error }));
|
|
36
36
|
if ('error' in client)
|
|
37
37
|
return console.error(`Error connecting to Realm - ${client.error.message}. BedrockPortal will continue to run, but will not be able to redirect players from this realm.`);
|
|
38
38
|
}
|
|
39
|
-
async initClient(options
|
|
39
|
+
async initClient(options) {
|
|
40
40
|
return new Promise((resolve, reject) => {
|
|
41
41
|
this.client = this.bedrock.createClient(options);
|
|
42
42
|
if (this.options.overideDeviceOS)
|
|
@@ -52,7 +52,7 @@ class RedirectFromRealm extends Module_1.default {
|
|
|
52
52
|
if (this.heartbeat)
|
|
53
53
|
clearInterval(this.heartbeat);
|
|
54
54
|
this.debug('Attempting to reconnect to Realm');
|
|
55
|
-
return this.initClient(options
|
|
55
|
+
return this.initClient(options).catch(err => {
|
|
56
56
|
this.debug(`Error reconnecting to Realm - ${err.message}`);
|
|
57
57
|
});
|
|
58
58
|
}, 30000);
|
|
@@ -62,7 +62,7 @@ class RedirectFromRealm extends Module_1.default {
|
|
|
62
62
|
if (packet.records.type !== 'add')
|
|
63
63
|
return;
|
|
64
64
|
for (const record of packet.records.records) {
|
|
65
|
-
portal.invitePlayer(record.xbox_user_id)
|
|
65
|
+
this.portal.invitePlayer(record.xbox_user_id)
|
|
66
66
|
.catch(e => this.debug(`Failed to invite ${record.xbox_user_id} - ${e.message}`));
|
|
67
67
|
}
|
|
68
68
|
});
|
|
@@ -73,7 +73,7 @@ class RedirectFromRealm extends Module_1.default {
|
|
|
73
73
|
return;
|
|
74
74
|
cd.add(packet.xuid);
|
|
75
75
|
setTimeout(() => cd.delete(packet.xuid), this.options.chatCommand.cooldown);
|
|
76
|
-
portal.invitePlayer(packet.xuid)
|
|
76
|
+
this.portal.invitePlayer(packet.xuid)
|
|
77
77
|
.catch(e => this.debug(`Failed to invite ${packet.xuid} - ${e.message}`));
|
|
78
78
|
});
|
|
79
79
|
});
|
|
@@ -37,8 +37,8 @@ export default class ServerFromList extends Module {
|
|
|
37
37
|
*/
|
|
38
38
|
timeoutMessage: string;
|
|
39
39
|
};
|
|
40
|
-
constructor();
|
|
41
|
-
run(
|
|
40
|
+
constructor(portal: BedrockPortal);
|
|
41
|
+
run(): Promise<void>;
|
|
42
42
|
private sendForm;
|
|
43
43
|
private handleJoin;
|
|
44
44
|
private handleFormResponse;
|
|
@@ -8,8 +8,8 @@ const start_game_1 = require("../common/start_game");
|
|
|
8
8
|
class ServerFromList extends Module_1.default {
|
|
9
9
|
n;
|
|
10
10
|
options;
|
|
11
|
-
constructor() {
|
|
12
|
-
super('serverFromList', 'Allows players to join the server from a list of servers');
|
|
11
|
+
constructor(portal) {
|
|
12
|
+
super(portal, 'serverFromList', 'Allows players to join the server from a list of servers');
|
|
13
13
|
this.options = {
|
|
14
14
|
form: {
|
|
15
15
|
title: '§l§aServer Form List',
|
|
@@ -25,8 +25,8 @@ class ServerFromList extends Module_1.default {
|
|
|
25
25
|
};
|
|
26
26
|
this.n = 0;
|
|
27
27
|
}
|
|
28
|
-
async run(
|
|
29
|
-
portal.onServerConnection = (client) => {
|
|
28
|
+
async run() {
|
|
29
|
+
this.portal.onServerConnection = (client) => {
|
|
30
30
|
client.once('join', () => this.handleJoin(client));
|
|
31
31
|
client.on('spawn', () => {
|
|
32
32
|
this.sendForm(client);
|
|
@@ -7,8 +7,8 @@ const Module_1 = __importDefault(require("../classes/Module"));
|
|
|
7
7
|
class UpdateMemberCount extends Module_1.default {
|
|
8
8
|
ping;
|
|
9
9
|
options;
|
|
10
|
-
constructor() {
|
|
11
|
-
super('updateMemberCount', 'Periodically updates the member count of the session to the amount of players online');
|
|
10
|
+
constructor(portal) {
|
|
11
|
+
super(portal, 'updateMemberCount', 'Periodically updates the member count of the session to the amount of players online');
|
|
12
12
|
this.options = {
|
|
13
13
|
updateInterval: 60000,
|
|
14
14
|
updateMaxMemberCount: true,
|
|
@@ -21,14 +21,14 @@ class UpdateMemberCount extends Module_1.default {
|
|
|
21
21
|
process.exit(1);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
async run(
|
|
24
|
+
async run() {
|
|
25
25
|
let cycle = 0;
|
|
26
26
|
setInterval(async () => {
|
|
27
27
|
try {
|
|
28
|
-
const data = await this.ping({ host: portal.options.ip, port: portal.options.port });
|
|
28
|
+
const data = await this.ping({ host: this.portal.options.ip, port: this.portal.options.port });
|
|
29
29
|
this.debug(`Updating member count to ${data.playersOnline} / ${data.playersMax}`);
|
|
30
|
-
await portal.updateMemberCount(data.playersOnline, this.options.updateMaxMemberCount ? data.playersMax : undefined);
|
|
31
|
-
portal.emit('memberCountUpdate', { online: Number(data.playersOnline), max: Number(data.playersMax), cycle });
|
|
30
|
+
await this.portal.updateMemberCount(data.playersOnline, this.options.updateMaxMemberCount ? data.playersMax : undefined);
|
|
31
|
+
this.portal.emit('memberCountUpdate', { online: Number(data.playersOnline), max: Number(data.playersMax), cycle });
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
34
34
|
this.debug(`Error updating member count - ${error.message}`, error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bedrock-portal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Creates a joinable session in Minecraft Bedrock Edition that can route players to their a specified host",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"prismarine-auth": "github:LucienHH/prismarine-auth#playfab",
|
|
29
29
|
"tiny-typed-emitter": "^2.1.0",
|
|
30
30
|
"uuid": "^9.0.0",
|
|
31
|
+
"xbox-message": "^0.2.0",
|
|
31
32
|
"xbox-rta": "^2.1.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|