hypixel-api-reborn 11.3.3 → 11.3.5

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": "hypixel-api-reborn",
3
- "version": "11.3.3",
3
+ "version": "11.3.5",
4
4
  "description": "Feature-rich Hypixel API wrapper for Node.js",
5
5
  "main": "./src/index.js",
6
6
  "types": "./typings/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "node-fetch": "^3.3.2",
33
33
  "prismarine-nbt": "^2.5.0",
34
34
  "rss-parser": "^3.13.0",
35
- "skyhelper-networth": "^1.22.0"
35
+ "skyhelper-networth": "^1.24.0"
36
36
  },
37
37
  "license": "MIT",
38
38
  "readme": "https://hypixel.stavzdev.me/",
@@ -42,10 +42,10 @@
42
42
  "publisher": "StavZ",
43
43
  "devDependencies": {
44
44
  "@discordjs/docgen": "github:discordjs/docgen",
45
- "@types/node": "^22.1.0",
45
+ "@types/node": "^22.5.0",
46
46
  "chai": "^4.3.4",
47
- "eslint": "^9.8.0",
48
- "eslint-plugin-jsdoc": "^49.0.0",
47
+ "eslint": "^9.9.1",
48
+ "eslint-plugin-jsdoc": "^50.2.2",
49
49
  "globals": "^15.9.0",
50
50
  "mocha": "^10.4.0",
51
51
  "node-env-run": "^4.0.2",
@@ -1,7 +1,11 @@
1
1
  module.exports = async function (profileId) {
2
2
  const SkyblockGarden = require('../../structures/SkyBlock/SkyblockGarden');
3
- // eslint-disable-next-line no-underscore-dangle
4
- const res = await this._makeRequest(`/skyblock/garden?profile=${profileId}`);
5
- if (res.raw) return res;
3
+ let res;
4
+ try {
5
+ // eslint-disable-next-line no-underscore-dangle
6
+ res = await this._makeRequest(`/skyblock/garden?profile=${profileId}`).catch();
7
+ // eslint-disable-next-line no-unused-vars, no-empty
8
+ } catch (e) {}
9
+ if (res?.raw) return res;
6
10
  return new SkyblockGarden(res);
7
11
  };
package/src/index.js CHANGED
@@ -80,7 +80,7 @@ module.exports = {
80
80
  VampireZ: require('./structures/MiniGames/VampireZ.js'),
81
81
  Walls: require('./structures/MiniGames/Walls.js'),
82
82
  Warlords: require('./structures/MiniGames/Warlords.js'),
83
- WoolWars: require('./structures/MiniGames/WoolWars.js'),
83
+ WoolGames: require('./structures/MiniGames/WoolGames.js'),
84
84
 
85
85
  /* Leaderboards */
86
86
  Leaderboard: require('./structures/Leaderboard.js'),
@@ -240,73 +240,6 @@ class BountyHunters {
240
240
  this.swordKills = data.sword_kills_oneinthequiver || 0;
241
241
  }
242
242
  }
243
- /**
244
- * Capture the Wool class
245
- */
246
- class CaptureTheWool {
247
- constructor(data) {
248
- /**
249
- * Wins
250
- * @type {number}
251
- */
252
- this.wins = data.woolhunt_participated_wins || 0;
253
- /**
254
- * Losses
255
- * @type {number}
256
- */
257
- this.losses = data.woolhunt_participated_losses || 0;
258
- /**
259
- * Win Loss ratio
260
- * @type {number}
261
- */
262
- this.WLRatio = divide(this.wins, this.losses);
263
- /**
264
- * Draws
265
- * @type {number}
266
- */
267
- this.draws = data.woolhunt_participated_draws || 0;
268
- /**
269
- * Kills
270
- * @type {number}
271
- */
272
- this.kills = data.woolhunt_kills || 0;
273
- /**
274
- * Deaths
275
- * @type {number}
276
- */
277
- this.deaths = data.woolhunt_deaths || 0;
278
- /**
279
- * Kill Death ratio
280
- * @type {number}
281
- */
282
- this.KDRatio = divide(this.kills, this.deaths);
283
- /**
284
- * assists
285
- * @type {number}
286
- */
287
- this.assists = data.woolhunt_assists || 0;
288
- /**
289
- * woolPickedUp
290
- * @type {number}
291
- */
292
- this.woolPickedUp = data.woolhunt_wools_stolen || 0;
293
- /**
294
- * woolCaptured
295
- * @type {number}
296
- */
297
- this.woolCaptured = data.woolhunt_wools_captured || 0;
298
- /**
299
- * fastestWin (In seconds)
300
- * @type {number}
301
- */
302
- this.fastestWin = data.woolhunt_fastest_win || 0;
303
- /**
304
- * longestGame (In seconds)
305
- * @type {number}
306
- */
307
- this.longestGame = data.woolhunt_longest_game || 0;
308
- }
309
- }
310
243
  /**
311
244
  * Dragon Wars class
312
245
  */
@@ -561,9 +494,9 @@ class GalaxyWars {
561
494
  }
562
495
  }
