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/src/world.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 { Block } from './block.js';
4
5
  import { Chunk, ChunkData } from './chunk.js';
@@ -8,18 +9,18 @@ interface WorldData {
8
9
  }
9
10
 
10
11
  export class World {
11
- static get(name: string): Promise<World | null> {
12
- return post<WorldData>('world.get', { name }).then((d) => (d ? new World(d.name) : null));
12
+ static get(name: string, options?: TaskOptions): Promise<World | null> {
13
+ return post<WorldData>('world.get', { name }, options).then((d) => (d ? new World(d.name) : null));
13
14
  }
14
- static getSync(name: string): World | null {
15
- const d = call<WorldData>('world.get', { name });
15
+ static getSync(name: string, options?: TaskOptions): World | null {
16
+ const d = call<WorldData>('world.get', { name }, options);
16
17
  return d ? new World(d.name) : null;
17
18
  }
18
- static getAll(): Promise<World[]> {
19
- return post<WorldData[]>('world.getAll', {}).then((list) => list.map((r) => new World(r.name)));
19
+ static getAll(options?: TaskOptions): Promise<World[]> {
20
+ return post<WorldData[]>('world.getAll', {}, options).then((list) => list.map((r) => new World(r.name)));
20
21
  }
21
- static getAllSync(): World[] {
22
- return call<WorldData[]>('world.getAll', {}).map((r) => new World(r.name));
22
+ static getAllSync(options?: TaskOptions): World[] {
23
+ return call<WorldData[]>('world.getAll', {}, options).map((r) => new World(r.name));
23
24
  }
24
25
 
25
26
  constructor(public readonly name: string) {}
@@ -38,132 +39,132 @@ export class World {
38
39
  }
39
40
  set spawnLocation(v: Location) { call('world.setSpawnLocation', { world: this.name, ...v.toObject() }); }
40
41
 
41
- getHighestBlockY(x: number, z: number): Promise<number> {
42
- return post<number>('world.getHighestBlockY', { world: this.name, x, z });
42
+ getHighestBlockY(x: number, z: number, options?: TaskOptions): Promise<number> {
43
+ return post<number>('world.getHighestBlockY', { world: this.name, x, z }, options);
43
44
  }
44
- getHighestBlockYSync(x: number, z: number): number {
45
- return call<number>('world.getHighestBlockY', { world: this.name, x, z });
45
+ getHighestBlockYSync(x: number, z: number, options?: TaskOptions): number {
46
+ return call<number>('world.getHighestBlockY', { world: this.name, x, z }, options);
46
47
  }
47
- getChunkAt(x: number, z: number): Promise<Chunk> {
48
- return post<ChunkData>('world.getChunkAt', { world: this.name, x, z }).then((d) => Chunk.from(d));
48
+ getChunkAt(x: number, z: number, options?: TaskOptions): Promise<Chunk> {
49
+ return post<ChunkData>('world.getChunkAt', { world: this.name, x, z }, options).then((d) => Chunk.from(d));
49
50
  }
50
- getChunkAtSync(x: number, z: number): Chunk {
51
- return Chunk.from(call<ChunkData>('world.getChunkAt', { world: this.name, x, z }));
51
+ getChunkAtSync(x: number, z: number, options?: TaskOptions): Chunk {
52
+ return Chunk.from(call<ChunkData>('world.getChunkAt', { world: this.name, x, z }, options));
52
53
  }
53
- isChunkLoaded(x: number, z: number): Promise<boolean> {
54
- return post<boolean>('world.isChunkLoaded', { world: this.name, x, z });
54
+ isChunkLoaded(x: number, z: number, options?: TaskOptions): Promise<boolean> {
55
+ return post<boolean>('world.isChunkLoaded', { world: this.name, x, z }, options);
55
56
  }
56
- isChunkLoadedSync(x: number, z: number): boolean {
57
- return call<boolean>('world.isChunkLoaded', { world: this.name, x, z });
57
+ isChunkLoadedSync(x: number, z: number, options?: TaskOptions): boolean {
58
+ return call<boolean>('world.isChunkLoaded', { world: this.name, x, z }, options);
58
59
  }
59
- loadChunk(x: number, z: number): Promise<boolean> {
60
- return post<boolean>('world.loadChunk', { world: this.name, x, z });
60
+ loadChunk(x: number, z: number, options?: TaskOptions): Promise<boolean> {
61
+ return post<boolean>('world.loadChunk', { world: this.name, x, z }, options);
61
62
  }
62
- loadChunkSync(x: number, z: number): boolean {
63
- return call<boolean>('world.loadChunk', { world: this.name, x, z });
63
+ loadChunkSync(x: number, z: number, options?: TaskOptions): boolean {
64
+ return call<boolean>('world.loadChunk', { world: this.name, x, z }, options);
64
65
  }
65
- unloadChunk(x: number, z: number): Promise<boolean> {
66
- return post<boolean>('world.unloadChunk', { world: this.name, x, z });
66
+ unloadChunk(x: number, z: number, options?: TaskOptions): Promise<boolean> {
67
+ return post<boolean>('world.unloadChunk', { world: this.name, x, z }, options);
67
68
  }
68
- unloadChunkSync(x: number, z: number): boolean {
69
- return call<boolean>('world.unloadChunk', { world: this.name, x, z });
69
+ unloadChunkSync(x: number, z: number, options?: TaskOptions): boolean {
70
+ return call<boolean>('world.unloadChunk', { world: this.name, x, z }, options);
70
71
  }
71
- getBlockLightLevel(x: number, y: number, z: number): Promise<number> {
72
- return post<number>('world.getBlockLightLevel', { world: this.name, x, y, z });
72
+ getBlockLightLevel(x: number, y: number, z: number, options?: TaskOptions): Promise<number> {
73
+ return post<number>('world.getBlockLightLevel', { world: this.name, x, y, z }, options);
73
74
  }
74
- getBlockLightLevelSync(x: number, y: number, z: number): number {
75
- return call<number>('world.getBlockLightLevel', { world: this.name, x, y, z });
75
+ getBlockLightLevelSync(x: number, y: number, z: number, options?: TaskOptions): number {
76
+ return call<number>('world.getBlockLightLevel', { world: this.name, x, y, z }, options);
76
77
  }
77
- getSkyLightLevel(x: number, y: number, z: number): Promise<number> {
78
- return post<number>('world.getSkyLightLevel', { world: this.name, x, y, z });
78
+ getSkyLightLevel(x: number, y: number, z: number, options?: TaskOptions): Promise<number> {
79
+ return post<number>('world.getSkyLightLevel', { world: this.name, x, y, z }, options);
79
80
  }
80
- getSkyLightLevelSync(x: number, y: number, z: number): number {
81
- return call<number>('world.getSkyLightLevel', { world: this.name, x, y, z });
81
+ getSkyLightLevelSync(x: number, y: number, z: number, options?: TaskOptions): number {
82
+ return call<number>('world.getSkyLightLevel', { world: this.name, x, y, z }, options);
82
83
  }
83
- getGameRule(rule: string): Promise<string | null> {
84
- return post<string | null>('world.getGameRule', { world: this.name, rule });
84
+ getGameRule(rule: string, options?: TaskOptions): Promise<string | null> {
85
+ return post<string | null>('world.getGameRule', { world: this.name, rule }, options);
85
86
  }
86
- getGameRuleSync(rule: string): string | null {
87
- return call<string | null>('world.getGameRule', { world: this.name, rule });
87
+ getGameRuleSync(rule: string, options?: TaskOptions): string | null {
88
+ return call<string | null>('world.getGameRule', { world: this.name, rule }, options);
88
89
  }
89
- setGameRule(rule: string, value: string): Promise<boolean> {
90
- return post('world.setGameRule', { world: this.name, rule, value });
90
+ setGameRule(rule: string, value: string, options?: TaskOptions): Promise<boolean> {
91
+ return post('world.setGameRule', { world: this.name, rule, value }, options);
91
92
  }
92
- setGameRuleSync(rule: string, value: string): boolean {
93
- return call<boolean>('world.setGameRule', { world: this.name, rule, value });
93
+ setGameRuleSync(rule: string, value: string, options?: TaskOptions): boolean {
94
+ return call<boolean>('world.setGameRule', { world: this.name, rule, value }, options);
94
95
  }
95
- getBiome(x: number, y: number, z: number): Promise<string> {
96
- return post<string>('world.getBiome', { world: this.name, x, y, z });
96
+ getBiome(x: number, y: number, z: number, options?: TaskOptions): Promise<string> {
97
+ return post<string>('world.getBiome', { world: this.name, x, y, z }, options);
97
98
  }
98
- getBiomeSync(x: number, y: number, z: number): string {
99
- return call<string>('world.getBiome', { world: this.name, x, y, z });
99
+ getBiomeSync(x: number, y: number, z: number, options?: TaskOptions): string {
100
+ return call<string>('world.getBiome', { world: this.name, x, y, z }, options);
100
101
  }
101
- getBlock(x: number, y: number, z: number): Promise<Block | null> {
102
- return post<{ x: number; y: number; z: number; type: string }>('world.getBlock', { world: this.name, x, y, z })
102
+ getBlock(x: number, y: number, z: number, options?: TaskOptions): Promise<Block | null> {
103
+ return post<{ x: number; y: number; z: number; type: string }>('world.getBlock', { world: this.name, x, y, z }, options)
103
104
  .then((r) => (r ? new Block(this.name, r.x, r.y, r.z, r.type) : null));
104
105
  }
105
- getBlockSync(x: number, y: number, z: number): Block | null {
106
- const r = call<{ x: number; y: number; z: number; type: string }>('world.getBlock', { world: this.name, x, y, z });
106
+ getBlockSync(x: number, y: number, z: number, options?: TaskOptions): Block | null {
107
+ const r = call<{ x: number; y: number; z: number; type: string }>('world.getBlock', { world: this.name, x, y, z }, options);
107
108
  return r ? new Block(this.name, r.x, r.y, r.z, r.type) : null;
108
109
  }
109
- setBlock(x: number, y: number, z: number, blockType: string): Promise<void> {
110
- return post('world.setBlock', { world: this.name, x, y, z, blockType });
110
+ setBlock(x: number, y: number, z: number, blockType: string, options?: TaskOptions): Promise<void> {
111
+ return post('world.setBlock', { world: this.name, x, y, z, blockType }, options);
111
112
  }
112
- setBlockSync(x: number, y: number, z: number, blockType: string): void {
113
- call('world.setBlock', { world: this.name, x, y, z, blockType });
113
+ setBlockSync(x: number, y: number, z: number, blockType: string, options?: TaskOptions): void {
114
+ call('world.setBlock', { world: this.name, x, y, z, blockType }, options);
114
115
  }
115
- getEntities(): Promise<string[]> {
116
- return post<string[]>('world.getEntities', { world: this.name });
116
+ getEntities(options?: TaskOptions): Promise<string[]> {
117
+ return post<string[]>('world.getEntities', { world: this.name }, options);
117
118
  }
118
- getEntitiesSync(): string[] {
119
- return call<string[]>('world.getEntities', { world: this.name });
119
+ getEntitiesSync(options?: TaskOptions): string[] {
120
+ return call<string[]>('world.getEntities', { world: this.name }, options);
120
121
  }
121
- getPlayers(): Promise<string[]> {
122
- return post<string[]>('world.getPlayers', { world: this.name });
122
+ getPlayers(options?: TaskOptions): Promise<string[]> {
123
+ return post<string[]>('world.getPlayers', { world: this.name }, options);
123
124
  }
124
- getPlayersSync(): string[] {
125
- return call<string[]>('world.getPlayers', { world: this.name });
125
+ getPlayersSync(options?: TaskOptions): string[] {
126
+ return call<string[]>('world.getPlayers', { world: this.name }, options);
126
127
  }
127
- getNearbyEntities(x: number, y: number, z: number, radius: number): Promise<string[]> {
128
- return post<string[]>('world.getNearbyEntities', { world: this.name, x, y, z, radius });
128
+ getNearbyEntities(x: number, y: number, z: number, radius: number, options?: TaskOptions): Promise<string[]> {
129
+ return post<string[]>('world.getNearbyEntities', { world: this.name, x, y, z, radius }, options);
129
130
  }
130
- getNearbyEntitiesSync(x: number, y: number, z: number, radius: number): string[] {
131
- return call<string[]>('world.getNearbyEntities', { world: this.name, x, y, z, radius });
131
+ getNearbyEntitiesSync(x: number, y: number, z: number, radius: number, options?: TaskOptions): string[] {
132
+ return call<string[]>('world.getNearbyEntities', { world: this.name, x, y, z, radius }, options);
132
133
  }
133
- dropItem(x: number, y: number, z: number, itemType: string, amount?: number): Promise<void> {
134
- return post('world.dropItem', { world: this.name, x, y, z, itemType, amount });
134
+ dropItem(x: number, y: number, z: number, itemType: string, amount?: number, options?: TaskOptions): Promise<void> {
135
+ return post('world.dropItem', { world: this.name, x, y, z, itemType, amount }, options);
135
136
  }
136
- dropItemSync(x: number, y: number, z: number, itemType: string, amount?: number): void {
137
- call('world.dropItem', { world: this.name, x, y, z, itemType, amount });
137
+ dropItemSync(x: number, y: number, z: number, itemType: string, amount?: number, options?: TaskOptions): void {
138
+ call('world.dropItem', { world: this.name, x, y, z, itemType, amount }, options);
138
139
  }
139
- strikeLightning(x: number, y: number, z: number): Promise<void> {
140
- return post('world.strikeLightning', { world: this.name, x, y, z });
140
+ strikeLightning(x: number, y: number, z: number, options?: TaskOptions): Promise<void> {
141
+ return post('world.strikeLightning', { world: this.name, x, y, z }, options);
141
142
  }
142
- strikeLightningSync(x: number, y: number, z: number): void {
143
- call('world.strikeLightning', { world: this.name, x, y, z });
143
+ strikeLightningSync(x: number, y: number, z: number, options?: TaskOptions): void {
144
+ call('world.strikeLightning', { world: this.name, x, y, z }, options);
144
145
  }
145
- strikeLightningEffect(x: number, y: number, z: number): Promise<void> {
146
- return post('world.strikeLightningEffect', { world: this.name, x, y, z });
146
+ strikeLightningEffect(x: number, y: number, z: number, options?: TaskOptions): Promise<void> {
147
+ return post('world.strikeLightningEffect', { world: this.name, x, y, z }, options);
147
148
  }
148
- strikeLightningEffectSync(x: number, y: number, z: number): void {
149
- call('world.strikeLightningEffect', { world: this.name, x, y, z });
149
+ strikeLightningEffectSync(x: number, y: number, z: number, options?: TaskOptions): void {
150
+ call('world.strikeLightningEffect', { world: this.name, x, y, z }, options);
150
151
  }
151
- createExplosion(x: number, y: number, z: number, power?: number, fire?: boolean, breaks?: boolean): Promise<void> {
152
- return post('world.createExplosion', { world: this.name, x, y, z, power, setFire: fire, breakBlocks: breaks });
152
+ createExplosion(x: number, y: number, z: number, power?: number, fire?: boolean, breaks?: boolean, options?: TaskOptions): Promise<void> {
153
+ return post('world.createExplosion', { world: this.name, x, y, z, power, setFire: fire, breakBlocks: breaks }, options);
153
154
  }
154
- createExplosionSync(x: number, y: number, z: number, power?: number, fire?: boolean, breaks?: boolean): void {
155
- call('world.createExplosion', { world: this.name, x, y, z, power, setFire: fire, breakBlocks: breaks });
155
+ createExplosionSync(x: number, y: number, z: number, power?: number, fire?: boolean, breaks?: boolean, options?: TaskOptions): void {
156
+ call('world.createExplosion', { world: this.name, x, y, z, power, setFire: fire, breakBlocks: breaks }, options);
156
157
  }
157
- spawnEntity(type: string, x: number, y: number, z: number): Promise<string | null> {
158
- return post<string | null>('world.spawnEntity', { world: this.name, type, x, y, z });
158
+ spawnEntity(type: string, x: number, y: number, z: number, options?: TaskOptions): Promise<string | null> {
159
+ return post<string | null>('world.spawnEntity', { world: this.name, type, x, y, z }, options);
159
160
  }
160
- spawnEntitySync(type: string, x: number, y: number, z: number): string | null {
161
- return call<string | null>('world.spawnEntity', { world: this.name, type, x, y, z });
161
+ spawnEntitySync(type: string, x: number, y: number, z: number, options?: TaskOptions): string | null {
162
+ return call<string | null>('world.spawnEntity', { world: this.name, type, x, y, z }, options);
162
163
  }
163
- playSound(sound: string, x: number, y: number, z: number, volume?: number, pitch?: number): Promise<void> {
164
- return post('world.playSound', { world: this.name, sound, x, y, z, volume, pitch });
164
+ playSound(sound: string, x: number, y: number, z: number, volume?: number, pitch?: number, options?: TaskOptions): Promise<void> {
165
+ return post('world.playSound', { world: this.name, sound, x, y, z, volume, pitch }, options);
165
166
  }
166
- playSoundSync(sound: string, x: number, y: number, z: number, volume?: number, pitch?: number): void {
167
- call('world.playSound', { world: this.name, sound, x, y, z, volume, pitch });
167
+ playSoundSync(sound: string, x: number, y: number, z: number, volume?: number, pitch?: number, options?: TaskOptions): void {
168
+ call('world.playSound', { world: this.name, sound, x, y, z, volume, pitch }, options);
168
169
  }
169
170
  }