@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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const minecraft_data_1 = __importDefault(require("minecraft-data"));
|
|
9
|
+
const command_1 = __importDefault(require("../command"));
|
|
10
|
+
const tabComplete_1 = require("./tabComplete");
|
|
11
|
+
const VERSION = '1.20.1';
|
|
12
|
+
function setup({ op = true } = {}) {
|
|
13
|
+
const commands = new command_1.default({});
|
|
14
|
+
commands.add({ base: 'setblock', info: '', usage: '', op: true, tab: ['blockX', 'blockY', 'blockZ', 'block', 'setblockMode'], action: () => { } });
|
|
15
|
+
commands.add({ base: 'teleport', aliases: ['/tp'], info: '', usage: '', op: true, tab: ['playerOrX', 'tpArg1', 'tpArg2', 'blockZ'], action: () => { } });
|
|
16
|
+
commands.add({ base: 'mv', info: '', usage: '', op: true, tab: ['mvAction', 'mvTarget', 'mvEnvironment'], action: () => { } });
|
|
17
|
+
commands.add({ base: 'version', info: '', usage: '', tab: [], action: () => { } });
|
|
18
|
+
commands.add({ base: 'gamemode', aliases: ['/gm'], info: '', usage: '', op: true, tab: ['gamemode', 'player'], action: () => { } });
|
|
19
|
+
const client = new events_1.EventEmitter();
|
|
20
|
+
const written = [];
|
|
21
|
+
client.write = (name, data) => written.push({ name, data });
|
|
22
|
+
const player = { username: 'Steve', op, _client: client };
|
|
23
|
+
const serv = {
|
|
24
|
+
commands,
|
|
25
|
+
mcData: (0, minecraft_data_1.default)(VERSION),
|
|
26
|
+
players: [player],
|
|
27
|
+
worlds: { overworld: {}, nether: {}, flat: {} },
|
|
28
|
+
gamerules: {},
|
|
29
|
+
supportFeature: (f) => f === 'tabCompleteHasAToolTip'
|
|
30
|
+
};
|
|
31
|
+
(0, tabComplete_1.server)(serv);
|
|
32
|
+
(0, tabComplete_1.player)(player, serv);
|
|
33
|
+
const complete = (text, lookedAtBlock = null) => {
|
|
34
|
+
written.length = 0;
|
|
35
|
+
client.emit('tab_complete', { text, lookedAtBlock });
|
|
36
|
+
(0, vitest_1.expect)(written, `one answer for "${text}"`).toHaveLength(1);
|
|
37
|
+
return written[0].data.matches.map((m) => m.match ?? m);
|
|
38
|
+
};
|
|
39
|
+
return { complete };
|
|
40
|
+
}
|
|
41
|
+
(0, vitest_1.test)('command names include aliases and hide op commands from non ops', () => {
|
|
42
|
+
const { complete } = setup();
|
|
43
|
+
(0, vitest_1.expect)(complete('/t')).toEqual(vitest_1.expect.arrayContaining(['/teleport', '/tp']));
|
|
44
|
+
(0, vitest_1.expect)(complete('/g')).toEqual(vitest_1.expect.arrayContaining(['/gamemode', '/gm']));
|
|
45
|
+
(0, vitest_1.expect)(setup({ op: false }).complete('/')).toEqual(['/version']);
|
|
46
|
+
});
|
|
47
|
+
(0, vitest_1.test)('every argument gets an answer, even with nothing to suggest (no client timeout)', () => {
|
|
48
|
+
const { complete } = setup();
|
|
49
|
+
(0, vitest_1.expect)(complete('/version ')).toEqual([]);
|
|
50
|
+
(0, vitest_1.expect)(complete('/setblock 1 2 3 stone replace extra ')).toEqual([]);
|
|
51
|
+
(0, vitest_1.expect)(complete('/nosuchcommand ')).toEqual([]);
|
|
52
|
+
});
|
|
53
|
+
(0, vitest_1.test)('setblock: coordinates, block names, block states, mode', () => {
|
|
54
|
+
const { complete } = setup();
|
|
55
|
+
(0, vitest_1.expect)(complete('/setblock ', { x: 5, y: 64, z: -3 })).toEqual(['5', '~']);
|
|
56
|
+
(0, vitest_1.expect)(complete('/setblock 5 ', { x: 5, y: 64, z: -3 })).toEqual(['64', '~']);
|
|
57
|
+
(0, vitest_1.expect)(complete('/setblock 5 64 -3 lad')).toEqual(['ladder']);
|
|
58
|
+
(0, vitest_1.expect)(complete('/setblock 5 64 -3 ladder[')).toEqual(['ladder[facing=', 'ladder[waterlogged=']);
|
|
59
|
+
(0, vitest_1.expect)(complete('/setblock 5 64 -3 ladder[facing=w')).toEqual(['ladder[facing=west,', 'ladder[facing=west]']);
|
|
60
|
+
(0, vitest_1.expect)(complete('/setblock 5 64 -3 ladder[facing=west] ')).toEqual(['replace', 'keep', 'destroy']);
|
|
61
|
+
});
|
|
62
|
+
(0, vitest_1.test)('aliases complete like their command (/tp, /gm)', () => {
|
|
63
|
+
const { complete } = setup();
|
|
64
|
+
(0, vitest_1.expect)(complete('/tp ')).toEqual(['Steve', '~']);
|
|
65
|
+
(0, vitest_1.expect)(complete('/tp Steve ')).toEqual(['Steve', '~']);
|
|
66
|
+
(0, vitest_1.expect)(complete('/tp 1 ')).toEqual(['~']);
|
|
67
|
+
(0, vitest_1.expect)(complete('/gm ')).toEqual(['survival', 'creative', 'adventure', 'spectator']);
|
|
68
|
+
(0, vitest_1.expect)(complete('/gm creative ')).toEqual(['Steve']);
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.test)('/mv: action, then worlds or environments', () => {
|
|
71
|
+
const { complete } = setup();
|
|
72
|
+
(0, vitest_1.expect)(complete('/mv ')).toEqual(['create', 'list', 'info', 'who', 'tp', 'remove']);
|
|
73
|
+
(0, vitest_1.expect)(complete('/mv tp ')).toEqual(['overworld', 'nether', 'flat']);
|
|
74
|
+
(0, vitest_1.expect)(complete('/mv create ')).toEqual([]);
|
|
75
|
+
(0, vitest_1.expect)(complete('/mv create skyblock ')).toEqual(['normal', 'nether', 'end']);
|
|
76
|
+
});
|
package/dist/lib/modules/tp.js
CHANGED
|
@@ -12,6 +12,7 @@ const server = (serv) => {
|
|
|
12
12
|
aliases: ['/tp'],
|
|
13
13
|
info: 'to teleport a player',
|
|
14
14
|
usage: '/teleport [target player] <destination player or x> [y] [z]',
|
|
15
|
+
tab: ['playerOrX', 'tpArg1', 'tpArg2', 'blockZ'],
|
|
15
16
|
op: true,
|
|
16
17
|
parse(str) {
|
|
17
18
|
return str.match(/^(((.* )?~?-?\d* ~?-?\d* ~?-?\d*)|(.+ .+))$/) ? str.split(' ') : false;
|
|
@@ -104,6 +104,7 @@ const server = async function (serv, options) {
|
|
|
104
104
|
base: 'home',
|
|
105
105
|
info: 'Teleport to your home',
|
|
106
106
|
usage: '/home',
|
|
107
|
+
tab: [],
|
|
107
108
|
op: false, // todo
|
|
108
109
|
commandBlock: false,
|
|
109
110
|
async action({}, { player }) {
|
|
@@ -114,6 +115,7 @@ const server = async function (serv, options) {
|
|
|
114
115
|
base: 'sethome',
|
|
115
116
|
info: 'Set your home',
|
|
116
117
|
usage: '/sethome',
|
|
118
|
+
tab: [],
|
|
117
119
|
op: false, // todo
|
|
118
120
|
commandBlock: false,
|
|
119
121
|
async action({}, { player }) {
|
|
@@ -493,6 +493,7 @@ const server = async function (serv, options) {
|
|
|
493
493
|
base: 'changeworld',
|
|
494
494
|
info: 'to change world',
|
|
495
495
|
usage: '/changeworld <world> (overworld | nether | end | any world created with /mv create)',
|
|
496
|
+
tab: ['world'],
|
|
496
497
|
onlyPlayer: true,
|
|
497
498
|
op: true,
|
|
498
499
|
action(name, ctx) {
|
|
@@ -506,6 +507,7 @@ const server = async function (serv, options) {
|
|
|
506
507
|
base: 'seed',
|
|
507
508
|
info: 'Get world\'s seed',
|
|
508
509
|
usage: '/seed',
|
|
510
|
+
tab: [],
|
|
509
511
|
action(data, ctx) {
|
|
510
512
|
const world = ctx.player?.world ?? serv.overworld;
|
|
511
513
|
// todo need concept of command output
|
|
@@ -95,6 +95,7 @@ const server = function (serv) {
|
|
|
95
95
|
base: 'mv',
|
|
96
96
|
info: 'Multiverse-style world management',
|
|
97
97
|
usage: '/mv <create|list|info|who|tp|remove> ...',
|
|
98
|
+
tab: ['mvAction', 'mvTarget', 'mvEnvironment'],
|
|
98
99
|
op: true,
|
|
99
100
|
parse: (str) => tokenize(str),
|
|
100
101
|
async action(tokens, ctx) {
|
|
@@ -110,6 +111,7 @@ const server = function (serv) {
|
|
|
110
111
|
base: 'mv' + sub,
|
|
111
112
|
info: `/mv ${sub}`,
|
|
112
113
|
usage: `/mv${sub} ...`,
|
|
114
|
+
tab: sub === 'create' ? ['text', 'worldEnvironment'] : sub === 'list' ? [] : ['world'],
|
|
113
115
|
op: true,
|
|
114
116
|
parse: (str) => tokenize(str),
|
|
115
117
|
action: async (tokens, ctx) => await actions[sub](tokens, ctx)
|