yeow-api 0.2.102 → 0.2.104
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/package.json +1 -1
- package/src/advancement.ts +11 -10
- package/src/assets.ts +13 -1
- package/src/block.ts +11 -10
- package/src/bossbar.ts +25 -24
- package/src/command.ts +4 -3
- package/src/entity.ts +35 -34
- package/src/global.d.ts +2 -1
- package/src/gui.ts +15 -14
- package/src/index.ts +2 -1
- package/src/inventory.ts +21 -20
- package/src/material.ts +7 -6
- package/src/particle.ts +3 -2
- package/src/pdc.ts +19 -18
- package/src/player.ts +70 -69
- package/src/potion.ts +9 -8
- package/src/recipe.ts +7 -6
- package/src/scoreboard.ts +49 -48
- package/src/server.ts +13 -12
- package/src/sound.ts +7 -6
- package/src/task.ts +19 -7
- package/src/world.ts +93 -92
package/package.json
CHANGED
package/src/advancement.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
|
|
3
4
|
export interface AdvancementProgress {
|
|
4
5
|
awardedCriteria: string[];
|
|
5
6
|
remainingCriteria: string[];
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export function grant(uuid: string, key: string): Promise<boolean> {
|
|
9
|
-
return post<boolean>('advancement.grant', { uuid, key });
|
|
9
|
+
export function grant(uuid: string, key: string, options?: TaskOptions): Promise<boolean> {
|
|
10
|
+
return post<boolean>('advancement.grant', { uuid, key }, options);
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export function revoke(uuid: string, key: string): Promise<boolean> {
|
|
13
|
-
return post<boolean>('advancement.revoke', { uuid, key });
|
|
13
|
+
export function revoke(uuid: string, key: string, options?: TaskOptions): Promise<boolean> {
|
|
14
|
+
return post<boolean>('advancement.revoke', { uuid, key }, options);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export function getProgress(uuid: string, key: string): Promise<AdvancementProgress | null> {
|
|
17
|
-
return post<AdvancementProgress | null>('advancement.getProgress', { uuid, key });
|
|
17
|
+
export function getProgress(uuid: string, key: string, options?: TaskOptions): Promise<AdvancementProgress | null> {
|
|
18
|
+
return post<AdvancementProgress | null>('advancement.getProgress', { uuid, key }, options);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export function awardCriteria(uuid: string, key: string, criteria: string): Promise<boolean> {
|
|
21
|
-
return post<boolean>('advancement.awardCriteria', { uuid, key, criteria });
|
|
21
|
+
export function awardCriteria(uuid: string, key: string, criteria: string, options?: TaskOptions): Promise<boolean> {
|
|
22
|
+
return post<boolean>('advancement.awardCriteria', { uuid, key, criteria }, options);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export function revokeCriteria(uuid: string, key: string, criteria: string): Promise<boolean> {
|
|
25
|
-
return post<boolean>('advancement.revokeCriteria', { uuid, key, criteria });
|
|
25
|
+
export function revokeCriteria(uuid: string, key: string, criteria: string, options?: TaskOptions): Promise<boolean> {
|
|
26
|
+
return post<boolean>('advancement.revokeCriteria', { uuid, key, criteria }, options);
|
|
26
27
|
}
|
package/src/assets.ts
CHANGED
|
@@ -43,4 +43,16 @@ export function extractSync(path: string, dest?: string): string {
|
|
|
43
43
|
return (_sendAssets({ t: 'extract', p }) as { path: string }).path;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export
|
|
46
|
+
export async function extractDir(path: string, dest?: string): Promise<string> {
|
|
47
|
+
const p: Record<string, unknown> = { path };
|
|
48
|
+
if (dest) p.dest = dest;
|
|
49
|
+
const r = await _sendAssetsAsync({ t: 'extractDir', p }) as { path: string };
|
|
50
|
+
return r.path;
|
|
51
|
+
}
|
|
52
|
+
export function extractDirSync(path: string, dest?: string): string {
|
|
53
|
+
const p: Record<string, unknown> = { path };
|
|
54
|
+
if (dest) p.dest = dest;
|
|
55
|
+
return (_sendAssets({ t: 'extractDir', p }) as { path: string }).path;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const assets = { read, readSync, readBase64, readBase64Sync, extract, extractSync, extractDir, extractDirSync };
|
package/src/block.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { call, post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
import { Location } from './location.js';
|
|
3
4
|
import type { ItemStack } from './item.js';
|
|
4
5
|
|
|
@@ -14,20 +15,20 @@ export class Block {
|
|
|
14
15
|
get location(): Location {
|
|
15
16
|
return new Location(this.x, this.y, this.z, undefined, undefined, this.world);
|
|
16
17
|
}
|
|
17
|
-
isSolid(): Promise<boolean> { return post<boolean>('block.isSolid', { world: this.world, x: this.x, y: this.y, z: this.z }); }
|
|
18
|
-
isSolidSync(): boolean { return call<boolean>('block.isSolid', { world: this.world, x: this.x, y: this.y, z: this.z }); }
|
|
19
|
-
isLiquid(): Promise<boolean> { return post<boolean>('block.isLiquid', { world: this.world, x: this.x, y: this.y, z: this.z }); }
|
|
20
|
-
isLiquidSync(): boolean { return call<boolean>('block.isLiquid', { world: this.world, x: this.x, y: this.y, z: this.z }); }
|
|
21
|
-
isEmpty(): Promise<boolean> { return post<boolean>('block.isEmpty', { world: this.world, x: this.x, y: this.y, z: this.z }); }
|
|
22
|
-
isEmptySync(): boolean { return call<boolean>('block.isEmpty', { world: this.world, x: this.x, y: this.y, z: this.z }); }
|
|
23
|
-
breakNaturally(tool?: ItemStack): Promise<boolean> {
|
|
18
|
+
isSolid(options?: TaskOptions): Promise<boolean> { return post<boolean>('block.isSolid', { world: this.world, x: this.x, y: this.y, z: this.z }, options); }
|
|
19
|
+
isSolidSync(options?: TaskOptions): boolean { return call<boolean>('block.isSolid', { world: this.world, x: this.x, y: this.y, z: this.z }, options); }
|
|
20
|
+
isLiquid(options?: TaskOptions): Promise<boolean> { return post<boolean>('block.isLiquid', { world: this.world, x: this.x, y: this.y, z: this.z }, options); }
|
|
21
|
+
isLiquidSync(options?: TaskOptions): boolean { return call<boolean>('block.isLiquid', { world: this.world, x: this.x, y: this.y, z: this.z }, options); }
|
|
22
|
+
isEmpty(options?: TaskOptions): Promise<boolean> { return post<boolean>('block.isEmpty', { world: this.world, x: this.x, y: this.y, z: this.z }, options); }
|
|
23
|
+
isEmptySync(options?: TaskOptions): boolean { return call<boolean>('block.isEmpty', { world: this.world, x: this.x, y: this.y, z: this.z }, options); }
|
|
24
|
+
breakNaturally(tool?: ItemStack, options?: TaskOptions): Promise<boolean> {
|
|
24
25
|
const p: Record<string, unknown> = { world: this.world, x: this.x, y: this.y, z: this.z };
|
|
25
26
|
if (tool) p.item = tool;
|
|
26
|
-
return post<boolean>('block.breakNaturally', p);
|
|
27
|
+
return post<boolean>('block.breakNaturally', p, options);
|
|
27
28
|
}
|
|
28
|
-
breakNaturallySync(tool?: ItemStack): boolean {
|
|
29
|
+
breakNaturallySync(tool?: ItemStack, options?: TaskOptions): boolean {
|
|
29
30
|
const p: Record<string, unknown> = { world: this.world, x: this.x, y: this.y, z: this.z };
|
|
30
31
|
if (tool) p.item = tool;
|
|
31
|
-
return call<boolean>('block.breakNaturally', p);
|
|
32
|
+
return call<boolean>('block.breakNaturally', p, options);
|
|
32
33
|
}
|
|
33
34
|
}
|
package/src/bossbar.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
import { BossBarHandle } from './instance-id.js';
|
|
3
4
|
|
|
4
5
|
export interface BossBarOptions {
|
|
@@ -8,52 +9,52 @@ export interface BossBarOptions {
|
|
|
8
9
|
visible?: boolean;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export async function createBossBar(title: string, options?: BossBarOptions): Promise<BossBarHandle> {
|
|
12
|
+
export async function createBossBar(title: string, options?: BossBarOptions, taskOptions?: TaskOptions): Promise<BossBarHandle> {
|
|
12
13
|
const h = new BossBarHandle();
|
|
13
|
-
await post('bossbar.create', { id: h.toString(), title, ...options });
|
|
14
|
+
await post('bossbar.create', { id: h.toString(), title, ...options }, taskOptions);
|
|
14
15
|
return h;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export function destroy(id: BossBarHandle): Promise<void> {
|
|
18
|
-
return post('bossbar.destroy', { id: id.toString() });
|
|
18
|
+
export function destroy(id: BossBarHandle, options?: TaskOptions): Promise<void> {
|
|
19
|
+
return post('bossbar.destroy', { id: id.toString() }, options);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export function setTitle(id: BossBarHandle, title: string): Promise<void> {
|
|
22
|
-
return post('bossbar.setTitle', { id: id.toString(), title });
|
|
22
|
+
export function setTitle(id: BossBarHandle, title: string, options?: TaskOptions): Promise<void> {
|
|
23
|
+
return post('bossbar.setTitle', { id: id.toString(), title }, options);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export function setProgress(id: BossBarHandle, progress: number): Promise<void> {
|
|
26
|
-
return post('bossbar.setProgress', { id: id.toString(), progress });
|
|
26
|
+
export function setProgress(id: BossBarHandle, progress: number, options?: TaskOptions): Promise<void> {
|
|
27
|
+
return post('bossbar.setProgress', { id: id.toString(), progress }, options);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export function setColor(id: BossBarHandle, color: string): Promise<void> {
|
|
30
|
-
return post('bossbar.setColor', { id: id.toString(), color });
|
|
30
|
+
export function setColor(id: BossBarHandle, color: string, options?: TaskOptions): Promise<void> {
|
|
31
|
+
return post('bossbar.setColor', { id: id.toString(), color }, options);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export function setStyle(id: BossBarHandle, style: string): Promise<void> {
|
|
34
|
-
return post('bossbar.setStyle', { id: id.toString(), style });
|
|
34
|
+
export function setStyle(id: BossBarHandle, style: string, options?: TaskOptions): Promise<void> {
|
|
35
|
+
return post('bossbar.setStyle', { id: id.toString(), style }, options);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export function setVisible(id: BossBarHandle, visible: boolean): Promise<void> {
|
|
38
|
-
return post('bossbar.setVisible', { id: id.toString(), visible });
|
|
38
|
+
export function setVisible(id: BossBarHandle, visible: boolean, options?: TaskOptions): Promise<void> {
|
|
39
|
+
return post('bossbar.setVisible', { id: id.toString(), visible }, options);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
export function addPlayer(id: BossBarHandle, uuid: string): Promise<void> {
|
|
42
|
-
return post('bossbar.addPlayer', { id: id.toString(), uuid });
|
|
42
|
+
export function addPlayer(id: BossBarHandle, uuid: string, options?: TaskOptions): Promise<void> {
|
|
43
|
+
return post('bossbar.addPlayer', { id: id.toString(), uuid }, options);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export function removePlayer(id: BossBarHandle, uuid: string): Promise<void> {
|
|
46
|
-
return post('bossbar.removePlayer', { id: id.toString(), uuid });
|
|
46
|
+
export function removePlayer(id: BossBarHandle, uuid: string, options?: TaskOptions): Promise<void> {
|
|
47
|
+
return post('bossbar.removePlayer', { id: id.toString(), uuid }, options);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
export function removeAll(id: BossBarHandle): Promise<void> {
|
|
50
|
-
return post('bossbar.removeAll', { id: id.toString() });
|
|
50
|
+
export function removeAll(id: BossBarHandle, options?: TaskOptions): Promise<void> {
|
|
51
|
+
return post('bossbar.removeAll', { id: id.toString() }, options);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
export function addFlag(id: BossBarHandle, flag: string): Promise<void> {
|
|
54
|
-
return post('bossbar.addFlag', { id: id.toString(), flag });
|
|
54
|
+
export function addFlag(id: BossBarHandle, flag: string, options?: TaskOptions): Promise<void> {
|
|
55
|
+
return post('bossbar.addFlag', { id: id.toString(), flag }, options);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
export function removeFlag(id: BossBarHandle, flag: string): Promise<void> {
|
|
58
|
-
return post('bossbar.removeFlag', { id: id.toString(), flag });
|
|
58
|
+
export function removeFlag(id: BossBarHandle, flag: string, options?: TaskOptions): Promise<void> {
|
|
59
|
+
return post('bossbar.removeFlag', { id: id.toString(), flag }, options);
|
|
59
60
|
}
|
package/src/command.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { call } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
|
|
3
4
|
export interface CommandSender {
|
|
4
5
|
readonly name: string;
|
|
@@ -28,7 +29,7 @@ export interface CommandOptions {
|
|
|
28
29
|
completer?: CompleterFn | ManualCompleter;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export function registerCommand(name: string, options: CommandOptions): boolean {
|
|
32
|
+
export function registerCommand(name: string, options: CommandOptions, taskOptions?: TaskOptions): boolean {
|
|
32
33
|
const executor = options.executor;
|
|
33
34
|
const completer = options.completer;
|
|
34
35
|
const pluginName = __plugin?.name || 'unknown';
|
|
@@ -36,7 +37,7 @@ export function registerCommand(name: string, options: CommandOptions): boolean
|
|
|
36
37
|
function decorateSender(sender: CommandSender): CommandSender {
|
|
37
38
|
if (sender?.uuid && sender.isPlayer) {
|
|
38
39
|
(sender as any).sendMessage = (msg: string) => {
|
|
39
|
-
call('player.sendMessage', { uuid: sender.uuid, message: msg });
|
|
40
|
+
call('player.sendMessage', { uuid: sender.uuid, message: msg }, taskOptions);
|
|
40
41
|
};
|
|
41
42
|
} else {
|
|
42
43
|
(sender as any).sendMessage = (msg: string) => {
|
|
@@ -109,5 +110,5 @@ export function registerCommand(name: string, options: CommandOptions): boolean
|
|
|
109
110
|
usage: options.usage,
|
|
110
111
|
permission: options.permission,
|
|
111
112
|
aliases: options.aliases,
|
|
112
|
-
});
|
|
113
|
+
}, taskOptions);
|
|
113
114
|
}
|
package/src/entity.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { call, post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
import { Location, LocationData } from './location.js';
|
|
3
4
|
|
|
4
5
|
export interface BoundingBox {
|
|
@@ -11,91 +12,91 @@ export interface BoundingBox {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export class Entity {
|
|
14
|
-
static get(uuid: string): Promise<Entity | null> {
|
|
15
|
-
return post<{ uuid: string }>('entity.get', { uuid }).then((d) => (d ? new Entity(d.uuid) : null));
|
|
15
|
+
static get(uuid: string, options?: TaskOptions): Promise<Entity | null> {
|
|
16
|
+
return post<{ uuid: string }>('entity.get', { uuid }, options).then((d) => (d ? new Entity(d.uuid) : null));
|
|
16
17
|
}
|
|
17
|
-
static getSync(uuid: string): Entity | null {
|
|
18
|
-
const d = call<{ uuid: string }>('entity.get', { uuid });
|
|
18
|
+
static getSync(uuid: string, options?: TaskOptions): Entity | null {
|
|
19
|
+
const d = call<{ uuid: string }>('entity.get', { uuid }, options);
|
|
19
20
|
return d ? new Entity(d.uuid) : null;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
constructor(public readonly uuid: string) {}
|
|
23
24
|
|
|
24
25
|
get type(): string { return call<string>('entity.getType', { uuid: this.uuid }); }
|
|
25
|
-
getType(): Promise<string> { return post<string>('entity.getType', { uuid: this.uuid }); }
|
|
26
|
+
getType(options?: TaskOptions): Promise<string> { return post<string>('entity.getType', { uuid: this.uuid }, options); }
|
|
26
27
|
|
|
27
28
|
get name(): string { return call<string>('entity.getName', { uuid: this.uuid }); }
|
|
28
|
-
getName(): Promise<string> { return post<string>('entity.getName', { uuid: this.uuid }); }
|
|
29
|
+
getName(options?: TaskOptions): Promise<string> { return post<string>('entity.getName', { uuid: this.uuid }, options); }
|
|
29
30
|
|
|
30
31
|
get customName(): string | null { return call<string | null>('entity.getCustomName', { uuid: this.uuid }); }
|
|
31
32
|
set customName(v: string | null) { call('entity.setCustomName', { uuid: this.uuid, value: v }); }
|
|
32
|
-
getCustomName(): Promise<string | null> { return post<string | null>('entity.getCustomName', { uuid: this.uuid }); }
|
|
33
|
-
setCustomName(v: string | null): Promise<void> { return post('entity.setCustomName', { uuid: this.uuid, value: v }); }
|
|
33
|
+
getCustomName(options?: TaskOptions): Promise<string | null> { return post<string | null>('entity.getCustomName', { uuid: this.uuid }, options); }
|
|
34
|
+
setCustomName(v: string | null, options?: TaskOptions): Promise<void> { return post('entity.setCustomName', { uuid: this.uuid, value: v }, options); }
|
|
34
35
|
|
|
35
|
-
setCustomNameVisible(v: boolean): Promise<void> {
|
|
36
|
-
return post('entity.setCustomNameVisible', { uuid: this.uuid, value: v });
|
|
36
|
+
setCustomNameVisible(v: boolean, options?: TaskOptions): Promise<void> {
|
|
37
|
+
return post('entity.setCustomNameVisible', { uuid: this.uuid, value: v }, options);
|
|
37
38
|
}
|
|
38
|
-
setCustomNameVisibleSync(v: boolean): void {
|
|
39
|
-
call('entity.setCustomNameVisible', { uuid: this.uuid, value: v });
|
|
39
|
+
setCustomNameVisibleSync(v: boolean, options?: TaskOptions): void {
|
|
40
|
+
call('entity.setCustomNameVisible', { uuid: this.uuid, value: v }, options);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
get world(): string | null { return call<string | null>('entity.getWorld', { uuid: this.uuid }); }
|
|
43
|
-
getWorld(): Promise<string | null> { return post<string | null>('entity.getWorld', { uuid: this.uuid }); }
|
|
44
|
+
getWorld(options?: TaskOptions): Promise<string | null> { return post<string | null>('entity.getWorld', { uuid: this.uuid }, options); }
|
|
44
45
|
|
|
45
46
|
get location(): Location | null {
|
|
46
47
|
const r = call<LocationData>('entity.getLocation', { uuid: this.uuid });
|
|
47
48
|
return r ? Location.from(r) : null;
|
|
48
49
|
}
|
|
49
|
-
getLocation(): Promise<Location | null> {
|
|
50
|
-
return post<LocationData>('entity.getLocation', { uuid: this.uuid }).then((r) => (r ? Location.from(r) : null));
|
|
50
|
+
getLocation(options?: TaskOptions): Promise<Location | null> {
|
|
51
|
+
return post<LocationData>('entity.getLocation', { uuid: this.uuid }, options).then((r) => (r ? Location.from(r) : null));
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
get isGlowing(): boolean { return call<boolean>('entity.isGlowing', { uuid: this.uuid }); }
|
|
54
55
|
set isGlowing(v: boolean) { call('entity.setGlowing', { uuid: this.uuid, value: v }); }
|
|
55
|
-
isGlowingAsync(): Promise<boolean> { return post<boolean>('entity.isGlowing', { uuid: this.uuid }); }
|
|
56
|
-
setGlowing(v: boolean): Promise<void> { return post('entity.setGlowing', { uuid: this.uuid, value: v }); }
|
|
56
|
+
isGlowingAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('entity.isGlowing', { uuid: this.uuid }, options); }
|
|
57
|
+
setGlowing(v: boolean, options?: TaskOptions): Promise<void> { return post('entity.setGlowing', { uuid: this.uuid, value: v }, options); }
|
|
57
58
|
|
|
58
59
|
get isInvulnerable(): boolean { return call<boolean>('entity.isInvulnerable', { uuid: this.uuid }); }
|
|
59
60
|
set isInvulnerable(v: boolean) { call('entity.setInvulnerable', { uuid: this.uuid, value: v }); }
|
|
60
|
-
isInvulnerableAsync(): Promise<boolean> { return post<boolean>('entity.isInvulnerable', { uuid: this.uuid }); }
|
|
61
|
-
setInvulnerable(v: boolean): Promise<void> { return post('entity.setInvulnerable', { uuid: this.uuid, value: v }); }
|
|
61
|
+
isInvulnerableAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('entity.isInvulnerable', { uuid: this.uuid }, options); }
|
|
62
|
+
setInvulnerable(v: boolean, options?: TaskOptions): Promise<void> { return post('entity.setInvulnerable', { uuid: this.uuid, value: v }, options); }
|
|
62
63
|
|
|
63
64
|
get isSilent(): boolean { return call<boolean>('entity.isSilent', { uuid: this.uuid }); }
|
|
64
65
|
set isSilent(v: boolean) { call('entity.setSilent', { uuid: this.uuid, value: v }); }
|
|
65
|
-
isSilentAsync(): Promise<boolean> { return post<boolean>('entity.isSilent', { uuid: this.uuid }); }
|
|
66
|
-
setSilent(v: boolean): Promise<void> { return post('entity.setSilent', { uuid: this.uuid, value: v }); }
|
|
66
|
+
isSilentAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('entity.isSilent', { uuid: this.uuid }, options); }
|
|
67
|
+
setSilent(v: boolean, options?: TaskOptions): Promise<void> { return post('entity.setSilent', { uuid: this.uuid, value: v }, options); }
|
|
67
68
|
|
|
68
69
|
get hasGravity(): boolean { return call<boolean>('entity.hasGravity', { uuid: this.uuid }); }
|
|
69
70
|
set hasGravity(v: boolean) { call('entity.setGravity', { uuid: this.uuid, value: v }); }
|
|
70
|
-
hasGravityAsync(): Promise<boolean> { return post<boolean>('entity.hasGravity', { uuid: this.uuid }); }
|
|
71
|
-
setGravity(v: boolean): Promise<void> { return post('entity.setGravity', { uuid: this.uuid, value: v }); }
|
|
71
|
+
hasGravityAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('entity.hasGravity', { uuid: this.uuid }, options); }
|
|
72
|
+
setGravity(v: boolean, options?: TaskOptions): Promise<void> { return post('entity.setGravity', { uuid: this.uuid, value: v }, options); }
|
|
72
73
|
|
|
73
74
|
get passengers(): string[] { return call<string[]>('entity.getPassengers', { uuid: this.uuid }); }
|
|
74
|
-
getPassengers(): Promise<string[]> { return post<string[]>('entity.getPassengers', { uuid: this.uuid }); }
|
|
75
|
+
getPassengers(options?: TaskOptions): Promise<string[]> { return post<string[]>('entity.getPassengers', { uuid: this.uuid }, options); }
|
|
75
76
|
|
|
76
77
|
get vehicle(): string | null { return call<string | null>('entity.getVehicle', { uuid: this.uuid }); }
|
|
77
|
-
getVehicle(): Promise<string | null> { return post<string | null>('entity.getVehicle', { uuid: this.uuid }); }
|
|
78
|
+
getVehicle(options?: TaskOptions): Promise<string | null> { return post<string | null>('entity.getVehicle', { uuid: this.uuid }, options); }
|
|
78
79
|
|
|
79
80
|
get boundingBox(): BoundingBox {
|
|
80
81
|
return call<BoundingBox>('entity.getBoundingBox', { uuid: this.uuid });
|
|
81
82
|
}
|
|
82
|
-
getBoundingBox(): Promise<BoundingBox> { return post<BoundingBox>('entity.getBoundingBox', { uuid: this.uuid }); }
|
|
83
|
+
getBoundingBox(options?: TaskOptions): Promise<BoundingBox> { return post<BoundingBox>('entity.getBoundingBox', { uuid: this.uuid }, options); }
|
|
83
84
|
|
|
84
|
-
remove(): Promise<void> { return post('entity.remove', { uuid: this.uuid }); }
|
|
85
|
-
removeSync(): void { call('entity.remove', { uuid: this.uuid }); }
|
|
86
|
-
teleport(loc: Location): Promise<void> { return post('entity.teleport', { uuid: this.uuid, ...loc.toObject() }); }
|
|
87
|
-
teleportSync(loc: Location): void { call('entity.teleport', { uuid: this.uuid, ...loc.toObject() }); }
|
|
85
|
+
remove(options?: TaskOptions): Promise<void> { return post('entity.remove', { uuid: this.uuid }, options); }
|
|
86
|
+
removeSync(options?: TaskOptions): void { call('entity.remove', { uuid: this.uuid }, options); }
|
|
87
|
+
teleport(loc: Location, options?: TaskOptions): Promise<void> { return post('entity.teleport', { uuid: this.uuid, ...loc.toObject() }, options); }
|
|
88
|
+
teleportSync(loc: Location, options?: TaskOptions): void { call('entity.teleport', { uuid: this.uuid, ...loc.toObject() }, options); }
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
export class LivingEntity extends Entity {
|
|
91
92
|
get health(): number { return call<number>('entity.getHealth', { uuid: this.uuid }); }
|
|
92
93
|
set health(v: number) { call('entity.setHealth', { uuid: this.uuid, value: v }); }
|
|
93
|
-
getHealth(): Promise<number> { return post<number>('entity.getHealth', { uuid: this.uuid }); }
|
|
94
|
-
setHealth(v: number): Promise<void> { return post('entity.setHealth', { uuid: this.uuid, value: v }); }
|
|
94
|
+
getHealth(options?: TaskOptions): Promise<number> { return post<number>('entity.getHealth', { uuid: this.uuid }, options); }
|
|
95
|
+
setHealth(v: number, options?: TaskOptions): Promise<void> { return post('entity.setHealth', { uuid: this.uuid, value: v }, options); }
|
|
95
96
|
|
|
96
97
|
get maxHealth(): number { return call<number>('entity.getMaxHealth', { uuid: this.uuid }); }
|
|
97
|
-
getMaxHealth(): Promise<number> { return post<number>('entity.getMaxHealth', { uuid: this.uuid }); }
|
|
98
|
+
getMaxHealth(options?: TaskOptions): Promise<number> { return post<number>('entity.getMaxHealth', { uuid: this.uuid }, options); }
|
|
98
99
|
|
|
99
100
|
get isDead(): boolean { return call<boolean>('entity.isDead', { uuid: this.uuid }); }
|
|
100
|
-
isDeadAsync(): Promise<boolean> { return post<boolean>('entity.isDead', { uuid: this.uuid }); }
|
|
101
|
+
isDeadAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('entity.isDead', { uuid: this.uuid }, options); }
|
|
101
102
|
}
|
package/src/global.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ declare global {
|
|
|
9
9
|
options?: { persistent?: boolean }
|
|
10
10
|
): string;
|
|
11
11
|
function _unregisterCallback(id: string): void;
|
|
12
|
-
function _getCurrentCbStack(): string | null;
|
|
12
|
+
function _getCurrentCbStack(): { stack: string; outer: unknown } | null;
|
|
13
|
+
function _attachCbStack(err: unknown): void;
|
|
13
14
|
|
|
14
15
|
var __plugin:
|
|
15
16
|
| {
|
package/src/gui.ts
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import { post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
import { GUIHandle } from './instance-id.js';
|
|
3
4
|
import type { ItemStack } from './item.js';
|
|
4
5
|
|
|
5
|
-
export async function createGUI(size: number, title: string): Promise<GUIHandle> {
|
|
6
|
+
export async function createGUI(size: number, title: string, options?: TaskOptions): Promise<GUIHandle> {
|
|
6
7
|
const h = new GUIHandle();
|
|
7
|
-
await post('gui.create', { id: h.toString(), size, title });
|
|
8
|
+
await post('gui.create', { id: h.toString(), size, title }, options);
|
|
8
9
|
return h;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export function destroy(id: GUIHandle): Promise<void> {
|
|
12
|
-
return post('gui.destroy', { id: id.toString() });
|
|
12
|
+
export function destroy(id: GUIHandle, options?: TaskOptions): Promise<void> {
|
|
13
|
+
return post('gui.destroy', { id: id.toString() }, options);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export function open(id: GUIHandle, uuid: string): Promise<void> {
|
|
16
|
-
return post('gui.open', { id: id.toString(), uuid });
|
|
16
|
+
export function open(id: GUIHandle, uuid: string, options?: TaskOptions): Promise<void> {
|
|
17
|
+
return post('gui.open', { id: id.toString(), uuid }, options);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export function close(id: GUIHandle): Promise<void> {
|
|
20
|
-
return post('gui.close', { id: id.toString() });
|
|
20
|
+
export function close(id: GUIHandle, options?: TaskOptions): Promise<void> {
|
|
21
|
+
return post('gui.close', { id: id.toString() }, options);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export function setItem(id: GUIHandle, slot: number, item: ItemStack): Promise<void> {
|
|
24
|
-
return post('gui.setItem', { id: id.toString(), slot, item });
|
|
24
|
+
export function setItem(id: GUIHandle, slot: number, item: ItemStack, options?: TaskOptions): Promise<void> {
|
|
25
|
+
return post('gui.setItem', { id: id.toString(), slot, item }, options);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
export function fill(id: GUIHandle, item: ItemStack): Promise<void> {
|
|
28
|
-
return post('gui.fill', { id: id.toString(), item });
|
|
28
|
+
export function fill(id: GUIHandle, item: ItemStack, options?: TaskOptions): Promise<void> {
|
|
29
|
+
return post('gui.fill', { id: id.toString(), item }, options);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export function clear(id: GUIHandle): Promise<void> {
|
|
32
|
-
return post('gui.clear', { id: id.toString() });
|
|
32
|
+
export function clear(id: GUIHandle, options?: TaskOptions): Promise<void> {
|
|
33
|
+
return post('gui.clear', { id: id.toString() }, options);
|
|
33
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -44,7 +44,8 @@ export {
|
|
|
44
44
|
} from './fs.js';
|
|
45
45
|
export { assets, read as assetsRead, readSync as assetsReadSync,
|
|
46
46
|
readBase64 as assetsReadBase64, readBase64Sync as assetsReadBase64Sync,
|
|
47
|
-
extract as assetsExtract, extractSync as assetsExtractSync
|
|
47
|
+
extract as assetsExtract, extractSync as assetsExtractSync,
|
|
48
|
+
extractDir as assetsExtractDir, extractDirSync as assetsExtractDirSync } from './assets.js';
|
|
48
49
|
export { path } from './path.js';
|
|
49
50
|
export { listen, respond, close, request } from './http.js';
|
|
50
51
|
export { logError } from './log-error.js';
|
package/src/inventory.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { call, post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
|
|
3
4
|
interface ItemData {
|
|
4
5
|
type: string;
|
|
@@ -8,34 +9,34 @@ interface ItemData {
|
|
|
8
9
|
export class Inventory {
|
|
9
10
|
constructor(private readonly uuid: string) {}
|
|
10
11
|
|
|
11
|
-
getItem(slot: number): Promise<ItemData | null> {
|
|
12
|
-
return post<ItemData | null>('inventory.getItem', { uuid: this.uuid, slot });
|
|
12
|
+
getItem(slot: number, options?: TaskOptions): Promise<ItemData | null> {
|
|
13
|
+
return post<ItemData | null>('inventory.getItem', { uuid: this.uuid, slot }, options);
|
|
13
14
|
}
|
|
14
|
-
getItemSync(slot: number): ItemData | null {
|
|
15
|
-
return call<ItemData | null>('inventory.getItem', { uuid: this.uuid, slot });
|
|
15
|
+
getItemSync(slot: number, options?: TaskOptions): ItemData | null {
|
|
16
|
+
return call<ItemData | null>('inventory.getItem', { uuid: this.uuid, slot }, options);
|
|
16
17
|
}
|
|
17
|
-
setItem(slot: number, itemType: string, amount?: number): Promise<void> {
|
|
18
|
-
return post('inventory.setItem', { uuid: this.uuid, slot, itemType, amount });
|
|
18
|
+
setItem(slot: number, itemType: string, amount?: number, options?: TaskOptions): Promise<void> {
|
|
19
|
+
return post('inventory.setItem', { uuid: this.uuid, slot, itemType, amount }, options);
|
|
19
20
|
}
|
|
20
|
-
setItemSync(slot: number, itemType: string, amount?: number): void {
|
|
21
|
-
call('inventory.setItem', { uuid: this.uuid, slot, itemType, amount });
|
|
21
|
+
setItemSync(slot: number, itemType: string, amount?: number, options?: TaskOptions): void {
|
|
22
|
+
call('inventory.setItem', { uuid: this.uuid, slot, itemType, amount }, options);
|
|
22
23
|
}
|
|
23
|
-
addItem(itemType: string, amount?: number): Promise<void> {
|
|
24
|
-
return post('inventory.addItem', { uuid: this.uuid, itemType, amount });
|
|
24
|
+
addItem(itemType: string, amount?: number, options?: TaskOptions): Promise<void> {
|
|
25
|
+
return post('inventory.addItem', { uuid: this.uuid, itemType, amount }, options);
|
|
25
26
|
}
|
|
26
|
-
addItemSync(itemType: string, amount?: number): void {
|
|
27
|
-
call('inventory.addItem', { uuid: this.uuid, itemType, amount });
|
|
27
|
+
addItemSync(itemType: string, amount?: number, options?: TaskOptions): void {
|
|
28
|
+
call('inventory.addItem', { uuid: this.uuid, itemType, amount }, options);
|
|
28
29
|
}
|
|
29
|
-
removeItem(itemType: string, amount?: number): Promise<void> {
|
|
30
|
-
return post('inventory.removeItem', { uuid: this.uuid, itemType, amount });
|
|
30
|
+
removeItem(itemType: string, amount?: number, options?: TaskOptions): Promise<void> {
|
|
31
|
+
return post('inventory.removeItem', { uuid: this.uuid, itemType, amount }, options);
|
|
31
32
|
}
|
|
32
|
-
removeItemSync(itemType: string, amount?: number): void {
|
|
33
|
-
call('inventory.removeItem', { uuid: this.uuid, itemType, amount });
|
|
33
|
+
removeItemSync(itemType: string, amount?: number, options?: TaskOptions): void {
|
|
34
|
+
call('inventory.removeItem', { uuid: this.uuid, itemType, amount }, options);
|
|
34
35
|
}
|
|
35
|
-
clear(slot?: number): Promise<void> {
|
|
36
|
-
return post('inventory.clear', { uuid: this.uuid, slot });
|
|
36
|
+
clear(slot?: number, options?: TaskOptions): Promise<void> {
|
|
37
|
+
return post('inventory.clear', { uuid: this.uuid, slot }, options);
|
|
37
38
|
}
|
|
38
|
-
clearSync(slot?: number): void {
|
|
39
|
-
call('inventory.clear', { uuid: this.uuid, slot });
|
|
39
|
+
clearSync(slot?: number, options?: TaskOptions): void {
|
|
40
|
+
call('inventory.clear', { uuid: this.uuid, slot }, options);
|
|
40
41
|
}
|
|
41
42
|
}
|
package/src/material.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
|
|
3
4
|
export interface MaterialInfo {
|
|
4
5
|
key: string;
|
|
@@ -8,9 +9,9 @@ export interface MaterialInfo {
|
|
|
8
9
|
|
|
9
10
|
let _materials: MaterialInfo[] | null = null;
|
|
10
11
|
|
|
11
|
-
export async function getMaterials(): Promise<MaterialInfo[]> {
|
|
12
|
+
export async function getMaterials(options?: TaskOptions): Promise<MaterialInfo[]> {
|
|
12
13
|
if (_materials) return _materials;
|
|
13
|
-
_materials = await post<MaterialInfo[]>('server.getMaterials', {});
|
|
14
|
+
_materials = await post<MaterialInfo[]>('server.getMaterials', {}, options);
|
|
14
15
|
Object.freeze(_materials);
|
|
15
16
|
for (const m of _materials) Object.freeze(m);
|
|
16
17
|
return _materials;
|
|
@@ -18,18 +19,18 @@ export async function getMaterials(): Promise<MaterialInfo[]> {
|
|
|
18
19
|
|
|
19
20
|
let _blocks: string[] | null = null;
|
|
20
21
|
|
|
21
|
-
export async function getBlocks(): Promise<string[]> {
|
|
22
|
+
export async function getBlocks(options?: TaskOptions): Promise<string[]> {
|
|
22
23
|
if (_blocks) return _blocks;
|
|
23
|
-
_blocks = await post<string[]>('server.getBlocks', {});
|
|
24
|
+
_blocks = await post<string[]>('server.getBlocks', {}, options);
|
|
24
25
|
Object.freeze(_blocks);
|
|
25
26
|
return _blocks;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
let _items: string[] | null = null;
|
|
29
30
|
|
|
30
|
-
export async function getItems(): Promise<string[]> {
|
|
31
|
+
export async function getItems(options?: TaskOptions): Promise<string[]> {
|
|
31
32
|
if (_items) return _items;
|
|
32
|
-
_items = await post<string[]>('server.getItems', {});
|
|
33
|
+
_items = await post<string[]>('server.getItems', {}, options);
|
|
33
34
|
Object.freeze(_items);
|
|
34
35
|
return _items;
|
|
35
36
|
}
|
package/src/particle.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
import type { ItemStack } from './item.js';
|
|
3
4
|
|
|
4
5
|
export interface ParticleOptions {
|
|
@@ -18,7 +19,7 @@ export interface ParticleOptions {
|
|
|
18
19
|
item?: ItemStack;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export function spawnParticle(options: ParticleOptions): Promise<void> {
|
|
22
|
+
export function spawnParticle(options: ParticleOptions, taskOptions?: TaskOptions): Promise<void> {
|
|
22
23
|
return post('world.spawnParticle', {
|
|
23
24
|
world: options.world,
|
|
24
25
|
particle: options.particle,
|
|
@@ -34,5 +35,5 @@ export function spawnParticle(options: ParticleOptions): Promise<void> {
|
|
|
34
35
|
color: options.color,
|
|
35
36
|
blockType: options.blockType,
|
|
36
37
|
item: options.item,
|
|
37
|
-
});
|
|
38
|
+
}, taskOptions);
|
|
38
39
|
}
|
package/src/pdc.ts
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import { post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
|
|
3
|
-
export function get(uuid: string, key: string): Promise<string | null> {
|
|
4
|
-
return post<string | null>('pdc.get', { uuid, key });
|
|
4
|
+
export function get(uuid: string, key: string, options?: TaskOptions): Promise<string | null> {
|
|
5
|
+
return post<string | null>('pdc.get', { uuid, key }, options);
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
export function set(uuid: string, key: string, value: string): Promise<boolean> {
|
|
8
|
-
return post<boolean>('pdc.set', { uuid, key, value });
|
|
8
|
+
export function set(uuid: string, key: string, value: string, options?: TaskOptions): Promise<boolean> {
|
|
9
|
+
return post<boolean>('pdc.set', { uuid, key, value }, options);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export function has(uuid: string, key: string): Promise<boolean> {
|
|
12
|
-
return post<boolean>('pdc.has', { uuid, key });
|
|
12
|
+
export function has(uuid: string, key: string, options?: TaskOptions): Promise<boolean> {
|
|
13
|
+
return post<boolean>('pdc.has', { uuid, key }, options);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export function remove(uuid: string, key: string): Promise<boolean> {
|
|
16
|
-
return post<boolean>('pdc.remove', { uuid, key });
|
|
16
|
+
export function remove(uuid: string, key: string, options?: TaskOptions): Promise<boolean> {
|
|
17
|
+
return post<boolean>('pdc.remove', { uuid, key }, options);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export function keys(uuid: string): Promise<string[]> {
|
|
20
|
-
return post<string[]>('pdc.keys', { uuid });
|
|
20
|
+
export function keys(uuid: string, options?: TaskOptions): Promise<string[]> {
|
|
21
|
+
return post<string[]>('pdc.keys', { uuid }, options);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export function getBlock(world: string, x: number, y: number, z: number, key: string): Promise<string | null> {
|
|
24
|
-
return post<string | null>('pdc.get', { world, x, y, z, key });
|
|
24
|
+
export function getBlock(world: string, x: number, y: number, z: number, key: string, options?: TaskOptions): Promise<string | null> {
|
|
25
|
+
return post<string | null>('pdc.get', { world, x, y, z, key }, options);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
export function setBlock(world: string, x: number, y: number, z: number, key: string, value: string): Promise<boolean> {
|
|
28
|
-
return post<boolean>('pdc.set', { world, x, y, z, key, value });
|
|
28
|
+
export function setBlock(world: string, x: number, y: number, z: number, key: string, value: string, options?: TaskOptions): Promise<boolean> {
|
|
29
|
+
return post<boolean>('pdc.set', { world, x, y, z, key, value }, options);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export function hasBlock(world: string, x: number, y: number, z: number, key: string): Promise<boolean> {
|
|
32
|
-
return post<boolean>('pdc.has', { world, x, y, z, key });
|
|
32
|
+
export function hasBlock(world: string, x: number, y: number, z: number, key: string, options?: TaskOptions): Promise<boolean> {
|
|
33
|
+
return post<boolean>('pdc.has', { world, x, y, z, key }, options);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
export function removeBlock(world: string, x: number, y: number, z: number, key: string): Promise<boolean> {
|
|
36
|
-
return post<boolean>('pdc.remove', { world, x, y, z, key });
|
|
36
|
+
export function removeBlock(world: string, x: number, y: number, z: number, key: string, options?: TaskOptions): Promise<boolean> {
|
|
37
|
+
return post<boolean>('pdc.remove', { world, x, y, z, key }, options);
|
|
37
38
|
}
|