specprotocol 1.4.0 → 1.4.3

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.
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Inventory Manager (Core)
3
+ *
4
+ * Tracks the player's inventory: 36 main slots (0-35 = hotbar 0-8 + main 9-35),
5
+ * armor slots (36-39), off-hand (40), and open container slots.
6
+ */
7
+ import { TypedEventEmitter } from './utils/events.js';
8
+ import { BufferReader } from './protocol/types.js';
9
+ export interface ItemStack {
10
+ /** Item count (0 = empty) */
11
+ count: number;
12
+ /** Item ID (registry ID) */
13
+ itemId: number;
14
+ /** Additional components count */
15
+ addComponentsCount: number;
16
+ /** Removed components count */
17
+ removeComponentsCount: number;
18
+ /** Raw component data */
19
+ rawData: Buffer;
20
+ }
21
+ export interface InventoryEvents {
22
+ 'slotUpdate': (slot: number, item: ItemStack | null, windowId: number) => void;
23
+ 'inventoryUpdate': (windowId: number) => void;
24
+ 'heldItemChange': (slot: number) => void;
25
+ }
26
+ export declare class Inventory extends TypedEventEmitter<InventoryEvents> {
27
+ /** Player inventory slots: 0-8 hotbar, 9-35 main, 36-39 armor, 40 off-hand, 41-45 crafting */
28
+ private slots;
29
+ /** Currently open container slots */
30
+ private containerSlots;
31
+ /** Current held hotbar slot (0-8) */
32
+ private _selectedSlot;
33
+ /** Current open window ID */
34
+ private _windowId;
35
+ /** State ID for click container packets */
36
+ private _stateId;
37
+ /** Carried item (cursor item) */
38
+ private _carriedItem;
39
+ constructor();
40
+ /** Currently selected hotbar slot (0-8) */
41
+ get selectedSlot(): number;
42
+ set selectedSlot(slot: number);
43
+ /** Current open window ID */
44
+ get windowId(): number;
45
+ /** State ID for container operations */
46
+ get stateId(): number;
47
+ /** Item currently on cursor */
48
+ get carriedItem(): ItemStack | null;
49
+ /** Get item in a player inventory slot (0-45) */
50
+ getSlot(slot: number): ItemStack | null;
51
+ /** Get item in currently held hotbar slot */
52
+ get heldItem(): ItemStack | null;
53
+ /** Get hotbar items (slots 0-8) */
54
+ get hotbar(): (ItemStack | null)[];
55
+ /** Get main inventory items (slots 9-35) */
56
+ get main(): (ItemStack | null)[];
57
+ /** Get armor slots: [helmet, chestplate, leggings, boots] */
58
+ get armor(): (ItemStack | null)[];
59
+ /** Get off-hand item (slot 40) */
60
+ get offHand(): ItemStack | null;
61
+ /** Get helmet (slot 36) */
62
+ get helmet(): ItemStack | null;
63
+ /** Get chestplate (slot 37) */
64
+ get chestplate(): ItemStack | null;
65
+ /** Get leggings (slot 38) */
66
+ get leggings(): ItemStack | null;
67
+ /** Get boots (slot 39) */
68
+ get boots(): ItemStack | null;
69
+ /** Get all non-null items */
70
+ get items(): ItemStack[];
71
+ /** Count of non-empty slots */
72
+ get usedSlots(): number;
73
+ /** Count of empty slots in main inventory (9-35) + hotbar (0-8) */
74
+ get emptySlots(): number;
75
+ /** Find first slot with matching item ID */
76
+ findItem(itemId: number): number;
77
+ /** Find all slots with matching item ID */
78
+ findAllItems(itemId: number): number[];
79
+ /** Count total items of a given ID across all slots */
80
+ countItem(itemId: number): number;
81
+ /** Get item in container slot */
82
+ getContainerSlot(slot: number): ItemStack | null;
83
+ /** Get all container slots */
84
+ get container(): (ItemStack | null)[];
85
+ /** Set a single slot (from server packet) */
86
+ setSlot(windowId: number, slot: number, item: ItemStack | null, stateId?: number): void;
87
+ /** Set all container contents (from server packet) */
88
+ setContainerContent(windowId: number, items: (ItemStack | null)[], stateId: number, carriedItem: ItemStack | null): void;
89
+ /** Open a new container window */
90
+ openWindow(windowId: number, slotCount: number): void;
91
+ /** Close current container */
92
+ closeWindow(): void;
93
+ /** Clear all inventory data */
94
+ clear(): void;
95
+ /** Parse an item stack from buffer data */
96
+ static parseItem(reader: BufferReader): ItemStack | null;
97
+ }
98
+ //# sourceMappingURL=inventory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inventory.d.ts","sourceRoot":"","sources":["../src/inventory.ts"],"names":[],"mappings":"AAAA;;;;;G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GAAG,IAAI,CAAC,EAAE,CAEpC;IAID,6CAA6C;IAC7C,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAkBvF,sDAAsD;IACtD,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAiBxH,kCAAkC;IAClC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKrD,8BAA8B;IAC9B,WAAW,IAAI,IAAI;IAKnB,+BAA+B;IAC/B,KAAK,IAAI,IAAI;IAWb,2CAA2C;IAC3C,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI;CAmB3D"}
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ /**
3
+ * Inventory Manager (Core)
4
+ *
5
+ * Tracks the player's inventory: 36 main slots (0-35 = hotbar 0-8 + main 9-35),
6
+ * armor slots (36-39), off-hand (40), and open container slots.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Inventory = void 0;
10
+ const events_js_1 = require("./utils/events.js");
11
+ class Inventory extends events_js_1.TypedEventEmitter {
12
+ /** Player inventory slots: 0-8 hotbar, 9-35 main, 36-39 armor, 40 off-hand, 41-45 crafting */
13
+ slots = new Array(46).fill(null);
14
+ /** Currently open container slots */
15
+ containerSlots = [];
16
+ /** Current held hotbar slot (0-8) */
17
+ _selectedSlot = 0;
18
+ /** Current open window ID */
19
+ _windowId = 0;
20
+ /** State ID for click container packets */
21
+ _stateId = 0;
22
+ /** Carried item (cursor item) */
23
+ _carriedItem = null;
24
+ constructor() {
25
+ super();
26
+ }
27
+ // ─── Getters ────────────────────────────
28
+ /** Currently selected hotbar slot (0-8) */
29
+ get selectedSlot() { return this._selectedSlot; }
30
+ set selectedSlot(slot) {
31
+ this._selectedSlot = slot;
32
+ this.emit('heldItemChange', slot);
33
+ }
34
+ /** Current open window ID */
35
+ get windowId() { return this._windowId; }
36
+ /** State ID for container operations */
37
+ get stateId() { return this._stateId; }
38
+ /** Item currently on cursor */
39
+ get carriedItem() { return this._carriedItem; }
40
+ // ─── Slot Access ────────────────────────
41
+ /** Get item in a player inventory slot (0-45) */
42
+ getSlot(slot) {
43
+ if (slot < 0 || slot >= this.slots.length)
44
+ return null;
45
+ return this.slots[slot] ?? null;
46
+ }
47
+ /** Get item in currently held hotbar slot */
48
+ get heldItem() {
49
+ return this.getSlot(this._selectedSlot);
50
+ }
51
+ /** Get hotbar items (slots 0-8) */
52
+ get hotbar() {
53
+ return this.slots.slice(0, 9);
54
+ }
55
+ /** Get main inventory items (slots 9-35) */
56
+ get main() {
57
+ return this.slots.slice(9, 36);
58
+ }
59
+ /** Get armor slots: [helmet, chestplate, leggings, boots] */
60
+ get armor() {
61
+ return this.slots.slice(36, 40);
62
+ }
63
+ /** Get off-hand item (slot 40) */
64
+ get offHand() {
65
+ return this.slots[40] ?? null;
66
+ }
67
+ /** Get helmet (slot 36) */
68
+ get helmet() { return this.slots[36] ?? null; }
69
+ /** Get chestplate (slot 37) */
70
+ get chestplate() { return this.slots[37] ?? null; }
71
+ /** Get leggings (slot 38) */
72
+ get leggings() { return this.slots[38] ?? null; }
73
+ /** Get boots (slot 39) */
74
+ get boots() { return this.slots[39] ?? null; }
75
+ /** Get all non-null items */
76
+ get items() {
77
+ return this.slots.filter(Boolean);
78
+ }
79
+ /** Count of non-empty slots */
80
+ get usedSlots() {
81
+ return this.items.length;
82
+ }
83
+ /** Count of empty slots in main inventory (9-35) + hotbar (0-8) */
84
+ get emptySlots() {
85
+ let count = 0;
86
+ for (let i = 0; i < 36; i++) {
87
+ if (!this.slots[i])
88
+ count++;
89
+ }
90
+ return count;
91
+ }
92
+ /** Find first slot with matching item ID */
93
+ findItem(itemId) {
94
+ for (let i = 0; i < this.slots.length; i++) {
95
+ if (this.slots[i]?.itemId === itemId)
96
+ return i;
97
+ }
98
+ return -1;
99
+ }
100
+ /** Find all slots with matching item ID */
101
+ findAllItems(itemId) {
102
+ const result = [];
103
+ for (let i = 0; i < this.slots.length; i++) {
104
+ if (this.slots[i]?.itemId === itemId)
105
+ result.push(i);
106
+ }
107
+ return result;
108
+ }
109
+ /** Count total items of a given ID across all slots */
110
+ countItem(itemId) {
111
+ let count = 0;
112
+ for (const slot of this.slots) {
113
+ if (slot?.itemId === itemId)
114
+ count += slot.count;
115
+ }
116
+ return count;
117
+ }
118
+ // ─── Container Slots ────────────────────
119
+ /** Get item in container slot */
120
+ getContainerSlot(slot) {
121
+ if (slot < 0 || slot >= this.containerSlots.length)
122
+ return null;
123
+ return this.containerSlots[slot] ?? null;
124
+ }
125
+ /** Get all container slots */
126
+ get container() {
127
+ return this.containerSlots;
128
+ }
129
+ // ─── Updates ────────────────────────────
130
+ /** Set a single slot (from server packet) */
131
+ setSlot(windowId, slot, item, stateId) {
132
+ if (stateId !== undefined)
133
+ this._stateId = stateId;
134
+ if (windowId === 0 || windowId === -1) {
135
+ // Player inventory
136
+ if (slot >= 0 && slot < this.slots.length) {
137
+ this.slots[slot] = item;
138
+ this.emit('slotUpdate', slot, item, windowId);
139
+ }
140
+ }
141
+ else {
142
+ // Container
143
+ if (slot >= 0 && slot < this.containerSlots.length) {
144
+ this.containerSlots[slot] = item;
145
+ this.emit('slotUpdate', slot, item, windowId);
146
+ }
147
+ }
148
+ }
149
+ /** Set all container contents (from server packet) */
150
+ setContainerContent(windowId, items, stateId, carriedItem) {
151
+ this._windowId = windowId;
152
+ this._stateId = stateId;
153
+ this._carriedItem = carriedItem;
154
+ if (windowId === 0) {
155
+ // Player inventory update
156
+ for (let i = 0; i < Math.min(items.length, this.slots.length); i++) {
157
+ this.slots[i] = items[i] ?? null;
158
+ }
159
+ }
160
+ else {
161
+ // Container
162
+ this.containerSlots = items;
163
+ }
164
+ this.emit('inventoryUpdate', windowId);
165
+ }
166
+ /** Open a new container window */
167
+ openWindow(windowId, slotCount) {
168
+ this._windowId = windowId;
169
+ this.containerSlots = new Array(slotCount).fill(null);
170
+ }
171
+ /** Close current container */
172
+ closeWindow() {
173
+ this._windowId = 0;
174
+ this.containerSlots = [];
175
+ }
176
+ /** Clear all inventory data */
177
+ clear() {
178
+ this.slots.fill(null);
179
+ this.containerSlots = [];
180
+ this._selectedSlot = 0;
181
+ this._windowId = 0;
182
+ this._stateId = 0;
183
+ this._carriedItem = null;
184
+ }
185
+ // ─── Item Parsing ───────────────────────
186
+ /** Parse an item stack from buffer data */
187
+ static parseItem(reader) {
188
+ const count = reader.readVarInt();
189
+ if (count <= 0)
190
+ return null;
191
+ const itemId = reader.readVarInt();
192
+ const addComponentsCount = reader.readVarInt();
193
+ const removeComponentsCount = reader.readVarInt();
194
+ // Skip component data for now (complex NBT-like structure)
195
+ const rawData = reader.readBytes(reader.remaining);
196
+ return {
197
+ count,
198
+ itemId,
199
+ addComponentsCount,
200
+ removeComponentsCount,
201
+ rawData,
202
+ };
203
+ }
204
+ }
205
+ exports.Inventory = Inventory;
206
+ //# sourceMappingURL=inventory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inventory.js","sourceRoot":"","sources":["../src/inventory.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,iDAAsD;AAsBtD,MAAa,SAAU,SAAQ,6BAAkC;IAC7D,8FAA8F;IACtF,KAAK,GAAyB,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,qCAAqC;IAC7B,cAAc,GAAyB,EAAE,CAAC;IAClD,qCAAqC;IAC7B,aAAa,GAAW,CAAC,CAAC;IAClC,6BAA6B;IACrB,SAAS,GAAW,CAAC,CAAC;IAC9B,2CAA2C;IACnC,QAAQ,GAAW,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,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEnD,OAAO;YACH,KAAK;YACL,MAAM;YACN,kBAAkB;YAClB,qBAAqB;YACrB,OAAO;SACV,CAAC;IACN,CAAC;CACJ;AA3ND,8BA2NC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Scoreboard Manager
3
+ *
4
+ * Tracks scoreboard objectives, scores, teams, and display slots.
5
+ */
6
+ import { TypedEventEmitter } from './utils/events.js';
7
+ export interface ScoreboardObjective {
8
+ name: string;
9
+ displayName: string;
10
+ renderType: number;
11
+ }
12
+ export interface ScoreboardScore {
13
+ entityName: string;
14
+ objectiveName: string;
15
+ value: number;
16
+ displayName?: string;
17
+ numberFormat?: number;
18
+ }
19
+ export interface ScoreboardTeam {
20
+ name: string;
21
+ displayName: string;
22
+ prefix: string;
23
+ suffix: string;
24
+ friendlyFire: boolean;
25
+ nameTagVisibility: string;
26
+ collisionRule: string;
27
+ color: number;
28
+ members: Set<string>;
29
+ }
30
+ export interface ScoreboardEvents {
31
+ 'objectiveAdd': (objective: ScoreboardObjective) => void;
32
+ 'objectiveRemove': (name: string) => void;
33
+ 'scoreSet': (score: ScoreboardScore) => void;
34
+ 'scoreRemove': (entityName: string, objectiveName: string) => void;
35
+ 'teamAdd': (team: ScoreboardTeam) => void;
36
+ 'teamRemove': (name: string) => void;
37
+ 'teamUpdate': (team: ScoreboardTeam) => void;
38
+ }
39
+ export declare class Scoreboard extends TypedEventEmitter<ScoreboardEvents> {
40
+ private objectives;
41
+ private scores;
42
+ private teams;
43
+ private displaySlots;
44
+ constructor();
45
+ addObjective(name: string, displayName: string, renderType?: number): void;
46
+ removeObjective(name: string): void;
47
+ getObjective(name: string): ScoreboardObjective | undefined;
48
+ getAllObjectives(): ScoreboardObjective[];
49
+ setDisplaySlot(slot: number, objectiveName: string): void;
50
+ getDisplaySlot(slot: number): string | undefined;
51
+ /** Get sidebar objective (slot 1) */
52
+ get sidebar(): ScoreboardObjective | undefined;
53
+ setScore(entityName: string, objectiveName: string, value: number, displayName?: string): void;
54
+ removeScore(entityName: string, objectiveName: string): void;
55
+ getScores(objectiveName: string): ScoreboardScore[];
56
+ getScore(entityName: string, objectiveName: string): number | undefined;
57
+ addTeam(name: string, displayName?: string): ScoreboardTeam;
58
+ removeTeam(name: string): void;
59
+ getTeam(name: string): ScoreboardTeam | undefined;
60
+ getTeamByMember(memberName: string): ScoreboardTeam | undefined;
61
+ getAllTeams(): ScoreboardTeam[];
62
+ addTeamMembers(teamName: string, members: string[]): void;
63
+ removeTeamMembers(teamName: string, members: string[]): void;
64
+ clear(): void;
65
+ }
66
+ //# sourceMappingURL=scoreboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoreboard.d.ts","sourceRoot":"","sources":["../src/scoreboard.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB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,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IAU5D,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,eAAe,EAAE;IAUnD,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOvE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,GAAE,MAAa,GAAG,cAAc;IAiBjE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK9B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIjD,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAO/D,WAAW,IAAI,cAAc,EAAE;IAI/B,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAOzD,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAS5D,KAAK,IAAI,IAAI;CAMhB"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ /**
3
+ * Scoreboard Manager
4
+ *
5
+ * Tracks scoreboard objectives, scores, teams, and display slots.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Scoreboard = void 0;
9
+ const events_js_1 = require("./utils/events.js");
10
+ class Scoreboard extends events_js_1.TypedEventEmitter {
11
+ objectives = new Map();
12
+ scores = new Map();
13
+ teams = new Map();
14
+ displaySlots = new Map(); // slot → objective name
15
+ constructor() {
16
+ super();
17
+ }
18
+ // ─── Objectives ─────────────────────────
19
+ addObjective(name, displayName, renderType = 0) {
20
+ const obj = { name, displayName, renderType };
21
+ this.objectives.set(name, obj);
22
+ this.emit('objectiveAdd', obj);
23
+ }
24
+ removeObjective(name) {
25
+ this.objectives.delete(name);
26
+ // Remove all scores for this objective
27
+ for (const [entity, entityScores] of this.scores) {
28
+ const filtered = entityScores.filter(s => s.objectiveName !== name);
29
+ if (filtered.length === 0)
30
+ this.scores.delete(entity);
31
+ else
32
+ this.scores.set(entity, filtered);
33
+ }
34
+ this.emit('objectiveRemove', name);
35
+ }
36
+ getObjective(name) {
37
+ return this.objectives.get(name);
38
+ }
39
+ getAllObjectives() {
40
+ return Array.from(this.objectives.values());
41
+ }
42
+ // ─── Display Slots ──────────────────────
43
+ setDisplaySlot(slot, objectiveName) {
44
+ this.displaySlots.set(slot, objectiveName);
45
+ }
46
+ getDisplaySlot(slot) {
47
+ return this.displaySlots.get(slot);
48
+ }
49
+ /** Get sidebar objective (slot 1) */
50
+ get sidebar() {
51
+ const name = this.displaySlots.get(1);
52
+ return name ? this.objectives.get(name) : undefined;
53
+ }
54
+ // ─── Scores ─────────────────────────────
55
+ setScore(entityName, objectiveName, value, displayName) {
56
+ const score = { entityName, objectiveName, value, displayName };
57
+ let entityScores = this.scores.get(entityName);
58
+ if (!entityScores) {
59
+ entityScores = [];
60
+ this.scores.set(entityName, entityScores);
61
+ }
62
+ const idx = entityScores.findIndex(s => s.objectiveName === objectiveName);
63
+ if (idx >= 0)
64
+ entityScores[idx] = score;
65
+ else
66
+ entityScores.push(score);
67
+ this.emit('scoreSet', score);
68
+ }
69
+ removeScore(entityName, objectiveName) {
70
+ const entityScores = this.scores.get(entityName);
71
+ if (entityScores) {
72
+ const idx = entityScores.findIndex(s => s.objectiveName === objectiveName);
73
+ if (idx >= 0)
74
+ entityScores.splice(idx, 1);
75
+ if (entityScores.length === 0)
76
+ this.scores.delete(entityName);
77
+ }
78
+ this.emit('scoreRemove', entityName, objectiveName);
79
+ }
80
+ getScores(objectiveName) {
81
+ const result = [];
82
+ for (const scores of this.scores.values()) {
83
+ for (const score of scores) {
84
+ if (score.objectiveName === objectiveName)
85
+ result.push(score);
86
+ }
87
+ }
88
+ return result.sort((a, b) => b.value - a.value);
89
+ }
90
+ getScore(entityName, objectiveName) {
91
+ const scores = this.scores.get(entityName);
92
+ return scores?.find(s => s.objectiveName === objectiveName)?.value;
93
+ }
94
+ // ─── Teams ──────────────────────────────
95
+ addTeam(name, displayName = name) {
96
+ const team = {
97
+ name,
98
+ displayName,
99
+ prefix: '',
100
+ suffix: '',
101
+ friendlyFire: true,
102
+ nameTagVisibility: 'always',
103
+ collisionRule: 'always',
104
+ color: 15, // white
105
+ members: new Set(),
106
+ };
107
+ this.teams.set(name, team);
108
+ this.emit('teamAdd', team);
109
+ return team;
110
+ }
111
+ removeTeam(name) {
112
+ this.teams.delete(name);
113
+ this.emit('teamRemove', name);
114
+ }
115
+ getTeam(name) {
116
+ return this.teams.get(name);
117
+ }
118
+ getTeamByMember(memberName) {
119
+ for (const team of this.teams.values()) {
120
+ if (team.members.has(memberName))
121
+ return team;
122
+ }
123
+ return undefined;
124
+ }
125
+ getAllTeams() {
126
+ return Array.from(this.teams.values());
127
+ }
128
+ addTeamMembers(teamName, members) {
129
+ const team = this.teams.get(teamName);
130
+ if (!team)
131
+ return;
132
+ for (const m of members)
133
+ team.members.add(m);
134
+ this.emit('teamUpdate', team);
135
+ }
136
+ removeTeamMembers(teamName, members) {
137
+ const team = this.teams.get(teamName);
138
+ if (!team)
139
+ return;
140
+ for (const m of members)
141
+ team.members.delete(m);
142
+ this.emit('teamUpdate', team);
143
+ }
144
+ // ─── Clear ──────────────────────────────
145
+ clear() {
146
+ this.objectives.clear();
147
+ this.scores.clear();
148
+ this.teams.clear();
149
+ this.displaySlots.clear();
150
+ }
151
+ }
152
+ exports.Scoreboard = Scoreboard;
153
+ //# sourceMappingURL=scoreboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoreboard.js","sourceRoot":"","sources":["../src/scoreboard.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,iDAAsD;AAsCtD,MAAa,UAAW,SAAQ,6BAAmC;IACvD,UAAU,GAAG,IAAI,GAAG,EAA+B,CAAC;IACpD,MAAM,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC9C,KAAK,G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AAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,QAAgB,EAAE,OAAiB;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,KAAK,MAAM,CAAC,IAAI,OAAO;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,2CAA2C;IAE3C,KAAK;QACD,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACJ;AA1JD,gCA0JC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Tab List / Player List Manager
3
+ *
4
+ * Tracks all players on the server with their info:
5
+ * username, UUID, gamemode, ping, display name, skin textures.
6
+ */
7
+ import { TypedEventEmitter } from './utils/events.js';
8
+ export interface TabListPlayer {
9
+ uuid: string;
10
+ username: string;
11
+ displayName?: string;
12
+ gameMode: number;
13
+ ping: number;
14
+ listed: boolean;
15
+ properties: Array<{
16
+ name: string;
17
+ value: string;
18
+ signature?: string;
19
+ }>;
20
+ }
21
+ export interface TabListEvents {
22
+ 'playerJoin': (player: TabListPlayer) => void;
23
+ 'playerLeave': (player: TabListPlayer) => void;
24
+ 'playerUpdate': (player: TabListPlayer) => void;
25
+ }
26
+ export declare class TabList extends TypedEventEmitter<TabListEvents> {
27
+ private players;
28
+ private _header;
29
+ private _footer;
30
+ constructor();
31
+ /** Get header text */
32
+ get header(): string;
33
+ set header(value: string);
34
+ /** Get footer text */
35
+ get footer(): string;
36
+ set footer(value: string);
37
+ /** Get a player by UUID */
38
+ getPlayer(uuid: string): TabListPlayer | undefined;
39
+ /** Get a player by username */
40
+ getPlayerByName(username: string): TabListPlayer | undefined;
41
+ /** Get all players */
42
+ getAll(): TabListPlayer[];
43
+ /** Get all listed (visible) players */
44
+ getListed(): TabListPlayer[];
45
+ /** Number of players */
46
+ get count(): number;
47
+ /** Add or update a player */
48
+ addPlayer(uuid: string, data: Partial<TabListPlayer>): void;
49
+ /** Update player info */
50
+ updatePlayer(uuid: string, data: Partial<TabListPlayer>): void;
51
+ /** Remove a player */
52
+ removePlayer(uuid: string): void;
53
+ /** Clear all players */
54
+ clear(): void;
55
+ }
56
+ //# sourceMappingURL=tablist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tablist.d.ts","sourceRoot":"","sources":["../src/tablist.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,aAAa;IAC1B,YAAY,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,aAAa,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,cAAc,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CACnD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