@james-pre/mc-admin 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/LICENSE.md +675 -0
- package/README.md +15 -0
- package/dist/buffers.d.ts +1 -0
- package/dist/buffers.js +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +110 -0
- package/dist/common/buffers.d.ts +8 -0
- package/dist/common/buffers.js +47 -0
- package/dist/common/chunk.d.ts +41 -0
- package/dist/common/chunk.js +31 -0
- package/dist/common/index.d.ts +7 -0
- package/dist/common/index.js +7 -0
- package/dist/common/level.d.ts +21 -0
- package/dist/common/level.js +16 -0
- package/dist/common/log.d.ts +13 -0
- package/dist/common/log.js +10 -0
- package/dist/common/nbt.d.ts +85 -0
- package/dist/common/nbt.js +179 -0
- package/dist/common/rcon.d.ts +58 -0
- package/dist/common/rcon.js +154 -0
- package/dist/common/region.d.ts +52 -0
- package/dist/common/region.js +128 -0
- package/dist/common/snbt.d.ts +98 -0
- package/dist/common/snbt.js +332 -0
- package/dist/common/tsconfig.tsbuildinfo +1 -0
- package/dist/config.d.ts +20 -0
- package/dist/config.js +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/level.d.ts +53 -0
- package/dist/level.js +136 -0
- package/dist/log.d.ts +18 -0
- package/dist/log.js +137 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +9 -0
- package/dist/nbt.d.ts +1 -0
- package/dist/nbt.js +1 -0
- package/dist/prune.d.ts +85 -0
- package/dist/prune.js +201 -0
- package/dist/rcon.d.ts +12 -0
- package/dist/rcon.js +19 -0
- package/dist/region.d.ts +1 -0
- package/dist/region.js +1 -0
- package/dist/snbt.d.ts +14 -0
- package/dist/snbt.js +63 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +52 -0
- package/package.json +68 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { TagType } from './nbt.js';
|
|
2
|
+
export class SnbtError extends SyntaxError {
|
|
3
|
+
position;
|
|
4
|
+
constructor(message,
|
|
5
|
+
/** Index into the source where parsing gave up. */
|
|
6
|
+
position) {
|
|
7
|
+
super(`${message} (at ${position})`);
|
|
8
|
+
this.position = position;
|
|
9
|
+
this.name = 'SnbtError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
// Sticky, so they match at the cursor without slicing the source apart.
|
|
13
|
+
const numberPattern = /([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)([bslfdBSLFD]?)/y;
|
|
14
|
+
const wordPattern = /[A-Za-z0-9_.+-]+/y;
|
|
15
|
+
const arrayPattern = /([BIL]);/y;
|
|
16
|
+
const booleanPattern = /true|false/y;
|
|
17
|
+
// A bare number or word runs until the first character that can't be part of one.
|
|
18
|
+
const wordChar = /[A-Za-z0-9_.+-]/;
|
|
19
|
+
const integer = /^[-+]?\d+$/;
|
|
20
|
+
const hex = /^[0-9a-fA-F]{4}$/;
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const escapes = { b: '\b', f: '\f', n: '\n', r: '\r', s: ' ', t: '\t' };
|
|
23
|
+
/** @internal */
|
|
24
|
+
export const suffixTags = {
|
|
25
|
+
b: TagType.Byte,
|
|
26
|
+
s: TagType.Short,
|
|
27
|
+
l: TagType.Long,
|
|
28
|
+
f: TagType.Float,
|
|
29
|
+
d: TagType.Double,
|
|
30
|
+
};
|
|
31
|
+
/** The letter printed after a number of each type. Ints get nothing. */
|
|
32
|
+
export const tagSuffixes = {
|
|
33
|
+
[TagType.Byte]: 'b',
|
|
34
|
+
[TagType.Short]: 's',
|
|
35
|
+
[TagType.Long]: 'L',
|
|
36
|
+
[TagType.Float]: 'f',
|
|
37
|
+
[TagType.Double]: 'd',
|
|
38
|
+
};
|
|
39
|
+
/** The marker a typed array leads with, and the suffix its items carry. */
|
|
40
|
+
export const arrayMarkers = {
|
|
41
|
+
[TagType.ByteArray]: ['B', 'b'],
|
|
42
|
+
[TagType.IntArray]: ['I', ''],
|
|
43
|
+
[TagType.LongArray]: ['L', 'L'],
|
|
44
|
+
};
|
|
45
|
+
/** @internal */
|
|
46
|
+
export class Parser {
|
|
47
|
+
source;
|
|
48
|
+
offset = 0;
|
|
49
|
+
bareStrings;
|
|
50
|
+
constructor(source, options = {}) {
|
|
51
|
+
this.source = source;
|
|
52
|
+
this.bareStrings = options.bareStrings ?? false;
|
|
53
|
+
}
|
|
54
|
+
error(message, position = this.offset) {
|
|
55
|
+
throw new SnbtError(message, position);
|
|
56
|
+
}
|
|
57
|
+
get current() {
|
|
58
|
+
return this.source.charAt(this.offset);
|
|
59
|
+
}
|
|
60
|
+
skipSpace() {
|
|
61
|
+
while (/\s/.test(this.current))
|
|
62
|
+
this.offset++;
|
|
63
|
+
}
|
|
64
|
+
take(literal) {
|
|
65
|
+
if (!this.source.startsWith(literal, this.offset))
|
|
66
|
+
return false;
|
|
67
|
+
this.offset += literal.length;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
expect(literal) {
|
|
71
|
+
if (!this.take(literal))
|
|
72
|
+
this.error(`expected "${literal}"`);
|
|
73
|
+
}
|
|
74
|
+
match(pattern) {
|
|
75
|
+
pattern.lastIndex = this.offset;
|
|
76
|
+
return pattern.exec(this.source);
|
|
77
|
+
}
|
|
78
|
+
/** True when the character after a `length`-long match would continue the word. */
|
|
79
|
+
continues(length) {
|
|
80
|
+
return wordChar.test(this.source.charAt(this.offset + length));
|
|
81
|
+
}
|
|
82
|
+
/** The character(s) a backslash stands for. */
|
|
83
|
+
escape() {
|
|
84
|
+
const start = this.offset;
|
|
85
|
+
const char = this.source.charAt(this.offset++);
|
|
86
|
+
if (char === '\\' || char === '"' || char === "'")
|
|
87
|
+
return char;
|
|
88
|
+
const mapped = escapes[char];
|
|
89
|
+
if (mapped)
|
|
90
|
+
return mapped;
|
|
91
|
+
if (char === 'u') {
|
|
92
|
+
const digits = this.source.slice(this.offset, this.offset + 4);
|
|
93
|
+
if (!hex.test(digits))
|
|
94
|
+
this.error('invalid unicode escape', start);
|
|
95
|
+
this.offset += 4;
|
|
96
|
+
return String.fromCharCode(parseInt(digits, 16));
|
|
97
|
+
}
|
|
98
|
+
this.error(`invalid escape "\\${char}"`, start);
|
|
99
|
+
}
|
|
100
|
+
/** A quoted string, or null when the cursor isn't on a quote. */
|
|
101
|
+
quoted() {
|
|
102
|
+
const quote = this.current;
|
|
103
|
+
if (quote !== '"' && quote !== "'")
|
|
104
|
+
return null;
|
|
105
|
+
const start = this.offset++;
|
|
106
|
+
let value = '';
|
|
107
|
+
while (this.offset < this.source.length) {
|
|
108
|
+
const char = this.source.charAt(this.offset++);
|
|
109
|
+
if (char === quote)
|
|
110
|
+
return value;
|
|
111
|
+
if (char !== '\\') {
|
|
112
|
+
value += char;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
value += this.escape();
|
|
116
|
+
}
|
|
117
|
+
this.error('unterminated string', start);
|
|
118
|
+
}
|
|
119
|
+
/** A compound key: quoted, or a bare word. */
|
|
120
|
+
key() {
|
|
121
|
+
const quoted = this.quoted();
|
|
122
|
+
if (quoted !== null)
|
|
123
|
+
return quoted;
|
|
124
|
+
const match = this.match(wordPattern);
|
|
125
|
+
if (!match)
|
|
126
|
+
this.error('expected a key');
|
|
127
|
+
this.offset += match[0].length;
|
|
128
|
+
return match[0];
|
|
129
|
+
}
|
|
130
|
+
/** A number with its optional type suffix, or null when the cursor isn't on one. */
|
|
131
|
+
number() {
|
|
132
|
+
const match = this.match(numberPattern);
|
|
133
|
+
if (!match)
|
|
134
|
+
return null;
|
|
135
|
+
const [text, digits, suffix] = match;
|
|
136
|
+
// `1.5x` isn't a number followed by a word; the whole run is one word.
|
|
137
|
+
if (this.continues(text.length))
|
|
138
|
+
return null;
|
|
139
|
+
const start = this.offset;
|
|
140
|
+
this.offset += text.length;
|
|
141
|
+
return this.numeric(digits, suffix, start);
|
|
142
|
+
}
|
|
143
|
+
/** `true` and `false` are how the game prints bytes it knows are flags. */
|
|
144
|
+
boolean() {
|
|
145
|
+
const match = this.match(booleanPattern);
|
|
146
|
+
if (!match || this.continues(match[0].length))
|
|
147
|
+
return null;
|
|
148
|
+
this.offset += match[0].length;
|
|
149
|
+
return { type: TagType.Byte, value: match[0] === 'true' ? 1 : 0 };
|
|
150
|
+
}
|
|
151
|
+
/** An unsuffixed number is an int, or a double once it has a fraction or an exponent. */
|
|
152
|
+
numeric(digits, suffix, position) {
|
|
153
|
+
const type = suffix ? suffixTags[suffix.toLowerCase()] : /[.eE]/.test(digits) ? TagType.Double : TagType.Int;
|
|
154
|
+
switch (type) {
|
|
155
|
+
case TagType.Byte:
|
|
156
|
+
return { type: TagType.Byte, value: this.whole(digits, position) };
|
|
157
|
+
case TagType.Short:
|
|
158
|
+
return { type: TagType.Short, value: this.whole(digits, position) };
|
|
159
|
+
case TagType.Int:
|
|
160
|
+
return { type: TagType.Int, value: this.whole(digits, position) };
|
|
161
|
+
case TagType.Long:
|
|
162
|
+
return { type: TagType.Long, value: BigInt(this.whole(digits, position)) };
|
|
163
|
+
case TagType.Float:
|
|
164
|
+
return { type: TagType.Float, value: Number(digits) };
|
|
165
|
+
default:
|
|
166
|
+
return { type: TagType.Double, value: Number(digits) };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Integer types reject a fractional or exponential literal, e.g. `1.5b`. */
|
|
170
|
+
whole(digits, position) {
|
|
171
|
+
if (!integer.test(digits))
|
|
172
|
+
this.error(`"${digits}" is not an integer`, position);
|
|
173
|
+
return Number(digits);
|
|
174
|
+
}
|
|
175
|
+
/** The integer an array item carries, whatever suffix it was written with. */
|
|
176
|
+
arrayItem(tag, position) {
|
|
177
|
+
switch (tag.type) {
|
|
178
|
+
case TagType.Byte:
|
|
179
|
+
case TagType.Short:
|
|
180
|
+
case TagType.Int:
|
|
181
|
+
return BigInt(tag.value);
|
|
182
|
+
case TagType.Long:
|
|
183
|
+
return tag.value;
|
|
184
|
+
default:
|
|
185
|
+
this.error(`expected an integer, got a ${TagType[tag.type]}`, position);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
compound() {
|
|
189
|
+
this.expect('{');
|
|
190
|
+
const value = new Map();
|
|
191
|
+
this.skipSpace();
|
|
192
|
+
if (this.take('}'))
|
|
193
|
+
return { type: TagType.Compound, value };
|
|
194
|
+
for (;;) {
|
|
195
|
+
this.skipSpace();
|
|
196
|
+
const key = this.key();
|
|
197
|
+
this.skipSpace();
|
|
198
|
+
this.expect(':');
|
|
199
|
+
this.skipSpace();
|
|
200
|
+
value.set(key, this.value());
|
|
201
|
+
this.skipSpace();
|
|
202
|
+
if (this.take(','))
|
|
203
|
+
continue;
|
|
204
|
+
this.expect('}');
|
|
205
|
+
return { type: TagType.Compound, value };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/** A list, or one of the typed arrays that lead with their element type: `[I; 1, 2]`. */
|
|
209
|
+
list() {
|
|
210
|
+
this.expect('[');
|
|
211
|
+
const array = this.match(arrayPattern);
|
|
212
|
+
if (array) {
|
|
213
|
+
this.offset += array[0].length;
|
|
214
|
+
return this.array(array[1]);
|
|
215
|
+
}
|
|
216
|
+
const value = [];
|
|
217
|
+
this.skipSpace();
|
|
218
|
+
if (this.take(']'))
|
|
219
|
+
return { type: TagType.List, of: TagType.End, value };
|
|
220
|
+
for (;;) {
|
|
221
|
+
this.skipSpace();
|
|
222
|
+
const start = this.offset;
|
|
223
|
+
const item = this.value();
|
|
224
|
+
// Lists are homogeneous; the binary format has nowhere to put a second element type.
|
|
225
|
+
if (value.length && item.type !== value[0].type)
|
|
226
|
+
this.error(`expected a ${TagType[value[0].type]} item`, start);
|
|
227
|
+
value.push(item);
|
|
228
|
+
this.skipSpace();
|
|
229
|
+
if (this.take(','))
|
|
230
|
+
continue;
|
|
231
|
+
this.expect(']');
|
|
232
|
+
return { type: TagType.List, of: value[0].type, value };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/** The body of `[B;…]`, `[I;…]` or `[L;…]`, whose marker has already been consumed. */
|
|
236
|
+
array(marker) {
|
|
237
|
+
const items = [];
|
|
238
|
+
this.skipSpace();
|
|
239
|
+
if (!this.take(']'))
|
|
240
|
+
for (;;) {
|
|
241
|
+
this.skipSpace();
|
|
242
|
+
const start = this.offset;
|
|
243
|
+
items.push(this.arrayItem(this.value(), start));
|
|
244
|
+
this.skipSpace();
|
|
245
|
+
if (this.take(','))
|
|
246
|
+
continue;
|
|
247
|
+
this.expect(']');
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
switch (marker) {
|
|
251
|
+
case 'B':
|
|
252
|
+
return { type: TagType.ByteArray, value: Int8Array.from(items, Number) };
|
|
253
|
+
case 'I':
|
|
254
|
+
return { type: TagType.IntArray, value: Int32Array.from(items, Number) };
|
|
255
|
+
default:
|
|
256
|
+
return { type: TagType.LongArray, value: BigInt64Array.from(items) };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
value() {
|
|
260
|
+
const char = this.current;
|
|
261
|
+
if (char === '{')
|
|
262
|
+
return this.compound();
|
|
263
|
+
if (char === '[')
|
|
264
|
+
return this.list();
|
|
265
|
+
const quoted = this.quoted();
|
|
266
|
+
if (quoted !== null)
|
|
267
|
+
return { type: TagType.String, value: quoted };
|
|
268
|
+
const tag = this.boolean() ?? this.number();
|
|
269
|
+
if (tag)
|
|
270
|
+
return tag;
|
|
271
|
+
if (this.bareStrings) {
|
|
272
|
+
const match = this.match(wordPattern);
|
|
273
|
+
if (match) {
|
|
274
|
+
this.offset += match[0].length;
|
|
275
|
+
return { type: TagType.String, value: match[0] };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
this.error('expected a value');
|
|
279
|
+
}
|
|
280
|
+
/** One value and nothing else, ignoring the whitespace around it. */
|
|
281
|
+
document() {
|
|
282
|
+
this.skipSpace();
|
|
283
|
+
const tag = this.value();
|
|
284
|
+
this.skipSpace();
|
|
285
|
+
if (this.offset < this.source.length)
|
|
286
|
+
this.error('unexpected trailing input');
|
|
287
|
+
return tag;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Parse a whole SNBT document.
|
|
292
|
+
*
|
|
293
|
+
* @throws SnbtError when the source isn't well-formed SNBT.
|
|
294
|
+
*/
|
|
295
|
+
export function parse(source, options) {
|
|
296
|
+
return new Parser(source, options).document();
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Parse the value starting at `start`, returning it with the index just past it, or null when
|
|
300
|
+
* what's there isn't well-formed SNBT. Unlike {@link parse}, trailing text is fine.
|
|
301
|
+
*/
|
|
302
|
+
export function parseAt(source, start = 0, options) {
|
|
303
|
+
const parser = new Parser(source, options);
|
|
304
|
+
parser.offset = start;
|
|
305
|
+
try {
|
|
306
|
+
const tag = parser.value();
|
|
307
|
+
return { start, end: parser.offset, tag };
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
if (error instanceof SnbtError)
|
|
311
|
+
return null;
|
|
312
|
+
throw error;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Find the SNBT embedded in prose.
|
|
317
|
+
*/
|
|
318
|
+
export function* scan(text) {
|
|
319
|
+
let offset = 0;
|
|
320
|
+
while (offset < text.length) {
|
|
321
|
+
const char = text.charAt(offset);
|
|
322
|
+
if (char === '{' || char === '[') {
|
|
323
|
+
const span = parseAt(text, offset);
|
|
324
|
+
if (span) {
|
|
325
|
+
yield span;
|
|
326
|
+
offset = span.end;
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
offset++;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.es2024.d.ts","../../node_modules/typescript/lib/lib.es2025.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2024.collection.d.ts","../../node_modules/typescript/lib/lib.es2024.object.d.ts","../../node_modules/typescript/lib/lib.es2024.promise.d.ts","../../node_modules/typescript/lib/lib.es2024.regexp.d.ts","../../node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2024.string.d.ts","../../node_modules/typescript/lib/lib.es2025.collection.d.ts","../../node_modules/typescript/lib/lib.es2025.float16.d.ts","../../node_modules/typescript/lib/lib.es2025.intl.d.ts","../../node_modules/typescript/lib/lib.es2025.iterator.d.ts","../../node_modules/typescript/lib/lib.es2025.promise.d.ts","../../node_modules/typescript/lib/lib.es2025.regexp.d.ts","../../node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.date.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.error.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.esnext.temporal.d.ts","../../node_modules/typescript/lib/lib.esnext.typedarrays.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../src/common/buffers.ts","../../node_modules/utilium/dist/string.d.ts","../../node_modules/utilium/dist/numbers.d.ts","../../node_modules/utilium/dist/types.d.ts","../../node_modules/utilium/dist/type-math.d.ts","../../node_modules/utilium/dist/array.d.ts","../../node_modules/utilium/dist/buffer.d.ts","../../node_modules/utilium/dist/cache.d.ts","../../node_modules/utilium/dist/checksum.d.ts","../../node_modules/utilium/dist/color.d.ts","../../node_modules/utilium/dist/diff.d.ts","../../node_modules/utilium/dist/format.d.ts","../../node_modules/eventemitter3/index.d.ts","../../node_modules/utilium/dist/list.d.ts","../../node_modules/utilium/dist/misc.d.ts","../../node_modules/utilium/dist/objects.d.ts","../../node_modules/utilium/dist/random.d.ts","../../node_modules/utilium/dist/version.d.ts","../../node_modules/utilium/dist/index.d.ts","../../src/common/nbt.ts","../../src/common/chunk.ts","../../src/common/log.ts","../../src/common/rcon.ts","../../src/common/level.ts","../../src/common/region.ts","../../src/common/snbt.ts","../../src/common/index.ts"],"fileIdsList":[[92,93],[90,92,93],[90,91,92,93,94,95,96,97,98,99,100,102,103,104,105,106],[101],[90],[90,92,94,99],[93,94],[90,91,92,94],[94],[89,108],[108,109,110,111,113,114],[89,107],[107],[89,108,109,112],[108]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"8a15b4607d9a499e2dbeed9ec0d3c0d7372c850b2d5f1fb259e8f6d41d468a84","impliedFormat":1},{"version":"26e0fe14baee4e127f4365d1ae0b276f400562e45e19e35fd2d4c296684715e6","impliedFormat":1},{"version":"1e9332c23e9a907175e0ffc6a49e236f97b48838cc8aec9ce7e4cec21e544b65","impliedFormat":1},{"version":"3753fbc1113dc511214802a2342280a8b284ab9094f6420e7aa171e868679f91","impliedFormat":1},{"version":"999ca32883495a866aa5737fe1babc764a469e4cde6ee6b136a4b9ae68853e4b","impliedFormat":1},{"version":"17f13ecb98cbc39243f2eee1f16d45cd8ec4706b03ee314f1915f1a8b42f6984","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"db9709688f82c9e5f65a119c64d835f906efe5f559d08b11642d56eb85b79357","affectsGlobalScope":true,"impliedFormat":1},{"version":"4b25b8c874acd1a4cf8444c3617e037d444d19080ac9f634b405583fd10ce1f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"37be57d7c90cf1f8112ee2636a068d8fd181289f82b744160ec56a7dc158a9f5","affectsGlobalScope":true,"impliedFormat":1},{"version":"a917a49ac94cd26b754ab84e113369a75d1a47a710661d7cd25e961cc797065f","affectsGlobalScope":true,"impliedFormat":1},{"version":"6d3261badeb7843d157ef3e6f5d1427d0eeb0af0cf9df84a62cfd29fd47ac86e","affectsGlobalScope":true,"impliedFormat":1},{"version":"195daca651dde22f2167ac0d0a05e215308119a3100f5e6268e8317d05a92526","affectsGlobalScope":true,"impliedFormat":1},{"version":"8b11e4285cd2bb164a4dc09248bdec69e9842517db4ca47c1ba913011e44ff2f","affectsGlobalScope":true,"impliedFormat":1},{"version":"0508571a52475e245b02bc50fa1394065a0a3d05277fbf5120c3784b85651799","affectsGlobalScope":true,"impliedFormat":1},{"version":"8f9af488f510c3015af3cc8c267a9e9d96c4dd38a1fdff0e11dc5a544711415b","affectsGlobalScope":true,"impliedFormat":1},{"version":"fc611fea8d30ea72c6bbfb599c9b4d393ce22e2f5bfef2172534781e7d138104","affectsGlobalScope":true,"impliedFormat":1},{"version":"0bd714129fca875f7d4c477a1a392200b0bcd13fb2e80928cd334b63830ea047","affectsGlobalScope":true,"impliedFormat":1},{"version":"e2c9037ae6cd2c52d80ceef0b3c5ffdb488627d71529cf4f63776daf11161c9a","affectsGlobalScope":true,"impliedFormat":1},{"version":"135d5cf4d345f59f1a9caadfafcd858d3d9cc68290db616cc85797224448cccc","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc238c3f81c2984751932b6aab223cd5b830e0ac6cad76389e5e9d2ffc03287d","affectsGlobalScope":true,"impliedFormat":1},{"version":"4a07f9b76d361f572620927e5735b77d6d2101c23cdd94383eb5b706e7b36357","affectsGlobalScope":true,"impliedFormat":1},{"version":"7c4e8dc6ab834cc6baa0227e030606d29e3e8449a9f67cdf5605ea5493c4db29","affectsGlobalScope":true,"impliedFormat":1},{"version":"de7ba0fd02e06cd9a5bd4ab441ed0e122735786e67dde1e849cced1cd8b46b78","affectsGlobalScope":true,"impliedFormat":1},{"version":"6148e4e88d720a06855071c3db02069434142a8332cf9c182cda551adedf3156","affectsGlobalScope":true,"impliedFormat":1},{"version":"d63dba625b108316a40c95a4425f8d4294e0deeccfd6c7e59d819efa19e23409","affectsGlobalScope":true,"impliedFormat":1},{"version":"0568d6befee03dd435bed4fc25c4e46865b24bdcb8c563fdc21f580a2c301904","affectsGlobalScope":true,"impliedFormat":1},{"version":"30d62269b05b584741f19a5369852d5d34895aa2ac4fd948956f886d15f9cc0d","affectsGlobalScope":true,"impliedFormat":1},{"version":"f128dae7c44d8f35ee42e0a437000a57c9f06cc04f8b4fb42eebf44954d53dc8","affectsGlobalScope":true,"impliedFormat":1},{"version":"ffbe6d7b295306b2ba88030f65b74c107d8d99bdcf596ea99c62a02f606108b0","affectsGlobalScope":true,"impliedFormat":1},{"version":"996fb27b15277369c68a4ba46ed138b4e9e839a02fb4ec756f7997629242fd9f","affectsGlobalScope":true,"impliedFormat":1},{"version":"79b712591b270d4778c89706ca2cfc56ddb8c3f895840e477388f1710dc5eda9","affectsGlobalScope":true,"impliedFormat":1},{"version":"20884846cef428b992b9bd032e70a4ef88e349263f63aeddf04dda837a7dba26","affectsGlobalScope":true,"impliedFormat":1},{"version":"5fcab789c73a97cd43828ee3cc94a61264cf24d4c44472ce64ced0e0f148bdb2","affectsGlobalScope":true,"impliedFormat":1},{"version":"db59a81f070c1880ad645b2c0275022baa6a0c4f0acdc58d29d349c6efcf0903","affectsGlobalScope":true,"impliedFormat":1},{"version":"673294292640f5722b700e7d814e17aaf7d93f83a48a2c9b38f33cbc940ad8b0","affectsGlobalScope":true,"impliedFormat":1},{"version":"d786b48f934cbca483b3c6d0a798cb43bbb4ada283e76fb22c28e53ae05b9e69","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ecb8e347cb6b2a8927c09b86263663289418df375f5e68e11a0ae683776978f","affectsGlobalScope":true,"impliedFormat":1},{"version":"142efd4ce210576f777dc34df121777be89eda476942d6d6663b03dcb53be3ff","affectsGlobalScope":true,"impliedFormat":1},{"version":"379bc41580c2d774f82e828c70308f24a005b490c25ba34d679d84bcf05c3d9d","affectsGlobalScope":true,"impliedFormat":1},{"version":"ed484fb2aa8a1a23d0277056ec3336e0a0b52f9b8d6a961f338a642faf43235d","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ffedae1d1c2d53fdbca1c96d3c7dda544281f7d262f99b6880634f8fd8d9820","affectsGlobalScope":true,"impliedFormat":1},{"version":"83a730b125d477dd264df8ba479afab27a3dae7152b005c214ab94dc7ee44fd3","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},{"version":"40212e135889c8bf55a802e367804640dba3e8fd71f90952ef1b74837081a145","signature":"be546492a4f8f27eb2abdf4ae799d0c9a24b4e2850bab8c55dfa275f137ac5ad","impliedFormat":99},{"version":"61f6951f98a4f39565ce35f66f636b0c0d364084210bdff5c7096272a4da8903","impliedFormat":99},{"version":"9c427fd3bb472110aa61c711b3450cd3dbe788492c46ffc732776b2fd4ed85ea","impliedFormat":99},{"version":"2531b2f51ac9ba04a22ad7987f89031481c4aa6ac2a3ce0f192ee65bcd1b5d10","impliedFormat":99},{"version":"b067f0286eef57bd55119275a31de8ff555d240881cd01627c27b7c445039db8","impliedFormat":99},{"version":"052d3a7b8e76cbba55e1f2684b98d46e34ec48fa4af1c8da25e7cc68f70ca6bb","impliedFormat":99},{"version":"3eb41ae47ba431f8c9f38fbac9b2c53e69a5af312041dd65d1f20e4c473d8a31","impliedFormat":99},{"version":"b628a5149ec12e682a4916c4d468aa518bf5f2f592b0fa2684c424ed0b4a6280","impliedFormat":99},{"version":"95f665421c7deef99923cf393320b993db8cec1e0f63326148d8fc4d4e806ef8","impliedFormat":99},{"version":"fbd2f0ef2d93d4c35fef3de845345d0f542b58564b7c54c37cfbe9e2da43c8bf","impliedFormat":99},{"version":"36c742f7cf257c86bb5ee94ef72e207e74b35ba5e3d9d67da5a4be1a2e26b5d3","impliedFormat":99},{"version":"c3b896813c3e9b0e685d7544ed9251442167e1fb4df961502803767f47fa0795","impliedFormat":99},{"version":"27679e96d1bd38c5938178aaf4abe8627493090b63d6bae2ce8436e6a87ebe4d","impliedFormat":1},{"version":"ff46eb4bdd636d5a8f720756ec21452df2e105bb0cd80b96d05376b08141b08c","impliedFormat":99},{"version":"1dd10611e8f9e3079f746ee9f0dd743437e9237b0f92241b6aef523b3566e455","impliedFormat":99},{"version":"249254ec401231d3bfea263aa8789708fd18b02ad0943d516a3f87defc76ac89","impliedFormat":99},{"version":"564ea78832f8dfa40542dd1c538cd11191eb7cfc38af17b55500223c44b0b089","impliedFormat":99},{"version":"eb941b3cfaadb3ca5e6b4be104af1847c943a987626da97195ac4d86171a4406","impliedFormat":99},{"version":"527f5d2ca0e86607aa5c9838564dab2a1f2406272aeeb205bb44fd5ad4784388","impliedFormat":99},{"version":"bdb58a7c1f177673a7dee9d56f16012fe6f6aa71ae1a1184c26ffa3af98f1c57","signature":"bbd2d0b4f35bc5005d87d8444547b5c2b580885f172f3a8302fb5091e52b76c9","impliedFormat":99},{"version":"eb936cf968125a09ea897ea68a9d25c99c16306cf6446846502905dec4dc53a8","signature":"1179dc5522119bdbba170ada532f9767571ed47f8ba76ed185b2ea41aed7aeed","impliedFormat":99},{"version":"56c69bdf41bf6a3ce483d1685a60862288478e282e1e793ee6c3a9736c02f32a","signature":"28570acdf4b504b90a7219d0419b35c0a4460054aab17e56f5aba1bc8111a70f","impliedFormat":99},{"version":"317b82c21453cc2ee631f67ea29a61c5fe6361d17200f8583cad2d3b63c11aef","signature":"e4a65aa9d1daaa0dd3e919b1e4ba1e0fa76f0d73356e1ecdae5ec9979d168a7b","impliedFormat":99},{"version":"bed31b76e29a873d685ce123fbf83b93d70f5cc8cd95fd3c75ad578de91aa16c","signature":"61f2a658b0cc63da8bed6c1b1b8514ce93ef500f05f312211859d9b83056d58d","impliedFormat":99},{"version":"c30239964699d358027abab442baa6ea9019465c80b33dbbee605d669914ba9c","signature":"1278377c380203b7aacabedb4917bbdcedbf52daa596c61c0a7daddb89ac8ec3","impliedFormat":99},{"version":"1834cfb556ed367b3d234ec5372b073dcf883cc3f671402082145dd4b7c313e6","signature":"007b1e650c152ed072f0c636922abd6b7c9912466122273b732f8cb30b2ab831","impliedFormat":99},{"version":"85b183e851007abc429203dc14822028fe9fd4229cb88513f92de1818da61c64","impliedFormat":99}],"root":[89,[108,115]],"options":{"composite":true,"declaration":true,"module":199,"outDir":"./","rootDir":"../../src/common","strict":true,"target":99},"referencedMap":[[94,1],[99,2],[107,3],[102,4],[91,5],[104,6],[90,7],[93,8],[92,9],[109,10],[115,11],[108,12],[111,13],[113,14],[114,15]],"latestChangedDtsFile":"./index.d.ts","version":"6.0.3"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Manager as ConfigManager } from '@james-pre/config';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
export declare const configManager: ConfigManager<z.ZodObject<{
|
|
4
|
+
world_path: z.ZodDefault<z.ZodString>;
|
|
5
|
+
protected_regions: z.ZodDefault<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodArray<z.ZodTemplateLiteral<`${number},${number}`>>>>;
|
|
6
|
+
prune_threshold: z.ZodDefault<z.ZodNumber>;
|
|
7
|
+
}, z.core.$strip>, import("@james-pre/config").LoadOptions, {
|
|
8
|
+
world_path?: string | undefined;
|
|
9
|
+
protected_regions?: Record<string, `${number},${number}`[]> | undefined;
|
|
10
|
+
prune_threshold?: number | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
world_path?: string | undefined;
|
|
13
|
+
protected_regions?: Record<string, `${number},${number}`[]> | undefined;
|
|
14
|
+
prune_threshold?: number | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const config: {
|
|
17
|
+
world_path: string;
|
|
18
|
+
protected_regions: Record<string, `${number},${number}`[]>;
|
|
19
|
+
prune_threshold: number;
|
|
20
|
+
};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Manager as ConfigManager } from '@james-pre/config';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
import { normalizeId } from './level.js';
|
|
4
|
+
export const configManager = new ConfigManager(z.object({
|
|
5
|
+
world_path: z.string().default('/srv/mc'),
|
|
6
|
+
protected_regions: z
|
|
7
|
+
.record(z.string().transform(dim => normalizeId(dim)), z.templateLiteral([z.int(), ',', z.int()]).array())
|
|
8
|
+
.default({}),
|
|
9
|
+
/** Keep regions with at least this much play time, in seconds. */
|
|
10
|
+
prune_threshold: z.number().min(0).default(300),
|
|
11
|
+
}), { system: 'mc-admin' });
|
|
12
|
+
export const config = configManager.data;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * as chunk from './common/chunk.js';
|
|
2
|
+
export { Dimension, Level } from './level.js';
|
|
3
|
+
export * as level from './level.js';
|
|
4
|
+
export * as log from './log.js';
|
|
5
|
+
export * as nbt from './nbt.js';
|
|
6
|
+
export * as prune from './prune.js';
|
|
7
|
+
export * as rcon from './rcon.js';
|
|
8
|
+
export { Region } from './region.js';
|
|
9
|
+
export * as region from './region.js';
|
|
10
|
+
export * as snbt from './snbt.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * as chunk from './common/chunk.js';
|
|
2
|
+
export { Dimension, Level } from './level.js';
|
|
3
|
+
export * as level from './level.js';
|
|
4
|
+
export * as log from './log.js';
|
|
5
|
+
export * as nbt from './nbt.js';
|
|
6
|
+
export * as prune from './prune.js';
|
|
7
|
+
export * as rcon from './rcon.js';
|
|
8
|
+
export { Region } from './region.js';
|
|
9
|
+
export * as region from './region.js';
|
|
10
|
+
export * as snbt from './snbt.js';
|
package/dist/level.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Parsed as Chunk } from './common/chunk.js';
|
|
2
|
+
import type { RegionFile, RegionKind } from './common/level.js';
|
|
3
|
+
import type { Named } from './common/nbt.js';
|
|
4
|
+
import { Region } from './common/region.js';
|
|
5
|
+
export * from './common/level.js';
|
|
6
|
+
/** Whether a directory is a level root rather than a single dimension's directory. */
|
|
7
|
+
export declare function isLevel(path: string): Promise<boolean>;
|
|
8
|
+
/** One dimension's directory: its region files and the chunks in them. */
|
|
9
|
+
export declare class Dimension {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly id: string;
|
|
12
|
+
/** The level root this dimension belongs to. */
|
|
13
|
+
readonly level: string;
|
|
14
|
+
constructor(path: string, id: string,
|
|
15
|
+
/** The level root this dimension belongs to. */
|
|
16
|
+
level: string);
|
|
17
|
+
/** Where a region's file belongs, whether or not it exists. */
|
|
18
|
+
regionFile(kind: RegionKind, x: number, z: number): RegionFile;
|
|
19
|
+
/** Every region file of one kind, sorted by name. */
|
|
20
|
+
regionFiles(kind?: RegionKind): Promise<RegionFile[]>;
|
|
21
|
+
/** Each kind's file for one region, skipping the kinds that don't have it. */
|
|
22
|
+
regionFilesAt(x: number, z: number): Promise<RegionFile[]>;
|
|
23
|
+
/** Read the region at region coordinates. */
|
|
24
|
+
region(x: number, z: number, kind?: RegionKind): Promise<Region>;
|
|
25
|
+
/** The chunk at chunk coordinates, or null when the dimension has never stored it. */
|
|
26
|
+
chunk(x: number, z: number, kind?: RegionKind): Promise<Chunk | null>;
|
|
27
|
+
/** Every directory at or under `path` that holds region files. */
|
|
28
|
+
static search(path: string, id: string, level: string): AsyncGenerator<Dimension>;
|
|
29
|
+
/** The dimension a directory holds and the level root it belongs to, from the path alone. */
|
|
30
|
+
static identify(path: string): {
|
|
31
|
+
id: string;
|
|
32
|
+
level: string;
|
|
33
|
+
};
|
|
34
|
+
/** A dimension directory, with its id and level root taken from the path. */
|
|
35
|
+
static at(path: string): Dimension;
|
|
36
|
+
}
|
|
37
|
+
/** A level (world) directory. */
|
|
38
|
+
export declare class Level {
|
|
39
|
+
readonly path: string;
|
|
40
|
+
constructor(path: string);
|
|
41
|
+
/** Read and parse an NBT file in the level directory. */
|
|
42
|
+
nbt(...path: string[]): Promise<Named>;
|
|
43
|
+
/** The level's `level.dat`. */
|
|
44
|
+
data(): Promise<Named>;
|
|
45
|
+
/** The UUIDs of every player with saved data, sorted. */
|
|
46
|
+
players(): Promise<string[]>;
|
|
47
|
+
/** Read and parse a player's `.dat`. */
|
|
48
|
+
player(uuid: string): Promise<Named>;
|
|
49
|
+
/** Every dimension with a `region/` directory, vanilla ones first. */
|
|
50
|
+
dimensions(): Promise<Dimension[]>;
|
|
51
|
+
/** The dimension with an id, or undefined when the level has none. */
|
|
52
|
+
dimension(id: string): Promise<Dimension | undefined>;
|
|
53
|
+
}
|
package/dist/level.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import { basename, join, resolve, sep } from 'node:path';
|
|
3
|
+
import { normalizeId, regionKinds, vanillaDimensions, vanillaIds } from './common/level.js';
|
|
4
|
+
import { parseCompressed } from './common/nbt.js';
|
|
5
|
+
import { parseName, Region, regionSize } from './common/region.js';
|
|
6
|
+
export * from './common/level.js';
|
|
7
|
+
import { exists, subdirectories } from './utils.js';
|
|
8
|
+
/** Whether a directory is a level root rather than a single dimension's directory. */
|
|
9
|
+
export async function isLevel(path) {
|
|
10
|
+
const markers = ['level.dat', 'dimensions', ...vanillaIds.keys()];
|
|
11
|
+
const found = await Promise.all(markers.map(marker => exists(join(path, marker))));
|
|
12
|
+
return found.includes(true);
|
|
13
|
+
}
|
|
14
|
+
const localCoord = (value) => ((value % regionSize) + regionSize) % regionSize;
|
|
15
|
+
/** One dimension's directory: its region files and the chunks in them. */
|
|
16
|
+
export class Dimension {
|
|
17
|
+
path;
|
|
18
|
+
id;
|
|
19
|
+
level;
|
|
20
|
+
constructor(path, id,
|
|
21
|
+
/** The level root this dimension belongs to. */
|
|
22
|
+
level) {
|
|
23
|
+
this.path = path;
|
|
24
|
+
this.id = id;
|
|
25
|
+
this.level = level;
|
|
26
|
+
}
|
|
27
|
+
/** Where a region's file belongs, whether or not it exists. */
|
|
28
|
+
regionFile(kind, x, z) {
|
|
29
|
+
const name = `r.${x}.${z}.mca`;
|
|
30
|
+
return { kind, x, z, name, path: join(this.path, kind, name) };
|
|
31
|
+
}
|
|
32
|
+
/** Every region file of one kind, sorted by name. */
|
|
33
|
+
async regionFiles(kind = 'region') {
|
|
34
|
+
const names = await fs.readdir(join(this.path, kind)).catch(() => []);
|
|
35
|
+
const files = [];
|
|
36
|
+
for (const name of names.sort()) {
|
|
37
|
+
const coords = parseName(name);
|
|
38
|
+
if (coords)
|
|
39
|
+
files.push(this.regionFile(kind, coords.x, coords.z));
|
|
40
|
+
}
|
|
41
|
+
return files;
|
|
42
|
+
}
|
|
43
|
+
/** Each kind's file for one region, skipping the kinds that don't have it. */
|
|
44
|
+
async regionFilesAt(x, z) {
|
|
45
|
+
const files = regionKinds.map(kind => this.regionFile(kind, x, z));
|
|
46
|
+
const present = await Promise.all(files.map(file => exists(file.path)));
|
|
47
|
+
return files.filter((_, i) => present[i]);
|
|
48
|
+
}
|
|
49
|
+
/** Read the region at region coordinates. */
|
|
50
|
+
async region(x, z, kind = 'region') {
|
|
51
|
+
const { path } = this.regionFile(kind, x, z);
|
|
52
|
+
return new Region(await fs.readFile(path));
|
|
53
|
+
}
|
|
54
|
+
/** The chunk at chunk coordinates, or null when the dimension has never stored it. */
|
|
55
|
+
async chunk(x, z, kind = 'region') {
|
|
56
|
+
const file = this.regionFile(kind, Math.floor(x / regionSize), Math.floor(z / regionSize));
|
|
57
|
+
try {
|
|
58
|
+
const region = new Region(await fs.readFile(file.path));
|
|
59
|
+
const entry = region.at(localCoord(x), localCoord(z));
|
|
60
|
+
return entry && (await region.chunk(entry));
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Every directory at or under `path` that holds region files. */
|
|
67
|
+
static async *search(path, id, level) {
|
|
68
|
+
if (await exists(join(path, 'region'))) {
|
|
69
|
+
yield new Dimension(path, id, level);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
for (const name of await subdirectories(path))
|
|
73
|
+
yield* Dimension.search(join(path, name), `${id}/${name}`, level);
|
|
74
|
+
}
|
|
75
|
+
/** The dimension a directory holds and the level root it belongs to, from the path alone. */
|
|
76
|
+
static identify(path) {
|
|
77
|
+
const parts = resolve(path).split(sep);
|
|
78
|
+
// Custom dimensions live at <level>/dimensions/<namespace>/<rest of the id>.
|
|
79
|
+
const marker = parts.lastIndexOf('dimensions');
|
|
80
|
+
if (marker >= 0 && parts.length > marker + 2)
|
|
81
|
+
return { id: `${parts[marker + 1]}:${parts.slice(marker + 2).join('/')}`, level: parts.slice(0, marker).join(sep) };
|
|
82
|
+
const id = vanillaIds.get(parts.at(-1));
|
|
83
|
+
return id ? { id, level: parts.slice(0, -1).join(sep) } : { id: 'minecraft:overworld', level: parts.join(sep) };
|
|
84
|
+
}
|
|
85
|
+
/** A dimension directory, with its id and level root taken from the path. */
|
|
86
|
+
static at(path) {
|
|
87
|
+
const { id, level } = Dimension.identify(path);
|
|
88
|
+
return new Dimension(resolve(path), id, level);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** A level (world) directory. */
|
|
92
|
+
export class Level {
|
|
93
|
+
path;
|
|
94
|
+
constructor(path) {
|
|
95
|
+
this.path = resolve(path);
|
|
96
|
+
}
|
|
97
|
+
/** Read and parse an NBT file in the level directory. */
|
|
98
|
+
async nbt(...path) {
|
|
99
|
+
return await parseCompressed(await fs.readFile(join(this.path, ...path)));
|
|
100
|
+
}
|
|
101
|
+
/** The level's `level.dat`. */
|
|
102
|
+
async data() {
|
|
103
|
+
return await this.nbt('level.dat');
|
|
104
|
+
}
|
|
105
|
+
/** The UUIDs of every player with saved data, sorted. */
|
|
106
|
+
async players() {
|
|
107
|
+
const names = await fs.readdir(join(this.path, 'playerdata')).catch(() => []);
|
|
108
|
+
return names
|
|
109
|
+
.filter(name => name.endsWith('.dat'))
|
|
110
|
+
.map(name => basename(name, '.dat'))
|
|
111
|
+
.sort();
|
|
112
|
+
}
|
|
113
|
+
/** Read and parse a player's `.dat`. */
|
|
114
|
+
async player(uuid) {
|
|
115
|
+
return await this.nbt('playerdata', `${uuid}.dat`);
|
|
116
|
+
}
|
|
117
|
+
/** Every dimension with a `region/` directory, vanilla ones first. */
|
|
118
|
+
async dimensions() {
|
|
119
|
+
const dimensions = [];
|
|
120
|
+
for (const [id, sub] of Object.entries(vanillaDimensions)) {
|
|
121
|
+
const dir = join(this.path, sub);
|
|
122
|
+
if (await exists(join(dir, 'region')))
|
|
123
|
+
dimensions.push(new Dimension(dir, id, this.path));
|
|
124
|
+
}
|
|
125
|
+
const root = join(this.path, 'dimensions');
|
|
126
|
+
for (const namespace of await subdirectories(root))
|
|
127
|
+
for (const name of await subdirectories(join(root, namespace)))
|
|
128
|
+
dimensions.push(...(await Array.fromAsync(Dimension.search(join(root, namespace, name), `${namespace}:${name}`, this.path))));
|
|
129
|
+
return dimensions;
|
|
130
|
+
}
|
|
131
|
+
/** The dimension with an id, or undefined when the level has none. */
|
|
132
|
+
async dimension(id) {
|
|
133
|
+
const wanted = normalizeId(id);
|
|
134
|
+
return (await this.dimensions()).find(dimension => normalizeId(dimension.id) === wanted);
|
|
135
|
+
}
|
|
136
|
+
}
|
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type LogLevel, type LogLine } from './common/log.js';
|
|
2
|
+
import { type InspectColor } from 'node:util';
|
|
3
|
+
export * from './common/log.js';
|
|
4
|
+
export interface FollowOptions {
|
|
5
|
+
/** Lines of existing content to emit before following the end of the file. */
|
|
6
|
+
backfill?: number;
|
|
7
|
+
/** How long to wait between polls, in milliseconds, for changes the watcher misses. */
|
|
8
|
+
interval?: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
/** Called for errors the follow can recover from; without it, they abort the stream. */
|
|
11
|
+
onError?: (error: Error) => void;
|
|
12
|
+
}
|
|
13
|
+
/** Follow a file, emitting bytes as they are appended, across rotation and truncation. */
|
|
14
|
+
export declare function follow(path: string, options?: FollowOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
15
|
+
/** Follow a file, emitting each line appended to it. */
|
|
16
|
+
export declare function tail(path: string, options?: FollowOptions): ReadableStream<string>;
|
|
17
|
+
export declare const levelColors: Record<LogLevel, InspectColor>;
|
|
18
|
+
export declare function format(line: string | LogLine): string;
|