@sectersion/rockbot 0.1.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/README.md +345 -0
- package/dist/auth/env.d.ts +6 -0
- package/dist/auth/env.d.ts.map +1 -0
- package/dist/auth/env.js +17 -0
- package/dist/auth/env.js.map +1 -0
- package/dist/auth/file.d.ts +9 -0
- package/dist/auth/file.d.ts.map +1 -0
- package/dist/auth/file.js +67 -0
- package/dist/auth/file.js.map +1 -0
- package/dist/auth/provider.d.ts +3 -0
- package/dist/auth/provider.d.ts.map +1 -0
- package/dist/auth/provider.js +3 -0
- package/dist/auth/provider.js.map +1 -0
- package/dist/block.d.ts +11 -0
- package/dist/block.d.ts.map +1 -0
- package/dist/block.js +21 -0
- package/dist/block.js.map +1 -0
- package/dist/bot.d.ts +37 -0
- package/dist/bot.d.ts.map +1 -0
- package/dist/bot.js +251 -0
- package/dist/bot.js.map +1 -0
- package/dist/entity.d.ts +19 -0
- package/dist/entity.d.ts.map +1 -0
- package/dist/entity.js +32 -0
- package/dist/entity.js.map +1 -0
- package/dist/fleet.d.ts +21 -0
- package/dist/fleet.d.ts.map +1 -0
- package/dist/fleet.js +110 -0
- package/dist/fleet.js.map +1 -0
- package/dist/group.d.ts +12 -0
- package/dist/group.d.ts.map +1 -0
- package/dist/group.js +37 -0
- package/dist/group.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/loader.d.ts +4 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +15 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/tick.d.ts +33 -0
- package/dist/tick.d.ts.map +1 -0
- package/dist/tick.js +126 -0
- package/dist/tick.js.map +1 -0
- package/dist/types.d.ts +45 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -0
package/dist/bot.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Bot = void 0;
|
|
37
|
+
const events_1 = require("events");
|
|
38
|
+
const vec3_1 = require("vec3");
|
|
39
|
+
const bedrock = __importStar(require("bedrock-protocol"));
|
|
40
|
+
const entity_1 = require("./entity");
|
|
41
|
+
const tick_1 = require("./tick");
|
|
42
|
+
const loader_1 = require("./plugins/loader");
|
|
43
|
+
const defaultControls = {
|
|
44
|
+
forward: false,
|
|
45
|
+
back: false,
|
|
46
|
+
left: false,
|
|
47
|
+
right: false,
|
|
48
|
+
jump: false,
|
|
49
|
+
sneak: false,
|
|
50
|
+
sprint: false,
|
|
51
|
+
};
|
|
52
|
+
class Bot extends events_1.EventEmitter {
|
|
53
|
+
username;
|
|
54
|
+
entity;
|
|
55
|
+
entities;
|
|
56
|
+
health;
|
|
57
|
+
food;
|
|
58
|
+
game;
|
|
59
|
+
_client;
|
|
60
|
+
_controls;
|
|
61
|
+
_tick;
|
|
62
|
+
_destroyed;
|
|
63
|
+
_signalHandler;
|
|
64
|
+
constructor(options) {
|
|
65
|
+
super();
|
|
66
|
+
this.username = options.username;
|
|
67
|
+
this.entity = new entity_1.Entity(-1);
|
|
68
|
+
this.entity.username = options.username;
|
|
69
|
+
this.entities = new Map();
|
|
70
|
+
this.health = 20;
|
|
71
|
+
this.food = 20;
|
|
72
|
+
this.game = { dimension: '', difficulty: 0, gameMode: 0 };
|
|
73
|
+
this._controls = { ...defaultControls };
|
|
74
|
+
this._destroyed = false;
|
|
75
|
+
this._signalHandler = () => this.end('process exit');
|
|
76
|
+
this._client = bedrock.createClient({
|
|
77
|
+
host: options.host ?? '127.0.0.1',
|
|
78
|
+
port: options.port ?? 19132,
|
|
79
|
+
username: options.username,
|
|
80
|
+
offline: options.offline ?? false,
|
|
81
|
+
version: options.version,
|
|
82
|
+
connectTimeout: options.connectTimeout ?? 9000,
|
|
83
|
+
viewDistance: options.viewDistance ?? 8,
|
|
84
|
+
});
|
|
85
|
+
this._tick = new tick_1.TickLoop(this._client, () => this._controls, () => this.entity.position);
|
|
86
|
+
this._client.on('connect_allowed', () => this.emit('connect_allowed'));
|
|
87
|
+
this._client.on('session', (profile) => {
|
|
88
|
+
this.username = profile.name || this.username;
|
|
89
|
+
this.entity.uuid = profile.uuid || '';
|
|
90
|
+
});
|
|
91
|
+
this._client.on('join', () => this.emit('login'));
|
|
92
|
+
this._client.on('spawn', () => {
|
|
93
|
+
this._tick.start();
|
|
94
|
+
this.emit('spawn');
|
|
95
|
+
});
|
|
96
|
+
this._client.on('kick', (packet) => {
|
|
97
|
+
this.emit('kicked', packet.message || 'kicked');
|
|
98
|
+
});
|
|
99
|
+
process.on('SIGINT', this._signalHandler);
|
|
100
|
+
process.on('SIGTERM', this._signalHandler);
|
|
101
|
+
this._client.on('close', () => {
|
|
102
|
+
process.off('SIGINT', this._signalHandler);
|
|
103
|
+
process.off('SIGTERM', this._signalHandler);
|
|
104
|
+
this._destroyed = true;
|
|
105
|
+
this._tick.stop();
|
|
106
|
+
this._client.removeAllListeners();
|
|
107
|
+
this.emit('end');
|
|
108
|
+
});
|
|
109
|
+
this._client.on('error', (err) => this.emit('error', err));
|
|
110
|
+
this._client.on('text', (packet) => {
|
|
111
|
+
const type = packet.type;
|
|
112
|
+
const message = packet.message || '';
|
|
113
|
+
const sourceName = packet.source_name || '';
|
|
114
|
+
if (type === 'chat') {
|
|
115
|
+
this.emit('chat', sourceName, message);
|
|
116
|
+
}
|
|
117
|
+
else if (type === 'whisper') {
|
|
118
|
+
this.emit('whisper', sourceName, message);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.emit('message', message);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
this._client.on('add_player', (packet) => {
|
|
125
|
+
const id = packet.uuid;
|
|
126
|
+
if (!id)
|
|
127
|
+
return;
|
|
128
|
+
const existing = [...this.entities.values()].find(e => e.uuid === id);
|
|
129
|
+
if (!existing) {
|
|
130
|
+
const entity = new entity_1.Entity(packet.runtime_entity_id ?? this.entities.size + 1);
|
|
131
|
+
entity.uuid = id;
|
|
132
|
+
entity.username = packet.username || '';
|
|
133
|
+
entity.type = 'player';
|
|
134
|
+
this.entities.set(entity.id, entity);
|
|
135
|
+
this.emit('entitySpawn', entity);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
this._client.on('remove_player', (packet) => {
|
|
139
|
+
for (const [id, entity] of this.entities) {
|
|
140
|
+
if (entity.uuid === packet.uuid) {
|
|
141
|
+
this.entities.delete(id);
|
|
142
|
+
entity.isValid = false;
|
|
143
|
+
this.emit('entityGone', entity);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
this._client.on('move_actor_absolute', (packet) => {
|
|
149
|
+
const entity = this.entities.get(packet.runtime_entity_id);
|
|
150
|
+
if (entity) {
|
|
151
|
+
entity.position = new vec3_1.Vec3(packet.position.x, packet.position.y, packet.position.z);
|
|
152
|
+
if (packet.rotation) {
|
|
153
|
+
entity.rotation = {
|
|
154
|
+
yaw: packet.rotation.x ?? 0,
|
|
155
|
+
headYaw: packet.rotation.y ?? 0,
|
|
156
|
+
pitch: packet.rotation.z ?? 0,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
this._client.on('move_actor_delta', (packet) => {
|
|
162
|
+
const entity = this.entities.get(packet.runtime_entity_id);
|
|
163
|
+
if (entity) {
|
|
164
|
+
entity.position = entity.position.offset(packet.delta.x / 128, packet.delta.y / 128, packet.delta.z / 128);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
this._client.on('update_attributes', (packet) => {
|
|
168
|
+
if (packet.runtime_entity_id !== this.entity.id)
|
|
169
|
+
return;
|
|
170
|
+
for (const attr of packet.attributes || []) {
|
|
171
|
+
if (attr.name === 'minecraft:health')
|
|
172
|
+
this.health = attr.current;
|
|
173
|
+
if (attr.name === 'minecraft:player.hunger')
|
|
174
|
+
this.food = attr.current;
|
|
175
|
+
}
|
|
176
|
+
this.emit('health');
|
|
177
|
+
});
|
|
178
|
+
this._client.on('respawn', (packet) => {
|
|
179
|
+
this.entity.position = new vec3_1.Vec3(packet.position.x, packet.position.y, packet.position.z);
|
|
180
|
+
this.emit('respawn');
|
|
181
|
+
});
|
|
182
|
+
this._client.on('start_game', (packet) => {
|
|
183
|
+
this.entity.id = packet.runtime_entity_id;
|
|
184
|
+
this.entity.position = new vec3_1.Vec3(packet.player_position?.x ?? 0, packet.player_position?.y ?? 0, packet.player_position?.z ?? 0);
|
|
185
|
+
this.game.dimension = packet.dimension ?? '';
|
|
186
|
+
this.game.difficulty = packet.difficulty ?? 0;
|
|
187
|
+
this.game.gameMode = packet.player_game_mode ?? 0;
|
|
188
|
+
this.emit('game');
|
|
189
|
+
});
|
|
190
|
+
if (options.plugins) {
|
|
191
|
+
(0, loader_1.loadPlugins)(this, options.plugins);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
get position() {
|
|
195
|
+
return this.entity.position;
|
|
196
|
+
}
|
|
197
|
+
get rotation() {
|
|
198
|
+
return { yaw: this.entity.rotation.yaw, pitch: this.entity.rotation.pitch };
|
|
199
|
+
}
|
|
200
|
+
chat(msg) {
|
|
201
|
+
this._client.queue('text', {
|
|
202
|
+
type: 'chat',
|
|
203
|
+
message: msg,
|
|
204
|
+
needs_translation: false,
|
|
205
|
+
source_name: this.username,
|
|
206
|
+
xuid: '',
|
|
207
|
+
platform_chat_id: '',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
whisper(username, msg) {
|
|
211
|
+
this._client.queue('text', {
|
|
212
|
+
type: 'whisper',
|
|
213
|
+
message: `/w ${username} ${msg}`,
|
|
214
|
+
needs_translation: false,
|
|
215
|
+
source_name: this.username,
|
|
216
|
+
xuid: '',
|
|
217
|
+
platform_chat_id: '',
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
look(yaw, pitch) {
|
|
221
|
+
this.entity.rotation.yaw = yaw;
|
|
222
|
+
this.entity.rotation.pitch = pitch;
|
|
223
|
+
}
|
|
224
|
+
lookAt(point) {
|
|
225
|
+
const dx = point.x - this.position.x;
|
|
226
|
+
const dy = point.y - this.position.y;
|
|
227
|
+
const dz = point.z - this.position.z;
|
|
228
|
+
const dist = Math.sqrt(dx * dx + dz * dz);
|
|
229
|
+
this.entity.rotation.yaw = (-Math.atan2(dx, dz) * 180) / Math.PI;
|
|
230
|
+
this.entity.rotation.pitch = (-Math.atan2(dy, dist) * 180) / Math.PI;
|
|
231
|
+
}
|
|
232
|
+
setControlState(control, state) {
|
|
233
|
+
if (control in this._controls) {
|
|
234
|
+
this._controls[control] = state;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
clearControlStates() {
|
|
238
|
+
this._controls = { ...defaultControls };
|
|
239
|
+
}
|
|
240
|
+
quit(reason) {
|
|
241
|
+
if (this._destroyed)
|
|
242
|
+
return;
|
|
243
|
+
this._destroyed = true;
|
|
244
|
+
this._client.disconnect(reason || 'disconnect');
|
|
245
|
+
}
|
|
246
|
+
end(reason) {
|
|
247
|
+
this.quit(reason);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
exports.Bot = Bot;
|
|
251
|
+
//# sourceMappingURL=bot.js.map
|
package/dist/bot.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot.js","sourceRoot":"","sources":["../src/bot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAqC;AACrC,+BAA2B;AAC3B,0DAA2C;AAC3C,qCAAiC;AAEjC,iCAAiC;AAEjC,6CAA8C;AAE9C,MAAM,eAAe,GAAiB;IACpC,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;CACd,CAAA;AAED,MAAa,GAAI,SAAQ,qBAAY;IACnC,QAAQ,CAAQ;IAChB,MAAM,CAAQ;IACd,QAAQ,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,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,IAAI,YAAY,CAAC,CAAA;IACjD,CAAC;IAED,GAAG,CAAC,MAAe;QACjB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnB,CAAC;CACF;AA5ND,kBA4NC"}
|
package/dist/entity.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Vec3 } from 'vec3';
|
|
2
|
+
export declare class Entity {
|
|
3
|
+
id: number;
|
|
4
|
+
uuid: string;
|
|
5
|
+
username: string;
|
|
6
|
+
position: Vec3;
|
|
7
|
+
rotation: {
|
|
8
|
+
yaw: number;
|
|
9
|
+
pitch: number;
|
|
10
|
+
headYaw: number;
|
|
11
|
+
};
|
|
12
|
+
velocity: Vec3;
|
|
13
|
+
type: 'player' | 'mob' | 'object';
|
|
14
|
+
metadata: Record<string, any>;
|
|
15
|
+
isValid: boolean;
|
|
16
|
+
constructor(id: number);
|
|
17
|
+
distanceTo(other: Vec3 | Entity): number;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,qBAAa,MAAM;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,IAAI,CAAA;IACd,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IACzD,QAAQ,EAAE,IAAI,CAAA;IACd,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAA;IACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC7B,OAAO,EAAE,OAAO,CAAA;gBAEJ,EAAE,EAAE,MAAM;IAYtB,UAAU,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM;CAIzC"}
|
package/dist/entity.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Entity = void 0;
|
|
4
|
+
const vec3_1 = require("vec3");
|
|
5
|
+
class Entity {
|
|
6
|
+
id;
|
|
7
|
+
uuid;
|
|
8
|
+
username;
|
|
9
|
+
position;
|
|
10
|
+
rotation;
|
|
11
|
+
velocity;
|
|
12
|
+
type;
|
|
13
|
+
metadata;
|
|
14
|
+
isValid;
|
|
15
|
+
constructor(id) {
|
|
16
|
+
this.id = id;
|
|
17
|
+
this.uuid = '';
|
|
18
|
+
this.username = '';
|
|
19
|
+
this.position = new vec3_1.Vec3(0, 0, 0);
|
|
20
|
+
this.rotation = { yaw: 0, pitch: 0, headYaw: 0 };
|
|
21
|
+
this.velocity = new vec3_1.Vec3(0, 0, 0);
|
|
22
|
+
this.type = 'player';
|
|
23
|
+
this.metadata = {};
|
|
24
|
+
this.isValid = true;
|
|
25
|
+
}
|
|
26
|
+
distanceTo(other) {
|
|
27
|
+
const pos = other instanceof Entity ? other.position : other;
|
|
28
|
+
return this.position.distanceTo(pos);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Entity = Entity;
|
|
32
|
+
//# sourceMappingURL=entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAE3B,MAAa,MAAM;IACjB,EAAE,CAAQ;IACV,IAAI,CAAQ;IACZ,QAAQ,CAAQ;IAChB,QAAQ,CAAM;IACd,QAAQ,CAAiD;IACzD,QAAQ,CAAM;IACd,IAAI,CAA6B;IACjC,QAAQ,CAAqB;IAC7B,OAAO,CAAS;IAEhB,YAAY,EAAU;QACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;QACd,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;QACjC,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAA;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACrB,CAAC;IAED,UAAU,CAAC,KAAoB;QAC7B,MAAM,GAAG,GAAG,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAA;QAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACtC,CAAC;CACF;AA3BD,wBA2BC"}
|
package/dist/fleet.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { Bot } from './bot';
|
|
3
|
+
import { Group } from './group';
|
|
4
|
+
import { FleetOptions, SpawnOptions } from './types';
|
|
5
|
+
export declare class Fleet extends EventEmitter {
|
|
6
|
+
bots: Map<string, Bot>;
|
|
7
|
+
private _opts;
|
|
8
|
+
private _auth;
|
|
9
|
+
private _counter;
|
|
10
|
+
constructor(options?: FleetOptions);
|
|
11
|
+
spawn(n: number): Promise<Bot[]>;
|
|
12
|
+
spawn(opts: SpawnOptions): Promise<Bot>;
|
|
13
|
+
private _spawnOne;
|
|
14
|
+
bot(name: string): Bot | undefined;
|
|
15
|
+
despawn(name: string): void;
|
|
16
|
+
despawnAll(): void;
|
|
17
|
+
broadcast(msg: string): void;
|
|
18
|
+
group(names: string[]): Group;
|
|
19
|
+
private _releaseAccount;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=fleet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet.d.ts","sourceRoot":"","sources":["../src/fleet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAyB,MAAM,SAAS,CAAA;AAU3E,qBAAa,KAAM,SAAQ,YAAY;IACrC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,QAAQ,CAAQ;gBAEZ,OAAO,GAAE,YAAiB;IAqBhC,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAChC,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;YAc/B,SAAS;IAgCvB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAIlC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQ3B,UAAU,IAAI,IAAI;IAMlB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAM5B,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK;IAK7B,OAAO,CAAC,eAAe;CAKxB"}
|
package/dist/fleet.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Fleet = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const bot_1 = require("./bot");
|
|
6
|
+
const group_1 = require("./group");
|
|
7
|
+
const file_1 = require("./auth/file");
|
|
8
|
+
const env_1 = require("./auth/env");
|
|
9
|
+
const defaultOptions = {
|
|
10
|
+
host: '127.0.0.1',
|
|
11
|
+
port: 19132,
|
|
12
|
+
offline: false,
|
|
13
|
+
};
|
|
14
|
+
class Fleet extends events_1.EventEmitter {
|
|
15
|
+
bots;
|
|
16
|
+
_opts;
|
|
17
|
+
_auth;
|
|
18
|
+
_counter;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
super();
|
|
21
|
+
this.bots = new Map();
|
|
22
|
+
this._opts = options;
|
|
23
|
+
this._auth = null;
|
|
24
|
+
this._counter = 0;
|
|
25
|
+
const auth = options.auth;
|
|
26
|
+
if (auth) {
|
|
27
|
+
if (typeof auth.provider === 'string') {
|
|
28
|
+
if (auth.provider === 'file') {
|
|
29
|
+
this._auth = new file_1.FileAuthProvider(auth.source || './accounts.csv');
|
|
30
|
+
}
|
|
31
|
+
else if (auth.provider === 'env') {
|
|
32
|
+
this._auth = new env_1.EnvAuthProvider();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this._auth = auth.provider;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async spawn(arg) {
|
|
41
|
+
if (typeof arg === 'number') {
|
|
42
|
+
const count = arg;
|
|
43
|
+
const results = [];
|
|
44
|
+
for (let i = 0; i < count; i++) {
|
|
45
|
+
const bot = await this._spawnOne({});
|
|
46
|
+
results.push(bot);
|
|
47
|
+
}
|
|
48
|
+
return results;
|
|
49
|
+
}
|
|
50
|
+
return this._spawnOne(arg);
|
|
51
|
+
}
|
|
52
|
+
async _spawnOne(opts) {
|
|
53
|
+
const account = this._auth ? await this._auth.acquire() : null;
|
|
54
|
+
const name = opts.name || account?.username || `bot-${++this._counter}`;
|
|
55
|
+
const botOpts = {
|
|
56
|
+
...defaultOptions,
|
|
57
|
+
...this._opts.defaults,
|
|
58
|
+
...opts,
|
|
59
|
+
username: opts.username || account?.username || name,
|
|
60
|
+
password: account?.password,
|
|
61
|
+
};
|
|
62
|
+
const bot = new bot_1.Bot(botOpts);
|
|
63
|
+
this.bots.set(name, bot);
|
|
64
|
+
bot.on('spawn', () => this.emit('spawn', bot));
|
|
65
|
+
bot.on('chat', (username, message) => this.emit('chat', bot, username, message));
|
|
66
|
+
bot.on('kicked', (reason) => {
|
|
67
|
+
this.emit('kicked', bot, reason);
|
|
68
|
+
this._releaseAccount(account);
|
|
69
|
+
});
|
|
70
|
+
bot.on('end', () => {
|
|
71
|
+
this.emit('end', bot);
|
|
72
|
+
if (this.bots.get(name) === bot) {
|
|
73
|
+
this.bots.delete(name);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
bot.on('error', (err) => this.emit('error', bot, err));
|
|
77
|
+
return bot;
|
|
78
|
+
}
|
|
79
|
+
bot(name) {
|
|
80
|
+
return this.bots.get(name);
|
|
81
|
+
}
|
|
82
|
+
despawn(name) {
|
|
83
|
+
const bot = this.bots.get(name);
|
|
84
|
+
if (bot) {
|
|
85
|
+
bot.quit();
|
|
86
|
+
this.bots.delete(name);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
despawnAll() {
|
|
90
|
+
for (const [name] of this.bots) {
|
|
91
|
+
this.despawn(name);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
broadcast(msg) {
|
|
95
|
+
for (const bot of this.bots.values()) {
|
|
96
|
+
bot.chat(msg);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
group(names) {
|
|
100
|
+
const bots = names.map(n => this.bots.get(n)).filter(Boolean);
|
|
101
|
+
return new group_1.Group(bots);
|
|
102
|
+
}
|
|
103
|
+
_releaseAccount(account) {
|
|
104
|
+
if (account && this._auth) {
|
|
105
|
+
this._auth.release(account, 'disconnected');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.Fleet = Fleet;
|
|
110
|
+
//# sourceMappingURL=fleet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet.js","sourceRoot":"","sources":["../src/fleet.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AACrC,+BAA2B;AAC3B,mCAA+B;AAE/B,sCAA8C;AAC9C,oCAA4C;AAE5C,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,KAAK;CACf,CAAA;AAED,MAAa,KAAM,SAAQ,qBAAY;IACrC,IAAI,CAAkB;IACd,KAAK,CAAc;IACnB,KAAK,CAAqB;IAC1B,QAAQ,CAAQ;IAExB,YAAY,UAAwB,EAAE;QACpC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAA;QACrB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAA;QAEjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACzB,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBACtC,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;oBAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,uBAAgB,CAAC,IAAI,CAAC,MAAM,IAAI,gBAAgB,CAAC,CAAA;gBACpE,CAAC;qBAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;oBACnC,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAe,EAAE,C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GAAG,EAAE,CAAC;YACR,GAAG,CAAC,IAAI,EAAE,CAAA;YACV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,UAAU;QACR,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAe;QACnB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAU,CAAA;QACtE,OAAO,IAAI,aAAK,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;IAEO,eAAe,CAAC,OAAuB;QAC7C,IAAI,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;QAC7C,CAAC;IACH,CAAC;CACF;AA5GD,sBA4GC"}
|
package/dist/group.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { Bot } from './bot';
|
|
3
|
+
export declare class Group extends EventEmitter {
|
|
4
|
+
bots: Bot[];
|
|
5
|
+
constructor(bots?: Bot[]);
|
|
6
|
+
add(bot: Bot): void;
|
|
7
|
+
remove(bot: Bot): void;
|
|
8
|
+
broadcast(msg: string): void;
|
|
9
|
+
call(method: string, ...args: any[]): Promise<any[]>;
|
|
10
|
+
on(event: string, fn: (...args: any[]) => void): this;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,qBAAa,KAAM,SAAQ,YAAY;IACrC,IAAI,EAAE,GAAG,EAAE,CAAA;gBAEC,IAAI,GAAE,GAAG,EAAO;IAK5B,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;IAMnB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;IAKtB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMtB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAI1D,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;CAMtD"}
|
package/dist/group.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Group = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
class Group extends events_1.EventEmitter {
|
|
6
|
+
bots;
|
|
7
|
+
constructor(bots = []) {
|
|
8
|
+
super();
|
|
9
|
+
this.bots = bots;
|
|
10
|
+
}
|
|
11
|
+
add(bot) {
|
|
12
|
+
if (!this.bots.includes(bot)) {
|
|
13
|
+
this.bots.push(bot);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
remove(bot) {
|
|
17
|
+
const idx = this.bots.indexOf(bot);
|
|
18
|
+
if (idx !== -1)
|
|
19
|
+
this.bots.splice(idx, 1);
|
|
20
|
+
}
|
|
21
|
+
broadcast(msg) {
|
|
22
|
+
for (const bot of this.bots) {
|
|
23
|
+
bot.chat(msg);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async call(method, ...args) {
|
|
27
|
+
return Promise.all(this.bots.map(bot => bot[method](...args)));
|
|
28
|
+
}
|
|
29
|
+
on(event, fn) {
|
|
30
|
+
for (const bot of this.bots) {
|
|
31
|
+
bot.on(event, fn);
|
|
32
|
+
}
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.Group = Group;
|
|
37
|
+
//# sourceMappingURL=group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAGrC,MAAa,KAAM,SAAQ,qBAAY;IACrC,IAAI,CAAO;IAEX,YAAY,OAAc,EAAE;QAC1B,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,GAAG,CAAC,GAAQ;QACV,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;IAED,MAAM,CAAC,GAAQ;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAClC,IAAI,GAAG,KAAK,CAAC,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC1C,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,GAAG,IAAW;QACvC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAE,GAAW,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACzE,CAAC;IAED,EAAE,CAAC,KAAa,EAAE,EAA4B;QAC5C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QACnB,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAnCD,sBAmCC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Bot } from './bot';
|
|
2
|
+
import { Fleet } from './fleet';
|
|
3
|
+
import { Group } from './group';
|
|
4
|
+
import { Entity } from './entity';
|
|
5
|
+
import { Block } from './block';
|
|
6
|
+
import { FileAuthProvider } from './auth/file';
|
|
7
|
+
import { EnvAuthProvider } from './auth/env';
|
|
8
|
+
import { BotOptions, FleetOptions } from './types';
|
|
9
|
+
export { Bot, Fleet, Group, Entity, Block, FileAuthProvider, EnvAuthProvider };
|
|
10
|
+
export type { BotOptions, FleetOptions };
|
|
11
|
+
export declare function createBot(options: BotOptions): Bot;
|
|
12
|
+
export declare function createFleet(options?: FleetOptions): Fleet;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAElD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAA;AAC9E,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,CAAA;AAExC,wBAAgB,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,GAAG,CAElD;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAEzD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnvAuthProvider = exports.FileAuthProvider = exports.Block = exports.Entity = exports.Group = exports.Fleet = exports.Bot = void 0;
|
|
4
|
+
exports.createBot = createBot;
|
|
5
|
+
exports.createFleet = createFleet;
|
|
6
|
+
const bot_1 = require("./bot");
|
|
7
|
+
Object.defineProperty(exports, "Bot", { enumerable: true, get: function () { return bot_1.Bot; } });
|
|
8
|
+
const fleet_1 = require("./fleet");
|
|
9
|
+
Object.defineProperty(exports, "Fleet", { enumerable: true, get: function () { return fleet_1.Fleet; } });
|
|
10
|
+
const group_1 = require("./group");
|
|
11
|
+
Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return group_1.Group; } });
|
|
12
|
+
const entity_1 = require("./entity");
|
|
13
|
+
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return entity_1.Entity; } });
|
|
14
|
+
const block_1 = require("./block");
|
|
15
|
+
Object.defineProperty(exports, "Block", { enumerable: true, get: function () { return block_1.Block; } });
|
|
16
|
+
const file_1 = require("./auth/file");
|
|
17
|
+
Object.defineProperty(exports, "FileAuthProvider", { enumerable: true, get: function () { return file_1.FileAuthProvider; } });
|
|
18
|
+
const env_1 = require("./auth/env");
|
|
19
|
+
Object.defineProperty(exports, "EnvAuthProvider", { enumerable: true, get: function () { return env_1.EnvAuthProvider; } });
|
|
20
|
+
function createBot(options) {
|
|
21
|
+
return new bot_1.Bot(options);
|
|
22
|
+
}
|
|
23
|
+
function createFleet(options) {
|
|
24
|
+
return new fleet_1.Fleet(options);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAYA,8BAEC;AAED,kCAEC;AAlBD,+BAA2B;AASlB,oFATA,SAAG,OASA;AARZ,mCAA+B;AAQjB,sFARL,aAAK,OAQK;AAPnB,mCAA+B;AAOV,sFAPZ,aAAK,OAOY;AAN1B,qCAAiC;AAML,uFANnB,eAAM,OAMmB;AALlC,mCAA+B;AAKK,sFAL3B,aAAK,OAK2B;AAJzC,sCAA8C;AAIH,iGAJlC,uBAAgB,OAIkC;AAH3D,oCAA4C;AAGiB,gGAHpD,qBAAe,OAGoD;AAG5E,SAAgB,SAAS,CAAC,OAAmB;IAC3C,OAAO,IAAI,SAAG,CAAC,OAAO,CAAC,CAAA;AACzB,CAAC;AAED,SAAgB,WAAW,CAAC,OAAsB;IAChD,OAAO,IAAI,aAAK,CAAC,OAAO,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE5C,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAI,CASxE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadPlugins = loadPlugins;
|
|
4
|
+
function loadPlugins(bot, plugins) {
|
|
5
|
+
for (const decl of plugins) {
|
|
6
|
+
if (Array.isArray(decl)) {
|
|
7
|
+
const [plugin, options] = decl;
|
|
8
|
+
plugin(bot, options);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
decl(bot);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":";;AAGA,kCASC;AATD,SAAgB,WAAW,CAAC,GAAQ,EAAE,OAA4B;IAChE,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;YAC9B,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QACtB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,CAAA;QACX,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/tick.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface ControlReader {
|
|
2
|
+
(): {
|
|
3
|
+
forward: boolean;
|
|
4
|
+
back: boolean;
|
|
5
|
+
left: boolean;
|
|
6
|
+
right: boolean;
|
|
7
|
+
jump: boolean;
|
|
8
|
+
sneak: boolean;
|
|
9
|
+
sprint: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface PositionReader {
|
|
13
|
+
(): {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
z: number;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare class TickLoop {
|
|
20
|
+
private _client;
|
|
21
|
+
private _getControls;
|
|
22
|
+
private _getPosition;
|
|
23
|
+
private _interval;
|
|
24
|
+
private _tick;
|
|
25
|
+
private _started;
|
|
26
|
+
constructor(client: any, getControls: ControlReader, getPosition: PositionReader);
|
|
27
|
+
start(): void;
|
|
28
|
+
stop(): void;
|
|
29
|
+
get running(): boolean;
|
|
30
|
+
private _send;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=tick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tick.d.ts","sourceRoot":"","sources":["../src/tick.ts"],"names":[],"mappings":"AAEA,UAAU,aAAa;IACrB,IAAI;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAA;CACvH;AAED,UAAU,cAAc;IACtB,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;CACpD;AAED,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,SAAS,CAAuC;IACxD,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,QAAQ,CAAS;gBAEb,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc;IAShF,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAOZ,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,OAAO,CAAC,KAAK;CA0Fd"}
|