563
496
  /**
564
- * Party Popper Stats (Sub gamemode of Hide and Seek)
497
+ * Party Pooper Stats (Sub gamemode of Hide and Seek)
565
498
  */
566
- class PartyPopper {
499
+ class PartyPooper {
567
500
  /**
568
501
  * @param {Object} data Data from API
569
502
  */
@@ -619,10 +552,10 @@ class HideAndSeek {
619
552
  */
620
553
  constructor(data) {
621
554
  /**
622
- * Party Popper Stats
623
- * @type {PartyPopper}
555
+ * Party Pooper Stats
556
+ * @type {PartyPooper}
624
557
  */
625
- this.partyPopper = new PartyPopper(data);
558
+ this.partyPooper = new PartyPooper(data);
626
559
  /**
627
560
  * Prop Hunt Stats
628
561
  * @type {PropHunt}
@@ -977,11 +910,6 @@ class Arcade {
977
910
  * @type {BountyHunters}
978
911
  */
979
912
  this.bountyHunters = new BountyHunters(data);
980
- /**
981
- * Capture The Wool
982
- * @type {CaptureTheWool}
983
- */
984
- this.captureTheWool = new CaptureTheWool(data);
985
913
  /**
986
914
  * Dragon wars stats
987
915
  * @type {DragonWars}
@@ -0,0 +1,405 @@
1
+ const { divide } = require('../../utils');
2
+
3
+ class WoolWarsClass {
4
+ /**
5
+ * Constructor
6
+ * @param {Record<string, unknown>} data Data from API
7
+ */
8
+ constructor(data, className) {
9
+ /**
10
+ * Wins
11
+ * @type {number}
12
+ */
13
+ this.wins = data?.[className]?.wins || 0;
14
+ /**
15
+ * Kills
16
+ * @type {number}
17
+ */
18
+ this.kills = data?.[className]?.kills || 0;
19
+ /**
20
+ * Assists
21
+ * @type {number}
22
+ */
23
+ this.assists = data?.[className]?.assists || 0;
24
+ /**
25
+ * Deaths
26
+ * @type {number}
27
+ */
28
+ this.deaths = data?.[className]?.deaths || 0;
29
+ /**
30
+ * KDRatio
31
+ * @type {number}
32
+ */
33
+ this.KDRatio = divide(this.kills, this.deaths);
34
+ /**
35
+ * Games Played
36
+ * @type {number}
37
+ */
38
+ this.gamesPlayed = data?.[className]?.games_played || 0;
39
+ /**
40
+ * Wools Placed
41
+ * @type {number}
42
+ */
43
+ this.woolsPlaced = data?.[className]?.wool_placed || 0;
44
+ /**
45
+ * Blocks Broken
46
+ * @type {number}
47
+ */
48
+ this.blocksBroken = data?.[className]?.blocks_broken || 0;
49
+ /**
50
+ * Place Break Ratio
51
+ * @type {number}
52
+ */
53
+ this.placeBreakRatio = divide(this.woolsPlaced, this.blocksBroken);
54
+ /**
55
+ * Powerups Collected
56
+ * @type {number}
57
+ */
58
+ this.powerups = data?.[className]?.powerups_gotten || 0;
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Wool Wars Class
64
+ */
65
+ class WoolWars {
66
+ /**
67
+ * Constructor
68
+ * @param {Record<string, unknown>} data Data from API
69
+ */
70
+ constructor(data) {
71
+ /**
72
+ * Selected Class
73
+ * @type {'ASSAULT' | 'TANK' | 'GOLEM' | 'SWORDSMAN' | 'ENGINEER' | 'ARCHER' | 'NONE'}
74
+ */
75
+ this.selectedClass = data?.selected_class || 'NONE';
76
+ /**
77
+ * Wins
78
+ * @type {number}
79
+ */
80
+ this.wins = data?.stats?.wins || 0;
81
+ /**
82
+ * Kills
83
+ * @type {number}
84
+ */
85
+ this.kills = data?.stats?.kills || 0;
86
+ /**
87
+ * Assists
88
+ * @type {number}
89
+ */
90
+ this.assists = data?.stats?.assists || 0;
91
+ /**
92
+ * Deaths
93
+ * @type {number}
94
+ */
95
+ this.deaths = data?.stats?.deaths || 0;
96
+ /**
97
+ * KDRatio
98
+ * @type {number}
99
+ */
100
+ this.KDRatio = divide(this.kills, this.deaths);
101
+ /**
102
+ * Games Played
103
+ * @type {number}
104
+ */
105
+ this.gamesPlayed = data?.stats?.games_played || 0;
106
+ /**
107
+ * Wools Placed
108
+ * @type {number}
109
+ */
110
+ this.woolsPlaced = data?.stats?.wool_placed || 0;
111
+ /**
112
+ * Blocks Broken
113
+ * @type {number}
114
+ */
115
+ this.blocksBroken = data?.stats?.blocks_broken || 0;
116
+ /**
117
+ * Place Break Ratio
118
+ * @type {number}
119
+ */
120
+ this.placeBreakRatio = divide(this.woolsPlaced, this.blocksBroken);
121
+ /**
122
+ * powerups
123
+ * @type {number}
124
+ */
125
+ this.powerups = data?.powerups_gotten || 0;
126
+ /**
127
+ * Assault Class Stats
128
+ * @type {WoolWarsClass}
129
+ */
130
+ this.assault = new WoolWarsClass(data?.stats?.classes, 'assault');
131
+ /**
132
+ * Tank Class Stats
133
+ * @type {WoolWarsClass}
134
+ */
135
+ this.tank = new WoolWarsClass(data?.stats?.classes, 'tank');
136
+ /**
137
+ * Golem Class Stats
138
+ * @type {WoolWarsClass}
139
+ */
140
+ this.golem = new WoolWarsClass(data?.stats?.classes, 'golem');
141
+ /**
142
+ * Swordsman Class Stats
143
+ * @type {WoolWarsClass}
144
+ */
145
+ this.swordsman = new WoolWarsClass(data?.stats?.classes, 'swordsman');
146
+ /**
147
+ * Engineer Class Stats
148
+ * @type {WoolWarsClass}
149
+ */
150
+ this.engineer = new WoolWarsClass(data?.stats?.classes, 'engineer');
151
+ /**
152
+ * Archer Class Stats
153
+ * @type {WoolWarsClass}
154
+ */
155
+ this.archer = new WoolWarsClass(data?.stats?.classes, 'archer');
156
+ }
157
+ }
158
+ /**
159
+ * Capture The Wool Stats Class
160
+ */
161
+ class CaptureTheWool {
162
+ /**
163
+ * Constructor
164
+ * @param {Record<string, unknown>} data Data from API
165
+ */
166
+ constructor(data) {
167
+ /**
168
+ * kills
169
+ * @type {number}
170
+ */
171
+ this.kills = data?.stats?.kills || 0;
172
+ /**
173
+ * Assists
174
+ * @type {number}
175
+ */
176
+ this.assists = data?.stats?.assists || 0;
177
+ /**
178
+ * Deaths
179
+ * @type {number}
180
+ */
181
+ this.deaths = data?.stats?.deaths || 0;
182
+ /**
183
+ * KDRatio
184
+ * @type {number}
185
+ */
186
+ this.KDRatio = divide(this.kills, this.deaths);
187
+ /**
188
+ * Kills With Wool
189
+ * @type {number}
190
+ */
191
+ this.killsWithWool = data?.stats?.kills_with_wool || 0;
192
+ /**
193
+ * Deaths With Wool
194
+ * @type {number}
195
+ */
196
+ this.deathsWithWool = data?.stats?.deaths_with_wool || 0;
197
+ /**
198
+ * KDRatio With Wool
199
+ * @type {number}
200
+ */
201
+ this.KDRatioWithWool = divide(this.killsWithWool, this.deathsWithWool);
202
+ /**
203
+ * Wool Captured
204
+ * @type {number}
205
+ */
206
+ this.woolCaptured = data?.stats?.wools_captured || 0;
207
+ /**
208
+ * Wool Stolen
209
+ * @type {number}
210
+ */
211
+ this.woolStolen = data?.stats?.wools_stolen || 0;
212
+ /**
213
+ * Wool Capture Stolen Ratio
214
+ * @type {number}
215
+ */
216
+ this.woolCaptureStolenRatio = divide(this.woolCaptured, this.woolStolen);
217
+ }
218
+ }
219
+ /**
220
+ * Sheep Wars Stats Class
221
+ */
222
+ class SheepWars {
223
+ /**
224
+ * Constructor
225
+ * @param {Record<string, unknown>} data Data from API
226
+ */
227
+ constructor(data) {
228
+ /**
229
+ * Wins
230
+ * @type {number}
231
+ */
232
+ this.wins = data?.stats?.wins || 0;
233
+ /**
234
+ * Kills
235
+ * @type {number}
236
+ */
237
+ this.kills = data?.stats?.kills || 0;
238
+ /**
239
+ * Kills Void
240
+ * @type {number}
241
+ */
242
+ this.killsVoid = data?.stats?.kills_void || 0;
243
+ /**
244
+ K kills Bow
245
+ * @type {number}
246
+ */
247
+ this.killsBow = data?.stats?.kills_bow || 0;
248
+ /**
249
+ * Kills Explosive
250
+ * @type {number}
251
+ */
252
+ this.killsExplosive = data?.stats?.kills_explosive || 0;
253
+ /**
254
+ * Deaths
255
+ * @type {number}
256
+ */
257
+ this.deaths = data?.stats?.deaths || 0;
258
+ /**
259
+ * Deaths Void
260
+ * @type {number}
261
+ */
262
+ this.deathsVoid = data?.stats?.deaths_void || 0;
263
+ /**
264
+ * Deaths Melee
265
+ * @type {number}
266
+ */
267
+ this.deathsMelee = data?.stats?.deaths_melee || 0;
268
+ /**
269
+ * Deaths Explosive
270
+ * @type {number}
271
+ */
272
+ this.deathsExplosive = data?.stats?.deaths_explosive || 0;
273
+ /**
274
+ * KDRatio
275
+ * @type {number}
276
+ */
277
+ this.KDRatio = divide(this.wins, this.deaths);
278
+ /**
279
+ * Losses
280
+ * @type {number}
281
+ */
282
+ this.losses = data?.stats?.losses || 0;
283
+ /**
284
+ * WLRatio
285
+ * @type {number}
286
+ */
287
+ this.WLRatio = divide(this.wins, this.losses);
288
+ /**
289
+ * Games Played
290
+ * @type {number}
291
+ */
292
+ this.gamesPlayed = data?.stats?.games_played || 0;
293
+ /**
294
+ * Damage Dealt
295
+ * @type {number}
296
+ */
297
+ this.damageDealt = data?.stats?.damage_dealt || 0;
298
+ /**
299
+ * Sheep Thrown
300
+ * @type {number}
301
+ */
302
+ this.sheepThrown = data?.stats?.sheep_thrown || 0;
303
+ /**
304
+ * Magic Wool Hit
305
+ * @type {number}
306
+ */
307
+ this.magicWoolHit = data?.stats?.magic_wool_hit || 0;
308
+ }
309
+ }
310
+
311
+ /**
312
+ * WoolGames Stats
313
+ */
314
+ class WoolGames {
315
+ /**
316
+ * Constructor
317
+ * @param {Record<string, unknown>} data Data from API
318
+ */
319
+ constructor(data) {
320
+ /**
321
+ * Layers
322
+ * @type {number}
323
+ */
324
+ this.layers = data?.progression?.available_layers || 0;
325
+ /**
326
+ * XP
327
+ * @type {number}
328
+ */
329
+ this.xp = data?.progression?.experience || 0;
330
+ /**
331
+ * Exact Level
332
+ * @type {number}
333
+ */
334
+ this.exactLevel = this.convertXPToLevel(this.xp);
335
+ /**
336
+ * Level
337
+ * @type {number}
338
+ */
339
+ this.level = Math?.floor(this.exactLevel);
340
+ /**
341
+ * Coins
342
+ * @type {number}
343
+ */
344
+ this.coins = data?.coins || 0;
345
+ /**
346
+ * Owned Cosmetics
347
+ * @type {string[]}
348
+ */
349
+ this.ownedCosmetics = data?.packages || [];
350
+ /**
351
+ * Private Games Config
352
+ * @type {WoolGamesPrivateGamesConfig}
353
+ */
354
+ this.privateGamesConfig = data?.privategames || {};
355
+ /**
356
+ * Playtime
357
+ * @type {number}
358
+ */
359
+ this.playtime = data?.playtime || 0;
360
+ /**
361
+ * Wool Wars
362
+ * @type {WoolWars}
363
+ */
364
+ this.woolWars = new WoolWars(data?.wool_wars);
365
+ /**
366
+ * Capture The Wool
367
+ * @type {CaptureTheWool}
368
+ */
369
+ this.captureTheWool = new CaptureTheWool(data?.capture_the_wool);
370
+ /**
371
+ * Sheep Wars
372
+ * @type {SheepWars}
373
+ */
374
+ this.sheepWars = new SheepWars(data?.sheep_wars);
375
+ }
376
+
377
+ /**
378
+ * Converts XP to Level
379
+ * @param {number} exp xp
380
+ * @return {number}
381
+ */
382
+ convertXPToLevel(exp) {
383
+ const minimalExp = [0, 1e3, 3e3, 6e3, 1e4, 15e3];
384
+ const baseLevel = minimalExp.length;
385
+ const baseExp = minimalExp[minimalExp.length - 1];
386
+ const expToLevel100 = 49e4;
387
+ if (exp < baseExp) return minimalExp.findIndex((x) => exp < x);
388
+ const theoreticalLevel = (exp - baseExp) / 5e3 + baseLevel;
389
+ if (100 < theoreticalLevel) return 100 + this.convertXPToLevel(exp - expToLevel100);
390
+ return theoreticalLevel;
391
+ }
392
+ }
393
+
394
+ /**
395
+ * @typedef {object} WoolGamesPrivateGamesConfig
396
+ * @property {boolean} one_hit_one_kill one hit one kill
397
+ * @property {'Enabled' | 'Disabled'} rainbow_wool rainbow wool
398
+ * @property {string} health_buff health buff
399
+ * @property {string} game_speed game speed
400
+ * @property {string} speed speed
401
+ * @property {'Enabled' | 'Disabled'} no_class no class
402
+ * @property {boolean} respawn_enable respawn enable
403
+ */
404
+
405
+ module.exports = WoolGames;
@@ -29,7 +29,7 @@ const Paintball = require('./MiniGames/Paintball');
29
29
  const Quakecraft = require('./MiniGames/Quakecraft');
30
30
  const Walls = require('./MiniGames/Walls');
31
31
  const Warlords = require('./MiniGames/Warlords');
32
- const WoolWars = require('./MiniGames/WoolWars');
32
+ const WoolGames = require('./MiniGames/WoolGames');
33
33
  const Pit = require('./MiniGames/Pit');
34
34
  const Guild = require('./Guild/Guild');
35
35
  const RecentGame = require('./RecentGame');
@@ -240,7 +240,7 @@ class Player {
240
240
  vampirez: data.stats.VampireZ ? new VampireZ(data.stats.VampireZ) : null,
241
241
  walls: data.stats.Walls ? new Walls(data.stats.Walls) : null,
242
242
  warlords: data.stats.Battleground ? new Warlords(data.stats.Battleground) : null,
243
- woolwars: data.stats.WoolGames ? new WoolWars(data.stats.WoolGames) : null
243
+ woolgames: data.stats.WoolGames ? new WoolGames(data.stats.WoolGames) : null
244
244
  }
245
245
  : null;
246
246
  /**
@@ -325,7 +325,7 @@ class Player {
325
325
  * @property {VampireZ|null} vampirez VampireZ
326
326
  * @property {Walls|null} walls Walls
327
327
  * @property {Warlords|null} warlords Warlords
328
- * @property {WoolWars|null} woolwars Wool Wars
328
+ * @property {WoolGames|null} woolgames Wool Games
329
329
  */
330
330
  /**
331
331
  * @typedef {Object} RanksPurchaseTime