yeow-api 0.2.102 → 0.2.103
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/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/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/src/player.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
|
import type { ItemStack } from './item.js';
|
|
4
5
|
|
|
@@ -8,18 +9,18 @@ interface PlayerData {
|
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export class Player {
|
|
11
|
-
static get(identifier: string): Promise<Player | null> {
|
|
12
|
-
return post<PlayerData>('player.get', { identifier }).then((d) => (d ? new Player(d.uuid, d.name) : null));
|
|
12
|
+
static get(identifier: string, options?: TaskOptions): Promise<Player | null> {
|
|
13
|
+
return post<PlayerData>('player.get', { identifier }, options).then((d) => (d ? new Player(d.uuid, d.name) : null));
|
|
13
14
|
}
|
|
14
|
-
static getSync(identifier: string): Player | null {
|
|
15
|
-
const d = call<PlayerData>('player.get', { identifier });
|
|
15
|
+
static getSync(identifier: string, options?: TaskOptions): Player | null {
|
|
16
|
+
const d = call<PlayerData>('player.get', { identifier }, options);
|
|
16
17
|
return d ? new Player(d.uuid, d.name) : null;
|
|
17
18
|
}
|
|
18
|
-
static getAll(): Promise<Player[]> {
|
|
19
|
-
return post<PlayerData[]>('player.getAll', {}).then((list) => list.map((r) => new Player(r.uuid, r.name)));
|
|
19
|
+
static getAll(options?: TaskOptions): Promise<Player[]> {
|
|
20
|
+
return post<PlayerData[]>('player.getAll', {}, options).then((list) => list.map((r) => new Player(r.uuid, r.name)));
|
|
20
21
|
}
|
|
21
|
-
static getAllSync(): Player[] {
|
|
22
|
-
return call<PlayerData[]>('player.getAll', {}).map((r) => new Player(r.uuid, r.name));
|
|
22
|
+
static getAllSync(options?: TaskOptions): Player[] {
|
|
23
|
+
return call<PlayerData[]>('player.getAll', {}, options).map((r) => new Player(r.uuid, r.name));
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
constructor(public readonly uuid: string, private _name?: string) {}
|
|
@@ -27,127 +28,127 @@ export class Player {
|
|
|
27
28
|
get name(): string { return this._name ?? ''; }
|
|
28
29
|
|
|
29
30
|
get ping(): number { return call<number>('player.getPing', { uuid: this.uuid }); }
|
|
30
|
-
getPing(): Promise<number> { return post<number>('player.getPing', { uuid: this.uuid }); }
|
|
31
|
+
getPing(options?: TaskOptions): Promise<number> { return post<number>('player.getPing', { uuid: this.uuid }, options); }
|
|
31
32
|
|
|
32
33
|
get gamemode(): string { return call<string>('player.getGamemode', { uuid: this.uuid }); }
|
|
33
34
|
set gamemode(v: string) { call('player.setGamemode', { uuid: this.uuid, value: v }); }
|
|
34
|
-
getGamemode(): Promise<string> { return post<string>('player.getGamemode', { uuid: this.uuid }); }
|
|
35
|
-
setGamemode(v: string): Promise<void> { return post('player.setGamemode', { uuid: this.uuid, value: v }); }
|
|
35
|
+
getGamemode(options?: TaskOptions): Promise<string> { return post<string>('player.getGamemode', { uuid: this.uuid }, options); }
|
|
36
|
+
setGamemode(v: string, options?: TaskOptions): Promise<void> { return post('player.setGamemode', { uuid: this.uuid, value: v }, options); }
|
|
36
37
|
|
|
37
38
|
get health(): number { return call<number>('player.getHealth', { uuid: this.uuid }); }
|
|
38
39
|
set health(v: number) { call('player.setHealth', { uuid: this.uuid, value: v }); }
|
|
39
|
-
getHealth(): Promise<number> { return post<number>('player.getHealth', { uuid: this.uuid }); }
|
|
40
|
-
setHealth(v: number): Promise<void> { return post('player.setHealth', { uuid: this.uuid, value: v }); }
|
|
40
|
+
getHealth(options?: TaskOptions): Promise<number> { return post<number>('player.getHealth', { uuid: this.uuid }, options); }
|
|
41
|
+
setHealth(v: number, options?: TaskOptions): Promise<void> { return post('player.setHealth', { uuid: this.uuid, value: v }, options); }
|
|
41
42
|
|
|
42
43
|
get food(): number { return call<number>('player.getFood', { uuid: this.uuid }); }
|
|
43
44
|
set food(v: number) { call('player.setFood', { uuid: this.uuid, value: v }); }
|
|
44
|
-
getFood(): Promise<number> { return post<number>('player.getFood', { uuid: this.uuid }); }
|
|
45
|
-
setFood(v: number): Promise<void> { return post('player.setFood', { uuid: this.uuid, value: v }); }
|
|
45
|
+
getFood(options?: TaskOptions): Promise<number> { return post<number>('player.getFood', { uuid: this.uuid }, options); }
|
|
46
|
+
setFood(v: number, options?: TaskOptions): Promise<void> { return post('player.setFood', { uuid: this.uuid, value: v }, options); }
|
|
46
47
|
|
|
47
48
|
get exp(): number { return call<number>('player.getExp', { uuid: this.uuid }); }
|
|
48
49
|
set exp(v: number) { call('player.setExp', { uuid: this.uuid, value: v }); }
|
|
49
|
-
getExp(): Promise<number> { return post<number>('player.getExp', { uuid: this.uuid }); }
|
|
50
|
-
setExp(v: number): Promise<void> { return post('player.setExp', { uuid: this.uuid, value: v }); }
|
|
50
|
+
getExp(options?: TaskOptions): Promise<number> { return post<number>('player.getExp', { uuid: this.uuid }, options); }
|
|
51
|
+
setExp(v: number, options?: TaskOptions): Promise<void> { return post('player.setExp', { uuid: this.uuid, value: v }, options); }
|
|
51
52
|
|
|
52
53
|
get level(): number { return call<number>('player.getLevel', { uuid: this.uuid }); }
|
|
53
54
|
set level(v: number) { call('player.setLevel', { uuid: this.uuid, value: v }); }
|
|
54
|
-
getLevel(): Promise<number> { return post<number>('player.getLevel', { uuid: this.uuid }); }
|
|
55
|
-
setLevel(v: number): Promise<void> { return post('player.setLevel', { uuid: this.uuid, value: v }); }
|
|
55
|
+
getLevel(options?: TaskOptions): Promise<number> { return post<number>('player.getLevel', { uuid: this.uuid }, options); }
|
|
56
|
+
setLevel(v: number, options?: TaskOptions): Promise<void> { return post('player.setLevel', { uuid: this.uuid, value: v }, options); }
|
|
56
57
|
|
|
57
58
|
get isOp(): boolean { return call<boolean>('player.isOp', { uuid: this.uuid }); }
|
|
58
|
-
isOpAsync(): Promise<boolean> { return post<boolean>('player.isOp', { uuid: this.uuid }); }
|
|
59
|
+
isOpAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('player.isOp', { uuid: this.uuid }, options); }
|
|
59
60
|
|
|
60
61
|
get online(): boolean { return call<boolean>('player.isOnline', { uuid: this.uuid }); }
|
|
61
|
-
getOnline(): Promise<boolean> { return post<boolean>('player.isOnline', { uuid: this.uuid }); }
|
|
62
|
+
getOnline(options?: TaskOptions): Promise<boolean> { return post<boolean>('player.isOnline', { uuid: this.uuid }, options); }
|
|
62
63
|
|
|
63
64
|
get isFlying(): boolean { return call<boolean>('player.isFlying', { uuid: this.uuid }); }
|
|
64
65
|
set isFlying(v: boolean) { call('player.setFlying', { uuid: this.uuid, value: v }); }
|
|
65
|
-
isFlyingAsync(): Promise<boolean> { return post<boolean>('player.isFlying', { uuid: this.uuid }); }
|
|
66
|
-
setFlying(v: boolean): Promise<void> { return post('player.setFlying', { uuid: this.uuid, value: v }); }
|
|
66
|
+
isFlyingAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('player.isFlying', { uuid: this.uuid }, options); }
|
|
67
|
+
setFlying(v: boolean, options?: TaskOptions): Promise<void> { return post('player.setFlying', { uuid: this.uuid, value: v }, options); }
|
|
67
68
|
|
|
68
69
|
get isSneaking(): boolean { return call<boolean>('player.isSneaking', { uuid: this.uuid }); }
|
|
69
|
-
isSneakingAsync(): Promise<boolean> { return post<boolean>('player.isSneaking', { uuid: this.uuid }); }
|
|
70
|
+
isSneakingAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('player.isSneaking', { uuid: this.uuid }, options); }
|
|
70
71
|
get isSprinting(): boolean { return call<boolean>('player.isSprinting', { uuid: this.uuid }); }
|
|
71
|
-
isSprintingAsync(): Promise<boolean> { return post<boolean>('player.isSprinting', { uuid: this.uuid }); }
|
|
72
|
+
isSprintingAsync(options?: TaskOptions): Promise<boolean> { return post<boolean>('player.isSprinting', { uuid: this.uuid }, options); }
|
|
72
73
|
|
|
73
74
|
get bedLocation(): Location | null {
|
|
74
75
|
const r = call<LocationData>('player.getBedLocation', { uuid: this.uuid });
|
|
75
76
|
return r ? Location.from(r) : null;
|
|
76
77
|
}
|
|
77
|
-
getBedLocation(): Promise<Location | null> {
|
|
78
|
-
return post<LocationData>('player.getBedLocation', { uuid: this.uuid }).then((r) => (r ? Location.from(r) : null));
|
|
78
|
+
getBedLocation(options?: TaskOptions): Promise<Location | null> {
|
|
79
|
+
return post<LocationData>('player.getBedLocation', { uuid: this.uuid }, options).then((r) => (r ? Location.from(r) : null));
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
get allowFlight(): boolean { return call<boolean>('player.getAllowFlight', { uuid: this.uuid }); }
|
|
82
83
|
set allowFlight(v: boolean) { call('player.setAllowFlight', { uuid: this.uuid, value: v }); }
|
|
83
|
-
getAllowFlight(): Promise<boolean> { return post<boolean>('player.getAllowFlight', { uuid: this.uuid }); }
|
|
84
|
-
setAllowFlight(v: boolean): Promise<void> { return post('player.setAllowFlight', { uuid: this.uuid, value: v }); }
|
|
84
|
+
getAllowFlight(options?: TaskOptions): Promise<boolean> { return post<boolean>('player.getAllowFlight', { uuid: this.uuid }, options); }
|
|
85
|
+
setAllowFlight(v: boolean, options?: TaskOptions): Promise<void> { return post('player.setAllowFlight', { uuid: this.uuid, value: v }, options); }
|
|
85
86
|
|
|
86
87
|
get walkSpeed(): number { return call<number>('player.getWalkSpeed', { uuid: this.uuid }); }
|
|
87
88
|
set walkSpeed(v: number) { call('player.setWalkSpeed', { uuid: this.uuid, value: v }); }
|
|
88
|
-
getWalkSpeed(): Promise<number> { return post<number>('player.getWalkSpeed', { uuid: this.uuid }); }
|
|
89
|
-
setWalkSpeed(v: number): Promise<void> { return post('player.setWalkSpeed', { uuid: this.uuid, value: v }); }
|
|
89
|
+
getWalkSpeed(options?: TaskOptions): Promise<number> { return post<number>('player.getWalkSpeed', { uuid: this.uuid }, options); }
|
|
90
|
+
setWalkSpeed(v: number, options?: TaskOptions): Promise<void> { return post('player.setWalkSpeed', { uuid: this.uuid, value: v }, options); }
|
|
90
91
|
|
|
91
92
|
get flySpeed(): number { return call<number>('player.getFlySpeed', { uuid: this.uuid }); }
|
|
92
93
|
set flySpeed(v: number) { call('player.setFlySpeed', { uuid: this.uuid, value: v }); }
|
|
93
|
-
getFlySpeed(): Promise<number> { return post<number>('player.getFlySpeed', { uuid: this.uuid }); }
|
|
94
|
-
setFlySpeed(v: number): Promise<void> { return post('player.setFlySpeed', { uuid: this.uuid, value: v }); }
|
|
94
|
+
getFlySpeed(options?: TaskOptions): Promise<number> { return post<number>('player.getFlySpeed', { uuid: this.uuid }, options); }
|
|
95
|
+
setFlySpeed(v: number, options?: TaskOptions): Promise<void> { return post('player.setFlySpeed', { uuid: this.uuid, value: v }, options); }
|
|
95
96
|
|
|
96
97
|
get world(): string { return call<string>('player.getWorld', { uuid: this.uuid }); }
|
|
97
|
-
getWorld(): Promise<string> { return post<string>('player.getWorld', { uuid: this.uuid }); }
|
|
98
|
+
getWorld(options?: TaskOptions): Promise<string> { return post<string>('player.getWorld', { uuid: this.uuid }, options); }
|
|
98
99
|
|
|
99
100
|
get location(): Location | null {
|
|
100
101
|
const r = call<LocationData>('player.getLocation', { uuid: this.uuid });
|
|
101
102
|
return r ? Location.from(r) : null;
|
|
102
103
|
}
|
|
103
|
-
getLocation(): Promise<Location | null> {
|
|
104
|
-
return post<LocationData>('player.getLocation', { uuid: this.uuid }).then((r) => (r ? Location.from(r) : null));
|
|
104
|
+
getLocation(options?: TaskOptions): Promise<Location | null> {
|
|
105
|
+
return post<LocationData>('player.getLocation', { uuid: this.uuid }, options).then((r) => (r ? Location.from(r) : null));
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
get displayName(): string { return call<string>('player.getDisplayName', { uuid: this.uuid }); }
|
|
108
109
|
set displayName(v: string | null) { call('player.setDisplayName', { uuid: this.uuid, value: v }); }
|
|
109
|
-
getDisplayName(): Promise<string> { return post<string>('player.getDisplayName', { uuid: this.uuid }); }
|
|
110
|
-
setDisplayName(v: string | null): Promise<void> { return post('player.setDisplayName', { uuid: this.uuid, value: v }); }
|
|
110
|
+
getDisplayName(options?: TaskOptions): Promise<string> { return post<string>('player.getDisplayName', { uuid: this.uuid }, options); }
|
|
111
|
+
setDisplayName(v: string | null, options?: TaskOptions): Promise<void> { return post('player.setDisplayName', { uuid: this.uuid, value: v }, options); }
|
|
111
112
|
|
|
112
113
|
get saturation(): number { return call<number>('player.getSaturation', { uuid: this.uuid }); }
|
|
113
|
-
getSaturation(): Promise<number> { return post<number>('player.getSaturation', { uuid: this.uuid }); }
|
|
114
|
+
getSaturation(options?: TaskOptions): Promise<number> { return post<number>('player.getSaturation', { uuid: this.uuid }, options); }
|
|
114
115
|
|
|
115
116
|
get totalExperience(): number { return call<number>('player.getTotalExperience', { uuid: this.uuid }); }
|
|
116
|
-
getTotalExperience(): Promise<number> { return post<number>('player.getTotalExperience', { uuid: this.uuid }); }
|
|
117
|
-
|
|
118
|
-
sendMessage(msg: string): Promise<void> { return post('player.sendMessage', { uuid: this.uuid, message: msg }); }
|
|
119
|
-
sendMessageSync(msg: string): void { call('player.sendMessage', { uuid: this.uuid, message: msg }); }
|
|
120
|
-
kick(reason?: string): Promise<void> { return post('player.kick', { uuid: this.uuid, reason }); }
|
|
121
|
-
kickSync(reason?: string): void { call('player.kick', { uuid: this.uuid, reason }); }
|
|
122
|
-
sendTitle(title?: string, subtitle?: string, fadeIn?: number, stay?: number, fadeOut?: number): Promise<void> {
|
|
123
|
-
return post('player.sendTitle', { uuid: this.uuid, title, subtitle, fadeIn, stay, fadeOut });
|
|
117
|
+
getTotalExperience(options?: TaskOptions): Promise<number> { return post<number>('player.getTotalExperience', { uuid: this.uuid }, options); }
|
|
118
|
+
|
|
119
|
+
sendMessage(msg: string, options?: TaskOptions): Promise<void> { return post('player.sendMessage', { uuid: this.uuid, message: msg }, options); }
|
|
120
|
+
sendMessageSync(msg: string, options?: TaskOptions): void { call('player.sendMessage', { uuid: this.uuid, message: msg }, options); }
|
|
121
|
+
kick(reason?: string, options?: TaskOptions): Promise<void> { return post('player.kick', { uuid: this.uuid, reason }, options); }
|
|
122
|
+
kickSync(reason?: string, options?: TaskOptions): void { call('player.kick', { uuid: this.uuid, reason }, options); }
|
|
123
|
+
sendTitle(title?: string, subtitle?: string, fadeIn?: number, stay?: number, fadeOut?: number, options?: TaskOptions): Promise<void> {
|
|
124
|
+
return post('player.sendTitle', { uuid: this.uuid, title, subtitle, fadeIn, stay, fadeOut }, options);
|
|
124
125
|
}
|
|
125
|
-
sendTitleSync(title?: string, subtitle?: string, fadeIn?: number, stay?: number, fadeOut?: number): void {
|
|
126
|
-
call('player.sendTitle', { uuid: this.uuid, title, subtitle, fadeIn, stay, fadeOut });
|
|
126
|
+
sendTitleSync(title?: string, subtitle?: string, fadeIn?: number, stay?: number, fadeOut?: number, options?: TaskOptions): void {
|
|
127
|
+
call('player.sendTitle', { uuid: this.uuid, title, subtitle, fadeIn, stay, fadeOut }, options);
|
|
127
128
|
}
|
|
128
|
-
playSound(sound: string, volume?: number, pitch?: number): Promise<void> {
|
|
129
|
-
return post('player.playSound', { uuid: this.uuid, sound, volume, pitch });
|
|
129
|
+
playSound(sound: string, volume?: number, pitch?: number, options?: TaskOptions): Promise<void> {
|
|
130
|
+
return post('player.playSound', { uuid: this.uuid, sound, volume, pitch }, options);
|
|
130
131
|
}
|
|
131
|
-
playSoundSync(sound: string, volume?: number, pitch?: number): void {
|
|
132
|
-
call('player.playSound', { uuid: this.uuid, sound, volume, pitch });
|
|
132
|
+
playSoundSync(sound: string, volume?: number, pitch?: number, options?: TaskOptions): void {
|
|
133
|
+
call('player.playSound', { uuid: this.uuid, sound, volume, pitch }, options);
|
|
133
134
|
}
|
|
134
|
-
giveExp(amount: number): Promise<void> { return post('player.giveExp', { uuid: this.uuid, amount }); }
|
|
135
|
-
giveExpSync(amount: number): void { call('player.giveExp', { uuid: this.uuid, amount }); }
|
|
136
|
-
hasPermission(node: string): Promise<boolean> {
|
|
137
|
-
return post<boolean>('player.hasPermission', { uuid: this.uuid, permission: node });
|
|
135
|
+
giveExp(amount: number, options?: TaskOptions): Promise<void> { return post('player.giveExp', { uuid: this.uuid, amount }, options); }
|
|
136
|
+
giveExpSync(amount: number, options?: TaskOptions): void { call('player.giveExp', { uuid: this.uuid, amount }, options); }
|
|
137
|
+
hasPermission(node: string, options?: TaskOptions): Promise<boolean> {
|
|
138
|
+
return post<boolean>('player.hasPermission', { uuid: this.uuid, permission: node }, options);
|
|
138
139
|
}
|
|
139
|
-
hasPermissionSync(node: string): boolean {
|
|
140
|
-
return call<boolean>('player.hasPermission', { uuid: this.uuid, permission: node });
|
|
140
|
+
hasPermissionSync(node: string, options?: TaskOptions): boolean {
|
|
141
|
+
return call<boolean>('player.hasPermission', { uuid: this.uuid, permission: node }, options);
|
|
141
142
|
}
|
|
142
|
-
teleport(loc: Location): Promise<void> { return post('player.teleport', { uuid: this.uuid, ...loc.toObject() }); }
|
|
143
|
-
teleportSync(loc: Location): void { call('player.teleport', { uuid: this.uuid, ...loc.toObject() }); }
|
|
144
|
-
sendActionBar(message: string): Promise<void> { return post('player.sendActionBar', { uuid: this.uuid, message }); }
|
|
145
|
-
sendActionBarSync(message: string): void { call('player.sendActionBar', { uuid: this.uuid, message }); }
|
|
146
|
-
sendResourcePack(url: string, hash?: string, prompt?: string, force?: boolean): Promise<void> {
|
|
147
|
-
return post('player.sendResourcePack', { uuid: this.uuid, url, hash, prompt, force });
|
|
143
|
+
teleport(loc: Location, options?: TaskOptions): Promise<void> { return post('player.teleport', { uuid: this.uuid, ...loc.toObject() }, options); }
|
|
144
|
+
teleportSync(loc: Location, options?: TaskOptions): void { call('player.teleport', { uuid: this.uuid, ...loc.toObject() }, options); }
|
|
145
|
+
sendActionBar(message: string, options?: TaskOptions): Promise<void> { return post('player.sendActionBar', { uuid: this.uuid, message }, options); }
|
|
146
|
+
sendActionBarSync(message: string, options?: TaskOptions): void { call('player.sendActionBar', { uuid: this.uuid, message }, options); }
|
|
147
|
+
sendResourcePack(url: string, hash?: string, prompt?: string, force?: boolean, options?: TaskOptions): Promise<void> {
|
|
148
|
+
return post('player.sendResourcePack', { uuid: this.uuid, url, hash, prompt, force }, options);
|
|
148
149
|
}
|
|
149
|
-
getItemInMainHand(): Promise<ItemStack | null> { return post<ItemStack | null>('player.getItemInMainHand', { uuid: this.uuid }); }
|
|
150
|
-
getItemInMainHandSync(): ItemStack | null { return call<ItemStack | null>('player.getItemInMainHand', { uuid: this.uuid }); }
|
|
151
|
-
getItemInOffHand(): Promise<ItemStack | null> { return post<ItemStack | null>('player.getItemInOffHand', { uuid: this.uuid }); }
|
|
152
|
-
getItemInOffHandSync(): ItemStack | null { return call<ItemStack | null>('player.getItemInOffHand', { uuid: this.uuid }); }
|
|
150
|
+
getItemInMainHand(options?: TaskOptions): Promise<ItemStack | null> { return post<ItemStack | null>('player.getItemInMainHand', { uuid: this.uuid }, options); }
|
|
151
|
+
getItemInMainHandSync(options?: TaskOptions): ItemStack | null { return call<ItemStack | null>('player.getItemInMainHand', { uuid: this.uuid }, options); }
|
|
152
|
+
getItemInOffHand(options?: TaskOptions): Promise<ItemStack | null> { return post<ItemStack | null>('player.getItemInOffHand', { uuid: this.uuid }, options); }
|
|
153
|
+
getItemInOffHandSync(options?: TaskOptions): ItemStack | null { return call<ItemStack | null>('player.getItemInOffHand', { uuid: this.uuid }, options); }
|
|
153
154
|
}
|
package/src/potion.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 PotionEffect {
|
|
4
5
|
type: string;
|
|
@@ -9,15 +10,15 @@ export interface PotionEffect {
|
|
|
9
10
|
icon?: boolean;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export function addPotionEffect(uuid: string, effect: PotionEffect): Promise<void> {
|
|
13
|
-
return post('entity.addPotionEffect', { uuid, ...effect });
|
|
13
|
+
export function addPotionEffect(uuid: string, effect: PotionEffect, options?: TaskOptions): Promise<void> {
|
|
14
|
+
return post('entity.addPotionEffect', { uuid, ...effect }, options);
|
|
14
15
|
}
|
|
15
|
-
export function removePotionEffect(uuid: string, type: string): Promise<void> {
|
|
16
|
-
return post('entity.removePotionEffect', { uuid, type });
|
|
16
|
+
export function removePotionEffect(uuid: string, type: string, options?: TaskOptions): Promise<void> {
|
|
17
|
+
return post('entity.removePotionEffect', { uuid, type }, options);
|
|
17
18
|
}
|
|
18
|
-
export function clearPotionEffects(uuid: string): Promise<void> {
|
|
19
|
-
return post('entity.clearPotionEffects', { uuid });
|
|
19
|
+
export function clearPotionEffects(uuid: string, options?: TaskOptions): Promise<void> {
|
|
20
|
+
return post('entity.clearPotionEffects', { uuid }, options);
|
|
20
21
|
}
|
|
21
|
-
export function getActivePotionEffects(uuid: string): Promise<PotionEffect[]> {
|
|
22
|
-
return post<PotionEffect[]>('entity.getActivePotionEffects', { uuid });
|
|
22
|
+
export function getActivePotionEffects(uuid: string, options?: TaskOptions): Promise<PotionEffect[]> {
|
|
23
|
+
return post<PotionEffect[]>('entity.getActivePotionEffects', { uuid }, options);
|
|
23
24
|
}
|
package/src/recipe.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
|
type RecipeDefinition = ShapedRecipe | ShapelessRecipe | FurnaceRecipe | BlastRecipe | SmokerRecipe | CampfireRecipe;
|
|
@@ -53,14 +54,14 @@ interface CampfireRecipe {
|
|
|
53
54
|
cookingTime?: number;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
export function add(recipe: RecipeDefinition): Promise<boolean> {
|
|
57
|
-
return post<boolean>('recipe.add', recipe as unknown as Record<string, unknown
|
|
57
|
+
export function add(recipe: RecipeDefinition, options?: TaskOptions): Promise<boolean> {
|
|
58
|
+
return post<boolean>('recipe.add', recipe as unknown as Record<string, unknown>, options);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
export function remove(key: string): Promise<void> {
|
|
61
|
-
return post('recipe.remove', { key });
|
|
61
|
+
export function remove(key: string, options?: TaskOptions): Promise<void> {
|
|
62
|
+
return post('recipe.remove', { key }, options);
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
export function getForItem(item: ItemStack): Promise<string[]> {
|
|
65
|
-
return post<string[]>('recipe.getForItem', { item });
|
|
65
|
+
export function getForItem(item: ItemStack, options?: TaskOptions): Promise<string[]> {
|
|
66
|
+
return post<string[]>('recipe.getForItem', { item }, options);
|
|
66
67
|
}
|
package/src/scoreboard.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 ObjectiveInfo {
|
|
4
5
|
name: string;
|
|
@@ -28,102 +29,102 @@ function boardParam(board?: string): Record<string, unknown> {
|
|
|
28
29
|
|
|
29
30
|
// ── Board ──
|
|
30
31
|
|
|
31
|
-
export function createBoard(id: string): Promise<string> {
|
|
32
|
-
return post<string>('scoreboard.createBoard', { id });
|
|
32
|
+
export function createBoard(id: string, options?: TaskOptions): Promise<string> {
|
|
33
|
+
return post<string>('scoreboard.createBoard', { id }, options);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
export function deleteBoard(id: string): Promise<void> {
|
|
36
|
-
return post('scoreboard.deleteBoard', { id });
|
|
36
|
+
export function deleteBoard(id: string, options?: TaskOptions): Promise<void> {
|
|
37
|
+
return post('scoreboard.deleteBoard', { id }, options);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
// ── Objectives ──
|
|
40
41
|
|
|
41
|
-
export function createObjective(name: string, criteria: string, displayName: string, board?: string): Promise<ObjectiveInfo> {
|
|
42
|
-
return post<ObjectiveInfo>('scoreboard.createObjective', { name, criteria, displayName, ...boardParam(board) });
|
|
42
|
+
export function createObjective(name: string, criteria: string, displayName: string, board?: string, options?: TaskOptions): Promise<ObjectiveInfo> {
|
|
43
|
+
return post<ObjectiveInfo>('scoreboard.createObjective', { name, criteria, displayName, ...boardParam(board) }, options);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export function deleteObjective(name: string, board?: string): Promise<void> {
|
|
46
|
-
return post('scoreboard.deleteObjective', { name, ...boardParam(board) });
|
|
46
|
+
export function deleteObjective(name: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
47
|
+
return post('scoreboard.deleteObjective', { name, ...boardParam(board) }, options);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
export function getObjectives(board?: string): Promise<ObjectiveInfo[]> {
|
|
50
|
-
return post<ObjectiveInfo[]>('scoreboard.getObjectives', { ...boardParam(board) });
|
|
50
|
+
export function getObjectives(board?: string, options?: TaskOptions): Promise<ObjectiveInfo[]> {
|
|
51
|
+
return post<ObjectiveInfo[]>('scoreboard.getObjectives', { ...boardParam(board) }, options);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
export function setObjectiveDisplay(name: string, slot: string | null, board?: string): Promise<boolean> {
|
|
54
|
-
return post<boolean>('scoreboard.setObjectiveDisplay', { name, slot, ...boardParam(board) });
|
|
54
|
+
export function setObjectiveDisplay(name: string, slot: string | null, board?: string, options?: TaskOptions): Promise<boolean> {
|
|
55
|
+
return post<boolean>('scoreboard.setObjectiveDisplay', { name, slot, ...boardParam(board) }, options);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
export function getScore(objective: string, entry: string, board?: string): Promise<number | null> {
|
|
58
|
-
return post<number | null>('scoreboard.getScore', { objective, entry, ...boardParam(board) });
|
|
58
|
+
export function getScore(objective: string, entry: string, board?: string, options?: TaskOptions): Promise<number | null> {
|
|
59
|
+
return post<number | null>('scoreboard.getScore', { objective, entry, ...boardParam(board) }, options);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
export function setScore(objective: string, entry: string, value: number, board?: string): Promise<void> {
|
|
62
|
-
return post('scoreboard.setScore', { objective, entry, value, ...boardParam(board) });
|
|
62
|
+
export function setScore(objective: string, entry: string, value: number, board?: string, options?: TaskOptions): Promise<void> {
|
|
63
|
+
return post('scoreboard.setScore', { objective, entry, value, ...boardParam(board) }, options);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
export function resetScore(objective: string, entry: string, board?: string): Promise<void> {
|
|
66
|
-
return post('scoreboard.resetScore', { objective, entry, ...boardParam(board) });
|
|
66
|
+
export function resetScore(objective: string, entry: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
67
|
+
return post('scoreboard.resetScore', { objective, entry, ...boardParam(board) }, options);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
// ── Teams ──
|
|
70
71
|
|
|
71
|
-
export function createTeam(name: string, board?: string): Promise<void> {
|
|
72
|
-
return post('scoreboard.createTeam', { name, ...boardParam(board) });
|
|
72
|
+
export function createTeam(name: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
73
|
+
return post('scoreboard.createTeam', { name, ...boardParam(board) }, options);
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
export function deleteTeam(name: string, board?: string): Promise<void> {
|
|
76
|
-
return post('scoreboard.deleteTeam', { name, ...boardParam(board) });
|
|
76
|
+
export function deleteTeam(name: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
77
|
+
return post('scoreboard.deleteTeam', { name, ...boardParam(board) }, options);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
export function getTeam(name: string, board?: string): Promise<TeamInfo | null> {
|
|
80
|
-
return post<TeamInfo | null>('scoreboard.getTeam', { name, ...boardParam(board) });
|
|
80
|
+
export function getTeam(name: string, board?: string, options?: TaskOptions): Promise<TeamInfo | null> {
|
|
81
|
+
return post<TeamInfo | null>('scoreboard.getTeam', { name, ...boardParam(board) }, options);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
export function getTeams(board?: string): Promise<TeamInfo[]> {
|
|
84
|
-
return post<TeamInfo[]>('scoreboard.getTeams', { ...boardParam(board) });
|
|
84
|
+
export function getTeams(board?: string, options?: TaskOptions): Promise<TeamInfo[]> {
|
|
85
|
+
return post<TeamInfo[]>('scoreboard.getTeams', { ...boardParam(board) }, options);
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
export function setTeamDisplayName(name: string, displayName: string, board?: string): Promise<void> {
|
|
88
|
-
return post('scoreboard.setTeamDisplayName', { name, displayName, ...boardParam(board) });
|
|
88
|
+
export function setTeamDisplayName(name: string, displayName: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
89
|
+
return post('scoreboard.setTeamDisplayName', { name, displayName, ...boardParam(board) }, options);
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
export function setTeamPrefix(name: string, prefix: string, board?: string): Promise<void> {
|
|
92
|
-
return post('scoreboard.setTeamPrefix', { name, prefix, ...boardParam(board) });
|
|
92
|
+
export function setTeamPrefix(name: string, prefix: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
93
|
+
return post('scoreboard.setTeamPrefix', { name, prefix, ...boardParam(board) }, options);
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
export function setTeamSuffix(name: string, suffix: string, board?: string): Promise<void> {
|
|
96
|
-
return post('scoreboard.setTeamSuffix', { name, suffix, ...boardParam(board) });
|
|
96
|
+
export function setTeamSuffix(name: string, suffix: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
97
|
+
return post('scoreboard.setTeamSuffix', { name, suffix, ...boardParam(board) }, options);
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
export function setTeamColor(name: string, color: string, board?: string): Promise<void> {
|
|
100
|
-
return post('scoreboard.setTeamColor', { name, color, ...boardParam(board) });
|
|
100
|
+
export function setTeamColor(name: string, color: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
101
|
+
return post('scoreboard.setTeamColor', { name, color, ...boardParam(board) }, options);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
export function setTeamFriendlyFire(name: string, allow: boolean, board?: string): Promise<void> {
|
|
104
|
-
return post('scoreboard.setTeamFriendlyFire', { name, allow, ...boardParam(board) });
|
|
104
|
+
export function setTeamFriendlyFire(name: string, allow: boolean, board?: string, options?: TaskOptions): Promise<void> {
|
|
105
|
+
return post('scoreboard.setTeamFriendlyFire', { name, allow, ...boardParam(board) }, options);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
export function setTeamSeeInvisible(name: string, canSee: boolean, board?: string): Promise<void> {
|
|
108
|
-
return post('scoreboard.setTeamSeeInvisible', { name, canSee, ...boardParam(board) });
|
|
108
|
+
export function setTeamSeeInvisible(name: string, canSee: boolean, board?: string, options?: TaskOptions): Promise<void> {
|
|
109
|
+
return post('scoreboard.setTeamSeeInvisible', { name, canSee, ...boardParam(board) }, options);
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
export function setTeamOption(name: string, option: string, value: string, board?: string): Promise<void> {
|
|
112
|
-
return post('scoreboard.setTeamOption', { name, option, value, ...boardParam(board) });
|
|
112
|
+
export function setTeamOption(name: string, option: string, value: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
113
|
+
return post('scoreboard.setTeamOption', { name, option, value, ...boardParam(board) }, options);
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
export function teamAddEntry(name: string, entry: string, board?: string): Promise<void> {
|
|
116
|
-
return post('scoreboard.teamAddEntry', { name, entry, ...boardParam(board) });
|
|
116
|
+
export function teamAddEntry(name: string, entry: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
117
|
+
return post('scoreboard.teamAddEntry', { name, entry, ...boardParam(board) }, options);
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
export function teamRemoveEntry(name: string, entry: string, board?: string): Promise<void> {
|
|
120
|
-
return post('scoreboard.teamRemoveEntry', { name, entry, ...boardParam(board) });
|
|
120
|
+
export function teamRemoveEntry(name: string, entry: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
121
|
+
return post('scoreboard.teamRemoveEntry', { name, entry, ...boardParam(board) }, options);
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
export function teamGetEntries(name: string, board?: string): Promise<string[]> {
|
|
124
|
-
return post<string[]>('scoreboard.teamGetEntries', { name, ...boardParam(board) });
|
|
124
|
+
export function teamGetEntries(name: string, board?: string, options?: TaskOptions): Promise<string[]> {
|
|
125
|
+
return post<string[]>('scoreboard.teamGetEntries', { name, ...boardParam(board) }, options);
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
export function setPlayerBoard(uuid: string, board?: string): Promise<void> {
|
|
128
|
-
return post('scoreboard.setPlayerBoard', { uuid, ...boardParam(board) });
|
|
128
|
+
export function setPlayerBoard(uuid: string, board?: string, options?: TaskOptions): Promise<void> {
|
|
129
|
+
return post('scoreboard.setPlayerBoard', { uuid, ...boardParam(board) }, options);
|
|
129
130
|
}
|
package/src/server.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { call, post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
|
|
3
|
-
export function broadcast(msg: string): Promise<void> { return post('server.broadcast', { message: msg }); }
|
|
4
|
-
export function broadcastSync(msg: string): void { call('server.broadcast', { message: msg }); }
|
|
5
|
-
export function dispatchCommand(cmd: string): Promise<boolean> { return post<boolean>('command.dispatch', { command: cmd }); }
|
|
6
|
-
export function dispatchCommandSync(cmd: string): boolean { return call<boolean>('command.dispatch', { command: cmd }); }
|
|
7
|
-
export function setMotd(motd: string): Promise<void> { return post('server.setMotd', { motd }); }
|
|
8
|
-
export function setMotdSync(motd: string): void { call('server.setMotd', { motd }); }
|
|
9
|
-
export function setIcon(base64: string): Promise<void> { return post('server.setIcon', { icon: base64 }); }
|
|
10
|
-
export function setIconSync(base64: string): void { call('server.setIcon', { icon: base64 }); }
|
|
11
|
-
export function getMotd(): Promise<string> { return post<string>('server.getMotd', {}); }
|
|
12
|
-
export function getMotdSync(): string { return call<string>('server.getMotd', {}); }
|
|
13
|
-
export function getVersion(): Promise<string> { return post<string>('server.getVersion', {}); }
|
|
14
|
-
export function getVersionSync(): string { return call<string>('server.getVersion', {}); }
|
|
4
|
+
export function broadcast(msg: string, options?: TaskOptions): Promise<void> { return post('server.broadcast', { message: msg }, options); }
|
|
5
|
+
export function broadcastSync(msg: string, options?: TaskOptions): void { call('server.broadcast', { message: msg }, options); }
|
|
6
|
+
export function dispatchCommand(cmd: string, options?: TaskOptions): Promise<boolean> { return post<boolean>('command.dispatch', { command: cmd }, options); }
|
|
7
|
+
export function dispatchCommandSync(cmd: string, options?: TaskOptions): boolean { return call<boolean>('command.dispatch', { command: cmd }, options); }
|
|
8
|
+
export function setMotd(motd: string, options?: TaskOptions): Promise<void> { return post('server.setMotd', { motd }, options); }
|
|
9
|
+
export function setMotdSync(motd: string, options?: TaskOptions): void { call('server.setMotd', { motd }, options); }
|
|
10
|
+
export function setIcon(base64: string, options?: TaskOptions): Promise<void> { return post('server.setIcon', { icon: base64 }, options); }
|
|
11
|
+
export function setIconSync(base64: string, options?: TaskOptions): void { call('server.setIcon', { icon: base64 }, options); }
|
|
12
|
+
export function getMotd(options?: TaskOptions): Promise<string> { return post<string>('server.getMotd', {}, options); }
|
|
13
|
+
export function getMotdSync(options?: TaskOptions): string { return call<string>('server.getMotd', {}, options); }
|
|
14
|
+
export function getVersion(options?: TaskOptions): Promise<string> { return post<string>('server.getVersion', {}, options); }
|
|
15
|
+
export function getVersionSync(options?: TaskOptions): string { return call<string>('server.getVersion', {}, options); }
|
package/src/sound.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { post } from './task.js';
|
|
2
|
+
import type { TaskOptions } from './task.js';
|
|
2
3
|
|
|
3
|
-
export function playSound(world: string, sound: string, x: number, y: number, z: number, volume?: number, pitch?: number): Promise<void> {
|
|
4
|
-
return post('world.playSound', { world, sound, x, y, z, volume, pitch });
|
|
4
|
+
export function playSound(world: string, sound: string, x: number, y: number, z: number, volume?: number, pitch?: number, options?: TaskOptions): Promise<void> {
|
|
5
|
+
return post('world.playSound', { world, sound, x, y, z, volume, pitch }, options);
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
export function stopSound(uuid: string, sound: string): Promise<void> {
|
|
8
|
-
return post('player.stopSound', { uuid, sound });
|
|
8
|
+
export function stopSound(uuid: string, sound: string, options?: TaskOptions): Promise<void> {
|
|
9
|
+
return post('player.stopSound', { uuid, sound }, options);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export function stopAllSounds(uuid: string): Promise<void> {
|
|
12
|
-
return post('player.stopAllSounds', { uuid });
|
|
12
|
+
export function stopAllSounds(uuid: string, options?: TaskOptions): Promise<void> {
|
|
13
|
+
return post('player.stopAllSounds', { uuid }, options);
|
|
13
14
|
}
|
package/src/task.ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
+
export interface TaskOptions {
|
|
2
|
+
/** 任务优先级:high / normal(默认)/ low */
|
|
3
|
+
priority?: 'high' | 'normal' | 'low';
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** 透传参数:TaskOptions 对象,或旧式字符串优先级。 */
|
|
7
|
+
type TaskOptionsArg = TaskOptions | string;
|
|
8
|
+
|
|
9
|
+
function applyOptions(pld: Record<string, unknown>, options?: TaskOptionsArg) {
|
|
10
|
+
if (!options) return;
|
|
11
|
+
pld.priority = typeof options === 'string' ? options : options.priority;
|
|
12
|
+
}
|
|
13
|
+
|
|
1
14
|
export function post<T = unknown>(
|
|
2
15
|
type: string,
|
|
3
16
|
params: Record<string, unknown> = {},
|
|
4
|
-
|
|
17
|
+
options?: TaskOptionsArg
|
|
5
18
|
): Promise<T> {
|
|
6
19
|
return new Promise((resolve, reject) => {
|
|
7
20
|
const cbId = _registerCallback((result: any) => {
|
|
8
21
|
if (result?.err) {
|
|
9
22
|
const msg = result.type ? `[${result.type}] ${result.err}` : result.err;
|
|
10
23
|
const e = new Error(msg);
|
|
11
|
-
if ($dev && typeof
|
|
12
|
-
|
|
13
|
-
if (s) e.stack += ' --- cb registered at ---\n' + s;
|
|
24
|
+
if ($dev && typeof _attachCbStack === 'function') {
|
|
25
|
+
_attachCbStack(e);
|
|
14
26
|
}
|
|
15
27
|
if (result.stack) {
|
|
16
28
|
e.stack += '\n --- runtime executer error(for reference) ---\n' + result.stack;
|
|
@@ -21,7 +33,7 @@ export function post<T = unknown>(
|
|
|
21
33
|
} else resolve(result as T);
|
|
22
34
|
});
|
|
23
35
|
const pld: Record<string, unknown> = { type, params, cb: cbId };
|
|
24
|
-
|
|
36
|
+
applyOptions(pld, options);
|
|
25
37
|
$send('task', pld);
|
|
26
38
|
});
|
|
27
39
|
}
|
|
@@ -29,10 +41,10 @@ export function post<T = unknown>(
|
|
|
29
41
|
export function call<T = unknown>(
|
|
30
42
|
type: string,
|
|
31
43
|
params: Record<string, unknown> = {},
|
|
32
|
-
|
|
44
|
+
options?: TaskOptionsArg
|
|
33
45
|
): T {
|
|
34
46
|
const pld: Record<string, unknown> = { type, params };
|
|
35
|
-
|
|
47
|
+
applyOptions(pld, options);
|
|
36
48
|
const r = $send('task', pld);
|
|
37
49
|
if (r == null) return undefined as T;
|
|
38
50
|
if ((r as any)?.err) throw new Error((r as any).err);
|