@zardoy/flying-squid 0.0.139 → 0.0.140
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/lib/blockArgument.d.ts +46 -0
- package/dist/lib/blockArgument.js +126 -0
- package/dist/lib/blockArgument.test.d.ts +1 -0
- package/dist/lib/blockArgument.test.js +65 -0
- package/dist/lib/command.js +3 -0
- package/dist/lib/commandArgs.d.ts +5 -0
- package/dist/lib/commandArgs.js +28 -0
- package/dist/lib/containers/gameData.d.ts +2 -0
- package/dist/lib/containers/gameData.js +18 -0
- package/dist/lib/modules/blocks.js +114 -49
- package/dist/lib/modules/blocks.test.d.ts +1 -0
- package/dist/lib/modules/blocks.test.js +91 -0
- package/dist/lib/modules/commands.js +8 -0
- package/dist/lib/modules/containers.js +1 -0
- package/dist/lib/modules/daycycle.js +1 -1
- package/dist/lib/modules/endFight.js +1 -0
- package/dist/lib/modules/experience.js +1 -0
- package/dist/lib/modules/gamerules.js +1 -0
- package/dist/lib/modules/moderation.js +8 -0
- package/dist/lib/modules/particle.js +1 -0
- package/dist/lib/modules/physics.js +1 -0
- package/dist/lib/modules/players.js +4 -1
- package/dist/lib/modules/portal.js +1 -0
- package/dist/lib/modules/pvp.js +1 -1
- package/dist/lib/modules/recipes.js +1 -0
- package/dist/lib/modules/sound.js +2 -0
- package/dist/lib/modules/spawn.js +2 -0
- package/dist/lib/modules/tabComplete.d.ts +26 -6
- package/dist/lib/modules/tabComplete.js +123 -110
- package/dist/lib/modules/tabComplete.test.d.ts +1 -0
- package/dist/lib/modules/tabComplete.test.js +76 -0
- package/dist/lib/modules/tp.js +1 -0
- package/dist/lib/modules/warps.js +2 -0
- package/dist/lib/modules/weather.js +1 -0
- package/dist/lib/modules/world.js +2 -0
- package/dist/lib/modules/worldManager.js +2 -0
- package/package.json +1 -1
|
@@ -50,6 +50,7 @@ const server = function (serv, { version }) {
|
|
|
50
50
|
base: 'ping',
|
|
51
51
|
info: 'to pong!',
|
|
52
52
|
usage: '/ping [number]',
|
|
53
|
+
tab: ['number'],
|
|
53
54
|
action(params, ctx) {
|
|
54
55
|
const num = params[0] * 1 + 1;
|
|
55
56
|
let str = 'Pong';
|
|
@@ -65,6 +66,7 @@ const server = function (serv, { version }) {
|
|
|
65
66
|
base: 'modpe',
|
|
66
67
|
info: 'for modpe commands',
|
|
67
68
|
usage: '/modpe <params>',
|
|
69
|
+
tab: ['text'],
|
|
68
70
|
onlyPlayer: true,
|
|
69
71
|
parse(str) { return str || false; },
|
|
70
72
|
action(str, ctx) {
|
|
@@ -79,6 +81,7 @@ const server = function (serv, { version }) {
|
|
|
79
81
|
],
|
|
80
82
|
info: 'to get version of the server',
|
|
81
83
|
usage: '/version',
|
|
84
|
+
tab: [],
|
|
82
85
|
action() {
|
|
83
86
|
return 'This server is running flying-squid version ' + version;
|
|
84
87
|
}
|
|
@@ -87,6 +90,7 @@ const server = function (serv, { version }) {
|
|
|
87
90
|
base: 'bug',
|
|
88
91
|
info: 'to bug report',
|
|
89
92
|
usage: '/bug',
|
|
93
|
+
tab: [],
|
|
90
94
|
action() {
|
|
91
95
|
return 'Report bugs or issues here: https://github.com/zardoy/flying-squid/issues';
|
|
92
96
|
}
|
|
@@ -95,6 +99,7 @@ const server = function (serv, { version }) {
|
|
|
95
99
|
base: 'selector',
|
|
96
100
|
info: 'Get entities id from selector like @a',
|
|
97
101
|
usage: '/selector <selector>',
|
|
102
|
+
tab: ['selector'],
|
|
98
103
|
op: true,
|
|
99
104
|
parse(str) {
|
|
100
105
|
return str || false;
|
|
@@ -176,6 +181,7 @@ const server = function (serv, { version }) {
|
|
|
176
181
|
base: 'stop',
|
|
177
182
|
info: 'Stop the server',
|
|
178
183
|
usage: '/stop',
|
|
184
|
+
tab: [],
|
|
179
185
|
op: true,
|
|
180
186
|
action() {
|
|
181
187
|
serv.quit('Server closed');
|
|
@@ -186,6 +192,7 @@ const server = function (serv, { version }) {
|
|
|
186
192
|
base: 'say',
|
|
187
193
|
info: 'Broadcast a message',
|
|
188
194
|
usage: '/say <message>',
|
|
195
|
+
tab: ['text'],
|
|
189
196
|
op: true,
|
|
190
197
|
parse(params) {
|
|
191
198
|
return params || false;
|
|
@@ -200,6 +207,7 @@ const server = function (serv, { version }) {
|
|
|
200
207
|
base: 'me',
|
|
201
208
|
info: 'Displays a message about yourself',
|
|
202
209
|
usage: '/me <message>',
|
|
210
|
+
tab: ['text'],
|
|
203
211
|
op: true,
|
|
204
212
|
parse(params) {
|
|
205
213
|
return params || false;
|
|
@@ -289,6 +289,7 @@ const server = (serv, options) => {
|
|
|
289
289
|
base: 'loot',
|
|
290
290
|
info: 'Puts a loot table into the container at a position (generated when it is opened)',
|
|
291
291
|
usage: '/loot <x> <y> <z> <loot_table> [seed] e.g. /loot ~ ~-1 ~ chests/simple_dungeon',
|
|
292
|
+
tab: ['blockX', 'blockY', 'blockZ', 'lootTable', 'number'],
|
|
292
293
|
op: true,
|
|
293
294
|
parse(str, ctx) {
|
|
294
295
|
const [x, y, z, table, seed] = str.trim().split(/\s+/);
|
|
@@ -41,7 +41,7 @@ const server = function (serv) {
|
|
|
41
41
|
base: 'time',
|
|
42
42
|
info: 'to change a time',
|
|
43
43
|
usage: '/time <add|query|set> <value>',
|
|
44
|
-
tab: ['time'],
|
|
44
|
+
tab: ['time', 'timeValue'],
|
|
45
45
|
op: true,
|
|
46
46
|
parse(str) {
|
|
47
47
|
const data = str.match(/^(add|query|set)(?: ([0-9]+|day|night))?/);
|
|
@@ -277,6 +277,7 @@ const server = function (serv, options) {
|
|
|
277
277
|
base: 'enderfight',
|
|
278
278
|
info: 'Starts / resets the ender dragon fight',
|
|
279
279
|
usage: '/enderfight <start|reset|state>',
|
|
280
|
+
tab: ['enderfight'],
|
|
280
281
|
op: true,
|
|
281
282
|
parse: (str) => (['start', 'reset', 'state'].includes(str.trim()) ? str.trim() : false),
|
|
282
283
|
async action(what) {
|
|
@@ -41,6 +41,7 @@ const server = function (serv) {
|
|
|
41
41
|
base: 'xp',
|
|
42
42
|
info: 'Give yourself experience',
|
|
43
43
|
usage: '/xp <amount> [player] OR /xp <amount>L [player]',
|
|
44
|
+
tab: ['xp', 'player'],
|
|
44
45
|
op: true,
|
|
45
46
|
parse(str) {
|
|
46
47
|
return str.match(/(-?\d+)(L)? ?([a-zA-Z0-9_]+)?/) || false;
|
|
@@ -89,6 +89,7 @@ const server = function (serv, settings) {
|
|
|
89
89
|
base: 'op',
|
|
90
90
|
info: 'Op a player',
|
|
91
91
|
usage: '/op <player>',
|
|
92
|
+
tab: ['player'],
|
|
92
93
|
op: true,
|
|
93
94
|
parse(params) {
|
|
94
95
|
if (!params.match(/([a-zA-Z0-9_]+)/))
|
|
@@ -124,6 +125,7 @@ const server = function (serv, settings) {
|
|
|
124
125
|
base: 'deop',
|
|
125
126
|
info: 'Deop a player',
|
|
126
127
|
usage: '/deop <player>',
|
|
128
|
+
tab: ['player'],
|
|
127
129
|
op: true,
|
|
128
130
|
parse(params) {
|
|
129
131
|
if (!params.match(/([a-zA-Z0-9_]+)/))
|
|
@@ -157,6 +159,7 @@ const server = function (serv, settings) {
|
|
|
157
159
|
base: 'kick',
|
|
158
160
|
info: 'to kick a player',
|
|
159
161
|
usage: '/kick <player> [reason]',
|
|
162
|
+
tab: ['player', 'text'],
|
|
160
163
|
op: true,
|
|
161
164
|
parse(str) {
|
|
162
165
|
if (!str.match(/([a-zA-Z0-9_]+)(?: (.*))?/)) {
|
|
@@ -186,6 +189,7 @@ const server = function (serv, settings) {
|
|
|
186
189
|
base: 'ban',
|
|
187
190
|
info: 'to ban a player',
|
|
188
191
|
usage: '/ban <player> [reason]',
|
|
192
|
+
tab: ['player', 'text'],
|
|
189
193
|
op: true,
|
|
190
194
|
parse(str) {
|
|
191
195
|
if (!str.match(/([a-zA-Z0-9_]+)(?: (.*))?/)) {
|
|
@@ -297,6 +301,7 @@ const server = function (serv, settings) {
|
|
|
297
301
|
base: 'ban-ip',
|
|
298
302
|
info: 'bans a specific IP',
|
|
299
303
|
usage: '/ban-ip <ip> [reason]',
|
|
304
|
+
tab: ['text', 'text'],
|
|
300
305
|
op: true,
|
|
301
306
|
parse(str) {
|
|
302
307
|
const argv = str.split(' ');
|
|
@@ -329,6 +334,7 @@ const server = function (serv, settings) {
|
|
|
329
334
|
base: 'banlist',
|
|
330
335
|
info: 'Displays banlist.',
|
|
331
336
|
usage: '/banlist',
|
|
337
|
+
tab: [],
|
|
332
338
|
op: true,
|
|
333
339
|
action(v, ctx) {
|
|
334
340
|
const pllist = Object.keys(serv.bannedPlayers);
|
|
@@ -367,6 +373,7 @@ const server = function (serv, settings) {
|
|
|
367
373
|
base: 'pardon-ip',
|
|
368
374
|
info: 'to pardon a player by ip',
|
|
369
375
|
usage: '/pardon-ip <ip>',
|
|
376
|
+
tab: ['text'],
|
|
370
377
|
op: true,
|
|
371
378
|
action(IP, ctx) {
|
|
372
379
|
serv.pardonIP(IP)
|
|
@@ -390,6 +397,7 @@ const server = function (serv, settings) {
|
|
|
390
397
|
base: 'pardon',
|
|
391
398
|
info: 'to pardon a player',
|
|
392
399
|
usage: '/pardon <player>',
|
|
400
|
+
tab: ['text'],
|
|
393
401
|
op: true,
|
|
394
402
|
parse(str) {
|
|
395
403
|
if (!str.match(/([a-zA-Z0-9_]+)/)) {
|
|
@@ -35,6 +35,7 @@ const server = function (serv) {
|
|
|
35
35
|
base: 'particle',
|
|
36
36
|
info: 'emit a particle at a position',
|
|
37
37
|
usage: '/particle <id> [amount] [<sizeX> <sizeY> <sizeZ>]',
|
|
38
|
+
tab: ['particle', 'number', 'number', 'number', 'number'],
|
|
38
39
|
onlyPlayer: true,
|
|
39
40
|
op: true,
|
|
40
41
|
parse(str) {
|
|
@@ -67,6 +67,7 @@ const server = function (serv) {
|
|
|
67
67
|
base: 'velocity',
|
|
68
68
|
info: 'Push velocity on player(s)',
|
|
69
69
|
usage: '/velocity <player> <x> <y> <z>',
|
|
70
|
+
tab: ['player', 'number', 'number', 'number'],
|
|
70
71
|
op: true,
|
|
71
72
|
parse(str) {
|
|
72
73
|
return str.match(/(.+?) (\d+) (\d+) (\d+)/) || false;
|
|
@@ -55,6 +55,7 @@ const server = function (serv, { version }) {
|
|
|
55
55
|
aliases: ['/gm'],
|
|
56
56
|
info: 'to change game mode',
|
|
57
57
|
usage: '/gamemode <mode> [player]',
|
|
58
|
+
tab: ['gamemode', 'player'],
|
|
58
59
|
op: true,
|
|
59
60
|
parse(str, ctx) {
|
|
60
61
|
const paramsSplit = str.split(' ');
|
|
@@ -123,6 +124,7 @@ const server = function (serv, { version }) {
|
|
|
123
124
|
aliases: ['/diff'],
|
|
124
125
|
info: 'Sets the difficulty level',
|
|
125
126
|
usage: '/difficulty <difficulty>',
|
|
127
|
+
tab: ['difficulty'],
|
|
126
128
|
op: true,
|
|
127
129
|
parse(str) {
|
|
128
130
|
if (!str.match(/^([0-3])$/)) {
|
|
@@ -225,6 +227,7 @@ const server = function (serv, { version }) {
|
|
|
225
227
|
base: 'clear',
|
|
226
228
|
info: '',
|
|
227
229
|
usage: '/clear',
|
|
230
|
+
tab: ['selector', 'item', 'number'],
|
|
228
231
|
parse(string, ctx) {
|
|
229
232
|
let players = [];
|
|
230
233
|
const [playersArg, item, count] = string.split(' ');
|
|
@@ -276,7 +279,7 @@ const server = function (serv, { version }) {
|
|
|
276
279
|
base: 'title',
|
|
277
280
|
info: 'Show a title, subtitle, or action bar.',
|
|
278
281
|
usage: '/title <targets> (title|subtitle|actionbar|times|clear|reset) <message|times>',
|
|
279
|
-
tab: ['selector', 'text'],
|
|
282
|
+
tab: ['selector', 'titleAction', 'text'],
|
|
280
283
|
op: true,
|
|
281
284
|
parse(str) {
|
|
282
285
|
const match = str.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);
|
|
@@ -310,6 +310,7 @@ const server = function (serv, { version, worldFolder, noWorldRegion }) {
|
|
|
310
310
|
base: 'portal',
|
|
311
311
|
info: 'Create a portal frame',
|
|
312
312
|
usage: '/portal <bottomLeft:<x> <y> <z>> <direction:x|z> <width> <height>',
|
|
313
|
+
tab: ['blockX', 'blockY', 'blockZ', 'axis', 'number', 'number'],
|
|
313
314
|
onlyPlayer: true,
|
|
314
315
|
op: true,
|
|
315
316
|
parse(str, ctx) {
|
package/dist/lib/modules/pvp.js
CHANGED
|
@@ -202,6 +202,7 @@ const server = function (serv, options) {
|
|
|
202
202
|
base: 'recipe',
|
|
203
203
|
info: 'Create / tune / regenerate custom dimensions (world recipes)',
|
|
204
204
|
usage: '/recipe <list|info|new|set|regen|apply|edit|editor> ...',
|
|
205
|
+
tab: ['recipeAction'],
|
|
205
206
|
op: true,
|
|
206
207
|
parse: (str) => ({ tokens: str.trim().split(/\s+/).filter(Boolean), raw: str }),
|
|
207
208
|
async action({ tokens, raw }, ctx) {
|
|
@@ -128,6 +128,7 @@ const server = function (serv) {
|
|
|
128
128
|
base: 'playsoundforall',
|
|
129
129
|
info: 'to play sound for everyone',
|
|
130
130
|
usage: '/playsoundforall <sound_name> [volume] [pitch]',
|
|
131
|
+
tab: ['sound', 'number', 'number'],
|
|
131
132
|
onlyPlayer: true,
|
|
132
133
|
op: true,
|
|
133
134
|
parse(str) {
|
|
@@ -149,6 +150,7 @@ const server = function (serv) {
|
|
|
149
150
|
base: 'playsound',
|
|
150
151
|
info: 'to play sound for yourself',
|
|
151
152
|
usage: '/playsound <sound_name> [volume] [pitch]',
|
|
153
|
+
tab: ['sound', 'number', 'number'],
|
|
152
154
|
onlyPlayer: true,
|
|
153
155
|
op: true,
|
|
154
156
|
parse(str) {
|
|
@@ -192,6 +192,7 @@ const server = function (serv, options) {
|
|
|
192
192
|
base: 'pile',
|
|
193
193
|
info: 'make a pile of entities',
|
|
194
194
|
usage: '/pile <entities types>',
|
|
195
|
+
tab: ['entity', 'entity', 'entity', 'entity', 'entity', 'entity'],
|
|
195
196
|
onlyPlayer: true,
|
|
196
197
|
op: true,
|
|
197
198
|
parse(str) {
|
|
@@ -231,6 +232,7 @@ const server = function (serv, options) {
|
|
|
231
232
|
base: 'attach',
|
|
232
233
|
info: 'attach an entity on an other entity',
|
|
233
234
|
usage: '/attach <carrier> <attached>',
|
|
235
|
+
tab: ['selector', 'selector'],
|
|
234
236
|
op: true,
|
|
235
237
|
parse(str, ctx) {
|
|
236
238
|
const args = str.split(' ');
|
|
@@ -1,19 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/** What a completion type gets besides the looked at block: the word being typed and the arguments before it. */
|
|
2
|
+
export type TabCompleteContext = {
|
|
3
|
+
player?: Player;
|
|
4
|
+
lookedAtBlock?: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
z: number;
|
|
8
|
+
} | null;
|
|
9
|
+
/** the word being completed (matches are filtered by it, and replace it in the client) */
|
|
10
|
+
typed: string;
|
|
11
|
+
/** the arguments typed before it (the command name not included) */
|
|
12
|
+
args: string[];
|
|
13
|
+
};
|
|
14
|
+
export type TabCompleteType = (lookedAtBlock: any, typed: string, ctx: TabCompleteContext) => string[] | undefined | null;
|
|
15
|
+
/** Commands the player may run (op commands only for ops), by every name they answer to (aliases included). */
|
|
16
|
+
export declare function commandNamesFor(serv: Server, player?: Player): string[];
|
|
17
|
+
export declare const server: (serv: Server) => void;
|
|
18
|
+
export declare const player: (player: Player, serv: Server) => void;
|
|
2
19
|
declare global {
|
|
3
20
|
interface Server {
|
|
4
|
-
/** `serv.tabComplete`
|
|
21
|
+
/** `serv.tabComplete` holds the argument types commands complete with (`tab: ['blockX', 'block', ...]` in `serv.commands.add`)
|
|
5
22
|
*
|
|
6
23
|
* You can provide your types:
|
|
7
24
|
* ```js
|
|
8
|
-
* serv.tabComplete.add('tabId', () => {
|
|
25
|
+
* serv.tabComplete.add('tabId', (lookedAtBlock, typed, { args, player }) => {
|
|
9
26
|
* return ['some', 'values', 'in array', 'ONLY STRINGS!']
|
|
10
27
|
* })
|
|
11
28
|
* ```
|
|
12
29
|
*/
|
|
13
30
|
'tabComplete': {
|
|
14
|
-
types:
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
types: Record<string, TabCompleteType>;
|
|
32
|
+
add: (id: string, cb: TabCompleteType) => void;
|
|
33
|
+
/** the completions of a type for the word being typed */
|
|
34
|
+
matches: (id: string | undefined, lookedAtBlock?: any, typed?: string, ctx?: Partial<TabCompleteContext>) => string[];
|
|
35
|
+
/** @deprecated does nothing; completions are answered per player */
|
|
36
|
+
use: (id?: any, otherData?: any, existingContent?: string) => void;
|
|
17
37
|
};
|
|
18
38
|
}
|
|
19
39
|
}
|
|
@@ -1,123 +1,136 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.player = void 0;
|
|
3
|
+
exports.player = exports.server = void 0;
|
|
4
|
+
exports.commandNamesFor = commandNamesFor;
|
|
4
5
|
const change_case_1 = require("change-case");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
serv.tabComplete.use(serv.commands.tab(textSplit[0].slice(1), textSplit.length - 2), data.lookedAtBlock || data.block, textSplit[textSplit.length - 1]);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
sendTabComplete(cmds, textSplit[textSplit.length - 1]);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
serv.tabComplete.use('player', null, textSplit[textSplit.length - 1]);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
6
|
+
const blockArgument_1 = require("../blockArgument");
|
|
7
|
+
/** Vanilla game rules, offered next to the ones the world has stored. */
|
|
8
|
+
const VANILLA_GAMERULES = [
|
|
9
|
+
'announceAdvancements', 'commandBlockOutput', 'disableElytraMovementCheck', 'disableRaids', 'doDaylightCycle', 'doEntityDrops',
|
|
10
|
+
'doFireTick', 'doImmediateRespawn', 'doInsomnia', 'doLimitedCrafting', 'doMobLoot', 'doMobSpawning', 'doPatrolSpawning',
|
|
11
|
+
'doTileDrops', 'doTraderSpawning', 'doWeatherCycle', 'drowningDamage', 'fallDamage', 'fireDamage', 'forgiveDeadPlayers',
|
|
12
|
+
'keepInventory', 'logAdminCommands', 'maxCommandChainLength', 'maxEntityCramming', 'mobGriefing', 'naturalRegeneration',
|
|
13
|
+
'randomTickSpeed', 'reducedDebugInfo', 'sendCommandFeedback', 'showDeathMessages', 'spawnRadius', 'spectatorsGenerateChunks',
|
|
14
|
+
'universalAnger'
|
|
15
|
+
];
|
|
16
|
+
/** Commands the player may run (op commands only for ops), by every name they answer to (aliases included). */
|
|
17
|
+
function commandNamesFor(serv, player) {
|
|
18
|
+
const names = new Set();
|
|
19
|
+
for (const [path, command] of Object.entries(serv.commands.hash)) {
|
|
20
|
+
if (path.includes(' ') || !command?.params?.base)
|
|
21
|
+
continue;
|
|
22
|
+
if (command.params.op && player && !player.op)
|
|
23
|
+
continue;
|
|
24
|
+
names.add(path);
|
|
25
|
+
}
|
|
26
|
+
return [...names];
|
|
27
|
+
}
|
|
28
|
+
const server = function (serv) {
|
|
29
|
+
const types = {};
|
|
39
30
|
serv.tabComplete = {
|
|
40
|
-
types
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
const matches = this.types[id](otherData) || this.types.player();
|
|
45
|
-
sendTabComplete(matches, existingContent);
|
|
31
|
+
types,
|
|
32
|
+
add(id, cb) {
|
|
33
|
+
types[id] = cb;
|
|
46
34
|
},
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
matches(id, lookedAtBlock = null, typed = '', ctx = {}) {
|
|
36
|
+
if (!id || !types[id])
|
|
37
|
+
return [];
|
|
38
|
+
const all = types[id](lookedAtBlock, typed, { typed, args: [], ...ctx }) ?? [];
|
|
39
|
+
return [...new Set(all.filter(match => typeof match === 'string' && match.startsWith(typed)))];
|
|
40
|
+
},
|
|
41
|
+
use() {
|
|
42
|
+
// the old API answered the player that logged in last; completions are answered per player now (see `player` below)
|
|
49
43
|
}
|
|
50
44
|
};
|
|
51
|
-
serv.tabComplete.add(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const playerNames = [];
|
|
75
|
-
const selectors = ['@p', '@a', '@e', '@r'];
|
|
76
|
-
for (const player of serv.players)
|
|
77
|
-
playerNames.push(player.username);
|
|
78
|
-
for (const sel in selectors)
|
|
79
|
-
playerNames.push(selectors[sel]);
|
|
80
|
-
return playerNames;
|
|
45
|
+
const add = (id, cb) => serv.tabComplete.add(id, cb);
|
|
46
|
+
const mcData = () => serv.mcData;
|
|
47
|
+
add('player', () => serv.players.map(p => p.username));
|
|
48
|
+
add('selector', () => ['@p', '@a', '@e', '@r', '@s', ...serv.players.map(p => p.username)]);
|
|
49
|
+
add('item', () => mcData().itemsArray.map(item => item.name));
|
|
50
|
+
add('block', (_, typed) => (0, blockArgument_1.completeBlockArgument)(mcData(), typed));
|
|
51
|
+
add('entity', () => mcData().entitiesArray.map(item => item.name));
|
|
52
|
+
add('effect', () => mcData().effectsArray.map(item => (0, change_case_1.snakeCase)(item.name)));
|
|
53
|
+
add('item_enchantment', () => (mcData().enchantmentsArray ?? []).map(e => e.name));
|
|
54
|
+
add('sound', () => (mcData().soundsArray ?? Object.values(mcData().sounds ?? {})).map((s) => s.name).filter(Boolean));
|
|
55
|
+
add('particle', () => (mcData().particlesArray ?? []).map((p) => String(p.id)));
|
|
56
|
+
add('number', () => ['1']);
|
|
57
|
+
add('boolean', () => ['true', 'false']);
|
|
58
|
+
// free text (messages, reasons, new names): nothing to suggest, but the client gets an answer instead of a timeout
|
|
59
|
+
add('text', () => []);
|
|
60
|
+
add('command', (_, __, ctx) => commandNamesFor(serv, ctx.player));
|
|
61
|
+
add('time', () => ['add', 'set', 'query']);
|
|
62
|
+
add('timeValue', (_, __, ctx) => {
|
|
63
|
+
if (ctx.args[0] === 'query')
|
|
64
|
+
return ['daytime', 'gametime', 'day'];
|
|
65
|
+
if (ctx.args[0] === 'set')
|
|
66
|
+
return ['day', 'noon', 'night', 'midnight', '1000', '6000', '13000', '18000'];
|
|
67
|
+
return ['100', '1000', '12000'];
|
|
81
68
|
});
|
|
82
|
-
|
|
83
|
-
|
|
69
|
+
add('gamemode', () => ['survival', 'creative', 'adventure', 'spectator']);
|
|
70
|
+
add('difficulty', () => ['peaceful', 'easy', 'normal', 'hard']);
|
|
71
|
+
add('weather', () => ['clear', 'rain']);
|
|
72
|
+
add('gamerule', () => [...new Set([...VANILLA_GAMERULES, ...Object.keys(serv.gamerules ?? {})])]);
|
|
73
|
+
add('setblockMode', () => ['replace', 'keep', 'destroy']);
|
|
74
|
+
add('fillMode', () => ['replace', 'keep', 'hollow', 'outline', 'destroy']);
|
|
75
|
+
// /fill ... replace <filter>
|
|
76
|
+
add('fillFilter', (_, typed, ctx) => ctx.args[7] === 'replace' ? (0, blockArgument_1.completeBlockArgument)(mcData(), typed) : []);
|
|
77
|
+
add('titleAction', () => ['title', 'subtitle', 'actionbar', 'times', 'clear', 'reset']);
|
|
78
|
+
add('enderfight', () => ['start', 'reset', 'state']);
|
|
79
|
+
add('axis', () => ['x', 'z']);
|
|
80
|
+
add('world', () => Object.keys(serv.worlds ?? {}));
|
|
81
|
+
add('mvAction', () => ['create', 'list', 'info', 'who', 'tp', 'remove']);
|
|
82
|
+
// after /mv <action>: create takes a new name, list nothing, the others an existing world
|
|
83
|
+
add('mvTarget', (_, __, ctx) => ['create', 'list'].includes(ctx.args[0]) ? [] : Object.keys(serv.worlds ?? {}));
|
|
84
|
+
add('mvEnvironment', (_, __, ctx) => ctx.args[0] === 'create' ? ['normal', 'nether', 'end'] : []);
|
|
85
|
+
add('worldEnvironment', () => ['normal', 'nether', 'end']);
|
|
86
|
+
add('recipeAction', () => ['list', 'info', 'new', 'set', 'regen', 'apply', 'edit', 'editor']);
|
|
87
|
+
add('lootTable', () => (serv.containers?.gameData?.lootTableIds?.() ?? []).map(id => id.replace(/^minecraft:/, '')));
|
|
88
|
+
add('xp', () => ['1', '10', '1L', '10L']);
|
|
89
|
+
// coordinates: the looked at block's, or relative to the player
|
|
90
|
+
const coordinate = (axis) => blockInfo => blockInfo ? [String(blockInfo[axis]), '~'] : ['~'];
|
|
91
|
+
add('blockX', coordinate('x'));
|
|
92
|
+
add('blockY', coordinate('y'));
|
|
93
|
+
add('blockZ', coordinate('z'));
|
|
94
|
+
// /tp <player> | <x> <y> <z>
|
|
95
|
+
add('playerOrX', blockInfo => [...serv.players.map(p => p.username), ...(blockInfo ? [String(blockInfo.x)] : []), '~']);
|
|
96
|
+
const isCoordinate = (arg) => !!arg && /^~?-?[\d.]*$/.test(arg);
|
|
97
|
+
// /tp <x> <y> <z> | <target> <destination player | x y z>
|
|
98
|
+
add('tpArg1', (blockInfo, typed, ctx) => isCoordinate(ctx.args[0]) ? types.blockY(blockInfo, typed, ctx) : types.playerOrX(blockInfo, typed, ctx));
|
|
99
|
+
add('tpArg2', (blockInfo, typed, ctx) => {
|
|
100
|
+
if (isCoordinate(ctx.args[0]))
|
|
101
|
+
return types.blockZ(blockInfo, typed, ctx);
|
|
102
|
+
return isCoordinate(ctx.args[1]) ? types.blockY(blockInfo, typed, ctx) : [];
|
|
84
103
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
add('warps', () => (serv.warps ?? []).map(w => w.name));
|
|
105
|
+
};
|
|
106
|
+
exports.server = server;
|
|
107
|
+
const player = function (player, serv) {
|
|
108
|
+
const send = (matches) => {
|
|
109
|
+
player._client.write('tab_complete', {
|
|
110
|
+
matches: !serv.supportFeature('tabCompleteHasAToolTip') ? matches : matches.map(match => ({ match, tooltip: '' }))
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
player._client.on('tab_complete', function (data) {
|
|
114
|
+
const text = data.text ?? '';
|
|
115
|
+
const words = text.split(' ');
|
|
116
|
+
const typed = words[words.length - 1];
|
|
117
|
+
const lookedAtBlock = data.lookedAtBlock || data.block || null;
|
|
118
|
+
if (!text.startsWith('/')) {
|
|
119
|
+
send(serv.tabComplete.matches('player', null, typed, { player }));
|
|
120
|
+
return;
|
|
92
121
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (blockInfo === null)
|
|
106
|
-
return [''];
|
|
107
|
-
const y = String(blockInfo.y);
|
|
108
|
-
return [y || ''];
|
|
109
|
-
});
|
|
110
|
-
serv.tabComplete.add('blockZ', (blockInfo) => {
|
|
111
|
-
if (blockInfo === null)
|
|
112
|
-
return [''];
|
|
113
|
-
const z = String(blockInfo.z);
|
|
114
|
-
return [z || ''];
|
|
115
|
-
});
|
|
116
|
-
serv.tabComplete.add('item_enchantment', () => {
|
|
117
|
-
return ['unbreaking', 'silk_touch', 'fortune'];
|
|
118
|
-
});
|
|
119
|
-
serv.tabComplete.add('warps', () => {
|
|
120
|
-
return serv.warps.map(w => w.name);
|
|
122
|
+
const name = words[0].slice(1);
|
|
123
|
+
if (words.length === 1) {
|
|
124
|
+
send(commandNamesFor(serv, player).map(cmd => `/${cmd}`).filter(cmd => cmd.startsWith(text)));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const found = serv.commands.find(name);
|
|
128
|
+
if (!found || (found[0].params.op && !player.op)) {
|
|
129
|
+
send([]);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const args = words.slice(1, -1);
|
|
133
|
+
send(serv.tabComplete.matches(serv.commands.tab(name, args.length), lookedAtBlock, typed, { player, lookedAtBlock, args }));
|
|
121
134
|
});
|
|
122
135
|
};
|
|
123
136
|
exports.player = player;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|