yeow-api 0.2.41 → 0.2.43

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeow-api",
3
- "version": "0.2.41",
3
+ "version": "0.2.43",
4
4
  "description": "Yeow API �?TypeScript OOP wrappers over the task protocol",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/block.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { call, post } from './task.js';
2
2
  import { Location } from './location.js';
3
+ import type { ItemStack } from './item.js';
3
4
 
4
5
  export class Block {
5
6
  constructor(
@@ -19,4 +20,14 @@ export class Block {
19
20
  isLiquidSync(): boolean { return call<boolean>('block.isLiquid', { world: this.world, x: this.x, y: this.y, z: this.z }); }
20
21
  isEmpty(): Promise<boolean> { return post<boolean>('block.isEmpty', { world: this.world, x: this.x, y: this.y, z: this.z }); }
21
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> {
24
+ const p: Record<string, unknown> = { world: this.world, x: this.x, y: this.y, z: this.z };
25
+ if (tool) p.item = tool;
26
+ return post<boolean>('block.breakNaturally', p);
27
+ }
28
+ breakNaturallySync(tool?: ItemStack): boolean {
29
+ const p: Record<string, unknown> = { world: this.world, x: this.x, y: this.y, z: this.z };
30
+ if (tool) p.item = tool;
31
+ return call<boolean>('block.breakNaturally', p);
32
+ }
22
33
  }
package/src/index.ts CHANGED
@@ -69,7 +69,8 @@ export { add as addRecipe, remove as removeRecipe, getForItem as getRecipesForIt
69
69
  export type {
70
70
  ObjectiveInfo, TeamInfo,
71
71
  } from './scoreboard.js';
72
- export { createObjective, deleteObjective, getObjectives,
72
+ export { createBoard as createScoreboard, deleteBoard as deleteScoreboard,
73
+ createObjective, deleteObjective, getObjectives,
73
74
  setObjectiveDisplay, getScore, setScore, resetScore,
74
75
  createTeam, deleteTeam, getTeam, getTeams,
75
76
  setTeamDisplayName, setTeamPrefix, setTeamSuffix, setTeamColor,
package/src/scoreboard.ts CHANGED
@@ -22,94 +22,108 @@ export interface TeamInfo {
22
22
  };
23
23
  }
24
24
 
25
+ function boardParam(board?: string): Record<string, unknown> {
26
+ return board ? { board } : {};
27
+ }
28
+
29
+ // ── Board ──
30
+
31
+ export function createBoard(id: string): Promise<string> {
32
+ return post<string>('scoreboard.createBoard', { id });
33
+ }
34
+
35
+ export function deleteBoard(id: string): Promise<void> {
36
+ return post('scoreboard.deleteBoard', { id });
37
+ }
38
+
25
39
  // ── Objectives ──
26
40
 
27
- export function createObjective(name: string, criteria: string, displayName: string): Promise<ObjectiveInfo> {
28
- return post<ObjectiveInfo>('scoreboard.createObjective', { name, criteria, displayName });
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) });
29
43
  }
30
44
 
31
- export function deleteObjective(name: string): Promise<void> {
32
- return post('scoreboard.deleteObjective', { name });
45
+ export function deleteObjective(name: string, board?: string): Promise<void> {
46
+ return post('scoreboard.deleteObjective', { name, ...boardParam(board) });
33
47
  }
34
48
 
35
- export function getObjectives(): Promise<ObjectiveInfo[]> {
36
- return post<ObjectiveInfo[]>('scoreboard.getObjectives', {});
49
+ export function getObjectives(board?: string): Promise<ObjectiveInfo[]> {
50
+ return post<ObjectiveInfo[]>('scoreboard.getObjectives', { ...boardParam(board) });
37
51
  }
38
52
 
39
- export function setObjectiveDisplay(name: string, slot: string | null): Promise<boolean> {
40
- return post<boolean>('scoreboard.setObjectiveDisplay', { name, slot });
53
+ export function setObjectiveDisplay(name: string, slot: string | null, board?: string): Promise<boolean> {
54
+ return post<boolean>('scoreboard.setObjectiveDisplay', { name, slot, ...boardParam(board) });
41
55
  }
42
56
 
43
- export function getScore(objective: string, entry: string): Promise<number | null> {
44
- return post<number | null>('scoreboard.getScore', { objective, entry });
57
+ export function getScore(objective: string, entry: string, board?: string): Promise<number | null> {
58
+ return post<number | null>('scoreboard.getScore', { objective, entry, ...boardParam(board) });
45
59
  }
46
60
 
47
- export function setScore(objective: string, entry: string, value: number): Promise<void> {
48
- return post('scoreboard.setScore', { objective, entry, value });
61
+ export function setScore(objective: string, entry: string, value: number, board?: string): Promise<void> {
62
+ return post('scoreboard.setScore', { objective, entry, value, ...boardParam(board) });
49
63
  }
50
64
 
51
- export function resetScore(objective: string, entry: string): Promise<void> {
52
- return post('scoreboard.resetScore', { objective, entry });
65
+ export function resetScore(objective: string, entry: string, board?: string): Promise<void> {
66
+ return post('scoreboard.resetScore', { objective, entry, ...boardParam(board) });
53
67
  }
54
68
 
55
69
  // ── Teams ──
56
70
 
57
- export function createTeam(name: string): Promise<void> {
58
- return post('scoreboard.createTeam', { name });
71
+ export function createTeam(name: string, board?: string): Promise<void> {
72
+ return post('scoreboard.createTeam', { name, ...boardParam(board) });
59
73
  }
60
74
 
61
- export function deleteTeam(name: string): Promise<void> {
62
- return post('scoreboard.deleteTeam', { name });
75
+ export function deleteTeam(name: string, board?: string): Promise<void> {
76
+ return post('scoreboard.deleteTeam', { name, ...boardParam(board) });
63
77
  }
64
78
 
65
- export function getTeam(name: string): Promise<TeamInfo | null> {
66
- return post<TeamInfo | null>('scoreboard.getTeam', { name });
79
+ export function getTeam(name: string, board?: string): Promise<TeamInfo | null> {
80
+ return post<TeamInfo | null>('scoreboard.getTeam', { name, ...boardParam(board) });
67
81
  }
68
82
 
69
- export function getTeams(): Promise<TeamInfo[]> {
70
- return post<TeamInfo[]>('scoreboard.getTeams', {});
83
+ export function getTeams(board?: string): Promise<TeamInfo[]> {
84
+ return post<TeamInfo[]>('scoreboard.getTeams', { ...boardParam(board) });
71
85
  }
72
86
 
73
- export function setTeamDisplayName(name: string, displayName: string): Promise<void> {
74
- return post('scoreboard.setTeamDisplayName', { name, displayName });
87
+ export function setTeamDisplayName(name: string, displayName: string, board?: string): Promise<void> {
88
+ return post('scoreboard.setTeamDisplayName', { name, displayName, ...boardParam(board) });
75
89
  }
76
90
 
77
- export function setTeamPrefix(name: string, prefix: string): Promise<void> {
78
- return post('scoreboard.setTeamPrefix', { name, prefix });
91
+ export function setTeamPrefix(name: string, prefix: string, board?: string): Promise<void> {
92
+ return post('scoreboard.setTeamPrefix', { name, prefix, ...boardParam(board) });
79
93
  }
80
94
 
81
- export function setTeamSuffix(name: string, suffix: string): Promise<void> {
82
- return post('scoreboard.setTeamSuffix', { name, suffix });
95
+ export function setTeamSuffix(name: string, suffix: string, board?: string): Promise<void> {
96
+ return post('scoreboard.setTeamSuffix', { name, suffix, ...boardParam(board) });
83
97
  }
84
98
 
85
- export function setTeamColor(name: string, color: string): Promise<void> {
86
- return post('scoreboard.setTeamColor', { name, color });
99
+ export function setTeamColor(name: string, color: string, board?: string): Promise<void> {
100
+ return post('scoreboard.setTeamColor', { name, color, ...boardParam(board) });
87
101
  }
88
102
 
89
- export function setTeamFriendlyFire(name: string, allow: boolean): Promise<void> {
90
- return post('scoreboard.setTeamFriendlyFire', { name, allow });
103
+ export function setTeamFriendlyFire(name: string, allow: boolean, board?: string): Promise<void> {
104
+ return post('scoreboard.setTeamFriendlyFire', { name, allow, ...boardParam(board) });
91
105
  }
92
106
 
93
- export function setTeamSeeInvisible(name: string, canSee: boolean): Promise<void> {
94
- return post('scoreboard.setTeamSeeInvisible', { name, canSee });
107
+ export function setTeamSeeInvisible(name: string, canSee: boolean, board?: string): Promise<void> {
108
+ return post('scoreboard.setTeamSeeInvisible', { name, canSee, ...boardParam(board) });
95
109
  }
96
110
 
97
- export function setTeamOption(name: string, option: string, value: string): Promise<void> {
98
- return post('scoreboard.setTeamOption', { name, option, value });
111
+ export function setTeamOption(name: string, option: string, value: string, board?: string): Promise<void> {
112
+ return post('scoreboard.setTeamOption', { name, option, value, ...boardParam(board) });
99
113
  }
100
114
 
101
- export function teamAddEntry(name: string, entry: string): Promise<void> {
102
- return post('scoreboard.teamAddEntry', { name, entry });
115
+ export function teamAddEntry(name: string, entry: string, board?: string): Promise<void> {
116
+ return post('scoreboard.teamAddEntry', { name, entry, ...boardParam(board) });
103
117
  }
104
118
 
105
- export function teamRemoveEntry(name: string, entry: string): Promise<void> {
106
- return post('scoreboard.teamRemoveEntry', { name, entry });
119
+ export function teamRemoveEntry(name: string, entry: string, board?: string): Promise<void> {
120
+ return post('scoreboard.teamRemoveEntry', { name, entry, ...boardParam(board) });
107
121
  }
108
122
 
109
- export function teamGetEntries(name: string): Promise<string[]> {
110
- return post<string[]>('scoreboard.teamGetEntries', { name });
123
+ export function teamGetEntries(name: string, board?: string): Promise<string[]> {
124
+ return post<string[]>('scoreboard.teamGetEntries', { name, ...boardParam(board) });
111
125
  }
112
126
 
113
- export function setPlayerBoard(uuid: string): Promise<void> {
114
- return post('scoreboard.setPlayerBoard', { uuid });
127
+ export function setPlayerBoard(uuid: string, board?: string): Promise<void> {
128
+ return post('scoreboard.setPlayerBoard', { uuid, ...boardParam(board) });
115
129
  }