hypixel-api-reborn 11.1.0 → 11.2.1

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.
Files changed (113) hide show
  1. package/.prettierrc +3 -3
  2. package/README.md +6 -4
  3. package/eslint.config.mjs +71 -0
  4. package/package.json +21 -25
  5. package/src/API/getAchievements.js +7 -0
  6. package/src/API/getBoosters.js +1 -0
  7. package/src/API/getChallenges.js +7 -0
  8. package/src/API/getGameCounts.js +1 -0
  9. package/src/API/getGuild.js +5 -4
  10. package/src/API/getGuildAchievements.js +7 -0
  11. package/src/API/getLeaderboards.js +4 -2
  12. package/src/API/getPlayer.js +2 -1
  13. package/src/API/getQuests.js +7 -0
  14. package/src/API/getRecentGames.js +6 -10
  15. package/src/API/getServerInfo.js +42 -37
  16. package/src/API/getStatus.js +2 -1
  17. package/src/API/getWatchdogStats.js +1 -0
  18. package/src/API/index.js +28 -17
  19. package/src/API/skyblock/getAuction.js +21 -0
  20. package/src/API/skyblock/{getSkyblockAuctions.js → getAuctions.js} +19 -12
  21. package/src/API/skyblock/{getSkyblockAuctionsByPlayer.js → getAuctionsByPlayer.js} +2 -2
  22. package/src/API/skyblock/{getSkyblockBazaar.js → getBazaar.js} +1 -3
  23. package/src/API/skyblock/getBingo.js +7 -0
  24. package/src/API/skyblock/getBingoByPlayer.js +14 -0
  25. package/src/API/skyblock/{getEndedSkyblockAuctions.js → getEndedAuctions.js} +1 -0
  26. package/src/API/skyblock/getFireSales.js +7 -0
  27. package/src/API/skyblock/getGovernment.js +7 -0
  28. package/src/API/skyblock/{getSkyblockMember.js → getMember.js} +10 -3
  29. package/src/API/skyblock/getMuseum.js +15 -0
  30. package/src/API/skyblock/{getSkyblockNews.js → getNews.js} +1 -0
  31. package/src/API/skyblock/{getSkyblockProfiles.js → getProfiles.js} +14 -7
  32. package/src/Client.js +127 -25
  33. package/src/Errors.js +38 -17
  34. package/src/Private/rateLimit.js +17 -13
  35. package/src/Private/requests.js +27 -16
  36. package/src/Private/updater.js +11 -8
  37. package/src/Private/uuidCache.js +23 -30
  38. package/src/Private/validate.js +33 -22
  39. package/src/index.js +9 -0
  40. package/src/structures/APIIncident.js +4 -11
  41. package/src/structures/APIStatus.js +0 -1
  42. package/src/structures/Boosters/Booster.js +14 -13
  43. package/src/structures/Color.js +93 -48
  44. package/src/structures/Game.js +4 -2
  45. package/src/structures/Guild/Guild.js +35 -48
  46. package/src/structures/Guild/GuildMember.js +8 -8
  47. package/src/structures/Guild/GuildRank.js +2 -2
  48. package/src/structures/MiniGames/Arcade.js +242 -235
  49. package/src/structures/MiniGames/ArenaBrawl.js +11 -11
  50. package/src/structures/MiniGames/BedWars.js +262 -131
  51. package/src/structures/MiniGames/BlitzSurvivalGames.js +24 -23
  52. package/src/structures/MiniGames/CopsAndCrims.js +1 -0
  53. package/src/structures/MiniGames/Duels.js +92 -33
  54. package/src/structures/MiniGames/MegaWalls.js +3 -1
  55. package/src/structures/MiniGames/MurderMystery.js +2 -2
  56. package/src/structures/MiniGames/Pit.js +230 -2
  57. package/src/structures/MiniGames/PitInventoryItem.js +43 -0
  58. package/src/structures/MiniGames/SkyWars.js +211 -195
  59. package/src/structures/MiniGames/SmashHeroes.js +37 -35
  60. package/src/structures/MiniGames/SpeedUHC.js +17 -4
  61. package/src/structures/MiniGames/TNTGames.js +1 -1
  62. package/src/structures/MiniGames/UHC.js +33 -14
  63. package/src/structures/MiniGames/WoolWars.js +6 -5
  64. package/src/structures/Pet.js +1 -1
  65. package/src/structures/Player.js +26 -121
  66. package/src/structures/PlayerCosmetics.js +67 -12
  67. package/src/structures/ServerInfo.js +1 -1
  68. package/src/structures/SkyBlock/Auctions/Auction.js +3 -1
  69. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +3 -1
  70. package/src/structures/SkyBlock/Auctions/BaseAuction.js +2 -1
  71. package/src/structures/SkyBlock/Auctions/Bid.js +1 -0
  72. package/src/structures/SkyBlock/Auctions/PartialAuction.js +1 -0
  73. package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
  74. package/src/structures/SkyBlock/PlayerBingo.js +49 -0
  75. package/src/structures/SkyBlock/SkyblockInventoryItem.js +76 -32
  76. package/src/structures/SkyBlock/SkyblockMember.js +252 -289
  77. package/src/structures/SkyBlock/SkyblockMuseum.js +60 -0
  78. package/src/structures/SkyBlock/SkyblockMuseumItem.js +54 -0
  79. package/src/structures/SkyBlock/SkyblockPet.js +3 -3
  80. package/src/structures/SkyBlock/SkyblockProfile.js +37 -23
  81. package/src/structures/SkyBlock/Static/Bingo.js +101 -0
  82. package/src/structures/SkyBlock/Static/BingoData.js +45 -0
  83. package/src/structures/SkyBlock/Static/Candidate.js +40 -0
  84. package/src/structures/SkyBlock/Static/FireSale.js +55 -0
  85. package/src/structures/SkyBlock/Static/Government.js +74 -0
  86. package/src/structures/SkyBlock/Static/Perk.js +24 -0
  87. package/src/structures/Static/Achievement.js +87 -0
  88. package/src/structures/Static/AchievementTier.js +33 -0
  89. package/src/structures/Static/Achievements.js +30 -0
  90. package/src/structures/Static/Challenges.js +29 -0
  91. package/src/structures/Static/GameAchievements.js +36 -0
  92. package/src/structures/Static/GameChallenges.js +40 -0
  93. package/src/structures/Static/GameQuests.js +24 -0
  94. package/src/structures/Static/GuildAchievements.js +34 -0
  95. package/src/structures/Static/Quest.js +66 -0
  96. package/src/structures/Static/Quests.js +31 -0
  97. package/src/structures/Status.js +2 -2
  98. package/src/utils/Constants.js +384 -543
  99. package/src/utils/{guildExp.js → Guild.js} +46 -13
  100. package/src/utils/Player.js +112 -0
  101. package/src/utils/SkyblockUtils.js +448 -186
  102. package/src/utils/arrayTools.js +1 -1
  103. package/src/utils/divide.js +1 -1
  104. package/src/utils/index.js +2 -1
  105. package/src/utils/isGuildID.js +1 -1
  106. package/src/utils/oscillation.js +4 -2
  107. package/src/utils/removeSnakeCase.js +19 -8
  108. package/src/utils/rgbToHexColor.js +1 -1
  109. package/src/utils/romanize.js +35 -4
  110. package/src/utils/toUuid.js +12 -7
  111. package/src/utils/varInt.js +2 -2
  112. package/typings/index.d.ts +1246 -446
  113. package/src/utils/toIGN.js +0 -20
@@ -1,3 +1,10 @@
1
+ const {
2
+ playerLevelProgress,
3
+ parseClaimedRewards,
4
+ getSocialMedia,
5
+ getPlayerLevel,
6
+ getRank
7
+ } = require('../utils/Player');
1
8
  const SkyWars = require('./MiniGames/SkyWars');
2
9
  const BedWars = require('./MiniGames/BedWars');
3
10
  const UHC = require('./MiniGames/UHC');
@@ -13,8 +20,6 @@ const VampireZ = require('./MiniGames/VampireZ');
13
20
  const BlitzSurvivalGames = require('./MiniGames/BlitzSurvivalGames');
14
21
  const ArenaBrawl = require('./MiniGames/ArenaBrawl');
15
22
  const Arcade = require('./MiniGames/Arcade');
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- const Pit = require('./MiniGames/Pit');
18
23
  const Color = require('./Color');
19
24
  const Game = require('./Game');
20
25
  const PlayerCosmetics = require('./PlayerCosmetics');
@@ -25,6 +30,9 @@ const Quakecraft = require('./MiniGames/Quakecraft');
25
30
  const Walls = require('./MiniGames/Walls');
26
31
  const Warlords = require('./MiniGames/Warlords');
27
32
  const WoolWars = require('./MiniGames/WoolWars');
33
+ const Pit = require('./MiniGames/Pit');
34
+ const Guild = require('./Guild/Guild');
35
+ const RecentGame = require('./RecentGame');
28
36
  /**
29
37
  * Player class
30
38
  */
@@ -44,21 +52,11 @@ class Player {
44
52
  * @type {string}
45
53
  */
46
54
  this.uuid = data.uuid;
47
- /**
48
- * Player nickname history known to Hypixel
49
- * @type {Array<string>}
50
- */
51
- this.history = data.knownAliases;
52
55
  /**
53
56
  * Player rank
54
57
  * @type {PlayerRank}
55
58
  */
56
59
  this.rank = getRank(data);
57
- /**
58
- * Player minecraft version
59
- * @type {string|null}
60
- */
61
- this.mcVersion = data.mcVersionRp || null;
62
60
  /**
63
61
  * Current chat channel, usually ALL, PARTY, or GUILD
64
62
  * @type {string|null}
@@ -75,12 +73,12 @@ class Player {
75
73
  */
76
74
  this.firstLogin = data.firstLogin ? new Date(data.firstLogin) : null;
77
75
  /**
78
- * Player's recently played game
76
+ * Timestamp when player last logged in as Date
79
77
  * @type {Game|null}
80
78
  */
81
79
  this.lastLoginTimestamp = data.lastLogin || null;
82
80
  /**
83
- * Timestamp when player first logged in
81
+ * Timestamp when player first logged in unix
84
82
  * @type {number|null}
85
83
  */
86
84
  this.lastLogin = data.lastLogin ? new Date(data.lastLogin) : null;
@@ -90,8 +88,8 @@ class Player {
90
88
  */
91
89
  this.lastLogoutTimestamp = data.lastLogout || null;
92
90
  /**
93
- * Timestamp when player first logged in as Date
94
- * @type {Date|null}
91
+ * Timestamp when player first logged in unix
92
+ * @type {number|null}
95
93
  */
96
94
  this.lastLogout = data.lastLogout ? new Date(data.lastLogout) : null;
97
95
  /**
@@ -103,12 +101,18 @@ class Player {
103
101
  * Player's plus color (must be a MVP+ rank)
104
102
  * @type {Color|null}
105
103
  */
106
- this.plusColor = this.rank === 'MVP+' || this.rank === 'MVP++' ? (data.rankPlusColor ? new Color(data.rankPlusColor) : new Color('RED')) : null;
104
+ this.plusColor =
105
+ 'MVP+' === this.rank || 'MVP++' === this.rank
106
+ ? data.rankPlusColor
107
+ ? new Color(data.rankPlusColor)
108
+ : new Color('RED')
109
+ : null;
107
110
  /**
108
111
  * MVP++ prefix color
109
112
  * @type {Color|null}
110
113
  */
111
- this.prefixColor = this.rank === 'MVP++' ? (data.monthlyRankColor ? new Color(data.monthlyRankColor) : new Color('GOLD')) : null;
114
+ this.prefixColor =
115
+ 'MVP++' === this.rank ? (data.monthlyRankColor ? new Color(data.monthlyRankColor) : new Color('GOLD')) : null;
112
116
  /**
113
117
  * Player karma
114
118
  * @type {number}
@@ -163,7 +167,7 @@ class Player {
163
167
  * Last time player claimed the daily reward
164
168
  * @type {Date | null}
165
169
  */
166
- this.lastDailyReward = new Date(data.lastAdsenseGenerateTime) || null;
170
+ this.lastDailyReward = data.lastAdsenseGenerateTime ? new Date(data.lastAdsenseGenerateTime) : null;
167
171
  /**
168
172
  * Last time player claimed the daily reward, as timestamp
169
173
  * @type {number | null}
@@ -236,7 +240,7 @@ class Player {
236
240
  walls: data.stats.Walls ? new Walls(data.stats.Walls) : null,
237
241
  warlords: data.stats.Battleground ? new Warlords(data.stats.Battleground) : null,
238
242
  woolwars: data.stats.WoolGames ? new WoolWars(data.stats.WoolGames) : null,
239
- pit: null
243
+ pit: data.stats.Pit ? new Pit(data.stats.Pit) : null
240
244
  }
241
245
  : null;
242
246
  /**
@@ -254,7 +258,7 @@ class Player {
254
258
  * Global Cosmetics a player owns
255
259
  * @type {PlayerCosmetics}
256
260
  */
257
- this.globalCosmetics = new PlayerCosmetics(data) || null;
261
+ this.globalCosmetics = data ? new PlayerCosmetics(data) : null;
258
262
  /**
259
263
  * Time at which the ranks were purchased. Can be all null if bought a long time ago, and some values can be null if player bought directly a rank above that
260
264
  * @type {RanksPurchaseTime}
@@ -274,106 +278,6 @@ class Player {
274
278
  return this.nickname;
275
279
  }
276
280
  }
277
-
278
- // eslint-disable-next-line require-jsdoc
279
- function getRank(player) {
280
- let rank;
281
- if (player.prefix) {
282
- rank = player.prefix.replace(/§[0-9|a-z]|\[|\]/g, '');
283
- } else if (player.rank && player.rank !== 'NORMAL') {
284
- switch (player.rank) {
285
- case 'YOUTUBER':
286
- rank = 'YouTube';
287
- break;
288
- case 'GAME_MASTER':
289
- rank = 'Game Master';
290
- break;
291
- case 'ADMIN':
292
- rank = 'Admin';
293
- break;
294
- }
295
- } else {
296
- switch (player.newPackageRank) {
297
- case 'MVP_PLUS':
298
- rank = player.monthlyPackageRank && player.monthlyPackageRank === 'SUPERSTAR' ? 'MVP++' : 'MVP+';
299
- break;
300
- case 'MVP':
301
- rank = 'MVP';
302
- break;
303
- case 'VIP_PLUS':
304
- rank = 'VIP+';
305
- break;
306
- case 'VIP':
307
- rank = 'VIP';
308
- break;
309
- default:
310
- rank = player.monthlyPackageRank && player.monthlyPackageRank === 'SUPERSTAR' ? 'MVP++' : 'Default';
311
- }
312
- }
313
- return rank;
314
- }
315
- // eslint-disable-next-line require-jsdoc
316
- function getPlayerLevel(exp) {
317
- const base = 10000;
318
- const growth = 2500;
319
- const reversePqPrefix = -(base - 0.5 * growth) / growth;
320
- const reverseConst = reversePqPrefix * reversePqPrefix;
321
- const growthDivides2 = 2 / growth;
322
- const num = 1 + reversePqPrefix + Math.sqrt(reverseConst + growthDivides2 * exp);
323
- const level = Math.round(num * 100) / 100;
324
- return level;
325
- }
326
- // eslint-disable-next-line require-jsdoc
327
- function xpToNextLevel(player) {
328
- const lvl = getPlayerLevel(player.networkExp);
329
- const xpToNext = 2500 * Math.floor(lvl) + 5000;
330
- if (player.networkExp < 10000) return 10000;
331
- return xpToNext;
332
- }
333
- // eslint-disable-next-line require-jsdoc
334
- function levelToXP(player) {
335
- let level = Number(Math.floor(getPlayerLevel(player.networkExp)));
336
- level = level - 1;
337
- const xp = 1250 * level ** 2 + 8750 * level;
338
- return xp;
339
- }
340
- // eslint-disable-next-line require-jsdoc
341
- function playerLevelProgress(player) {
342
- const xpFromLevel = levelToXP(player);
343
- let currentXP = player.networkExp - xpFromLevel;
344
- const xpToNext = xpToNextLevel(player);
345
- const remainingXP = xpToNext - currentXP + 2500;
346
- currentXP = currentXP - 2500;
347
- const percent = Math.round((currentXP / xpToNext) * 100 * 100) / 100;
348
- const percentRemaining = Math.round((100 - percent) * 100) / 100;
349
- return {
350
- xpToNext,
351
- currentXP,
352
- remainingXP,
353
- percent,
354
- percentRemaining
355
- };
356
- }
357
- // eslint-disable-next-line require-jsdoc
358
- function getSocialMedia(data) {
359
- if (!data) return null;
360
- const links = data.links;
361
- const formattedNames = ['Twitter', 'YouTube', 'Instagram', 'Twitch', 'Hypixel', 'Discord'];
362
- const upperNames = ['TWITTER', 'YOUTUBE', 'INSTAGRAM', 'TWITCH', 'HYPIXEL', 'DISCORD'];
363
- if (!links) return null;
364
- return Object.keys(links)
365
- .map((x) => upperNames.indexOf(x))
366
- .filter((x) => x !== -1)
367
- .map((x) => ({ name: formattedNames[x], link: links[upperNames[x]], id: upperNames[x] }));
368
- }
369
- // eslint-disable-next-line require-jsdoc
370
- function parseClaimedRewards(data) {
371
- if (!data) return null;
372
- return Object.keys(data)
373
- .map((x) => x.match(/levelingReward_(\d+)/))
374
- .filter((x) => x)
375
- .map((x) => parseInt(x[1], 10));
376
- }
377
281
  /**
378
282
  * @typedef {string} PlayerRank
379
283
  * * `Default`
@@ -413,6 +317,7 @@ function parseClaimedRewards(data) {
413
317
  * @property {BlitzSurvivalGames|null} blitzsg Blitz Survival Games
414
318
  * @property {ArenaBrawl|null} arena Arena Brawl
415
319
  * @property {Arcade|null} arcade Arcade
320
+ * @property {WoolWars|null} woolwars Wool Wars
416
321
  */
417
322
  /**
418
323
  * @typedef {Object} RanksPurchaseTime
@@ -1,5 +1,6 @@
1
- const Pets = require('./Pets');
1
+ /* eslint-disable no-underscore-dangle */
2
2
  const { removeSnakeCaseString } = require('../utils/removeSnakeCase');
3
+ const Pets = require('./Pets');
3
4
  /**
4
5
  * Player Cosmetics class
5
6
  */
@@ -12,7 +13,7 @@ class PlayerCosmetics {
12
13
  * All cosmetics
13
14
  * @type {string[]}
14
15
  */
15
- this.allCosmetics = data.vanityMeta ? data.vanityMeta.packages : undefined;
16
+ this.allCosmetics = data?.vanityMeta?.packages || undefined;
16
17
  /**
17
18
  * Pets
18
19
  * @type {Pets|null}
@@ -29,7 +30,13 @@ class PlayerCosmetics {
29
30
  * @type {string[]}
30
31
  */
31
32
  get suits() {
32
- if (!this._suits) this._suits = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('suit_')).map((x) => removeSnakeCaseString(x.replace('suit_', ''))) || [] : [];
33
+ if (!this._suits) {
34
+ this._suits = this.allCosmetics
35
+ ? this.allCosmetics
36
+ .filter((x) => x.startsWith('suit_'))
37
+ .map((x) => removeSnakeCaseString(x.replace('suit_', ''))) || []
38
+ : [];
39
+ }
33
40
  return this._suits;
34
41
  }
35
42
  /**
@@ -37,7 +44,13 @@ class PlayerCosmetics {
37
44
  * @type {string[]}
38
45
  */
39
46
  get hats() {
40
- if (!this._hats) this._hats = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('hat_')).map((x) => removeSnakeCaseString(x.replace('hat_', ''))) || [] : [];
47
+ if (!this._hats) {
48
+ this._hats = this.allCosmetics
49
+ ? this.allCosmetics
50
+ .filter((x) => x.startsWith('hat_'))
51
+ .map((x) => removeSnakeCaseString(x.replace('hat_', ''))) || []
52
+ : [];
53
+ }
41
54
  return this._hats;
42
55
  }
43
56
  /**
@@ -45,7 +58,13 @@ class PlayerCosmetics {
45
58
  * @type {string[]}
46
59
  */
47
60
  get gadgets() {
48
- if (!this._gadgets) this._gadgets = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('gadget_')).map((x) => removeSnakeCaseString(x.replace('gadget_', ''))) || [] : [];
61
+ if (!this._gadgets) {
62
+ this._gadgets = this.allCosmetics
63
+ ? this.allCosmetics
64
+ .filter((x) => x.startsWith('gadget_'))
65
+ .map((x) => removeSnakeCaseString(x.replace('gadget_', ''))) || []
66
+ : [];
67
+ }
49
68
  return this._gadgets;
50
69
  }
51
70
  /**
@@ -53,7 +72,13 @@ class PlayerCosmetics {
53
72
  * @type {string[]}
54
73
  */
55
74
  get morphs() {
56
- if (!this._morphs) this._morphs = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('morph_')).map((x) => removeSnakeCaseString(x.replace('morph_', ''))) || [] : [];
75
+ if (!this._morphs) {
76
+ this._morphs = this.allCosmetics
77
+ ? this.allCosmetics
78
+ .filter((x) => x.startsWith('morph_'))
79
+ .map((x) => removeSnakeCaseString(x.replace('morph_', ''))) || []
80
+ : [];
81
+ }
57
82
  return this._morphs;
58
83
  }
59
84
  /**
@@ -61,7 +86,13 @@ class PlayerCosmetics {
61
86
  * @type {string[]}
62
87
  */
63
88
  get cloaks() {
64
- if (!this._cloaks) this._cloaks = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('cloak_')).map((x) => removeSnakeCaseString(x.replace('cloak_', ''))) || [] : [];
89
+ if (!this._cloaks) {
90
+ this._cloaks = this.allCosmetics
91
+ ? this.allCosmetics
92
+ .filter((x) => x.startsWith('cloak_'))
93
+ .map((x) => removeSnakeCaseString(x.replace('cloak_', ''))) || []
94
+ : [];
95
+ }
65
96
  return this._cloaks;
66
97
  }
67
98
  /**
@@ -69,7 +100,13 @@ class PlayerCosmetics {
69
100
  * @type {string[]}
70
101
  */
71
102
  get taunts() {
72
- if (!this._taunts) this._taunts = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('taunt_')).map((x) => removeSnakeCaseString(x.replace('taunt_', ''))) || [] : [];
103
+ if (!this._taunts) {
104
+ this._taunts = this.allCosmetics
105
+ ? this.allCosmetics
106
+ .filter((x) => x.startsWith('taunt_'))
107
+ .map((x) => removeSnakeCaseString(x.replace('taunt_', ''))) || []
108
+ : [];
109
+ }
73
110
  return this._taunts;
74
111
  }
75
112
  /**
@@ -77,15 +114,27 @@ class PlayerCosmetics {
77
114
  * @type {string[]}
78
115
  */
79
116
  get rankColors() {
80
- if (!this._rankcolors) this._rankcolors = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('rankcolor_')).map((x) => removeSnakeCaseString(x.replace('rankcolor_', ''))) || [] : [];
81
- return this._rankcolors;
117
+ if (!this._rankColors) {
118
+ this._rankColors = this.allCosmetics
119
+ ? this.allCosmetics
120
+ .filter((x) => x.startsWith('rankcolor_'))
121
+ .map((x) => removeSnakeCaseString(x.replace('rankcolor_', ''))) || []
122
+ : [];
123
+ }
124
+ return this._rankColors;
82
125
  }
83
126
  /**
84
127
  * Particle Packs
85
128
  * @type {string[]}
86
129
  */
87
130
  get particlePacks() {
88
- if (!this._particle) this._particle = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('particlepack_')).map((x) => removeSnakeCaseString(x.replace('particlepack_', ''))) || [] : [];
131
+ if (!this._particle) {
132
+ this._particle = this.allCosmetics
133
+ ? this.allCosmetics
134
+ .filter((x) => x.startsWith('particlepack_'))
135
+ .map((x) => removeSnakeCaseString(x.replace('particlepack_', ''))) || []
136
+ : [];
137
+ }
89
138
  return this._particlepacks;
90
139
  }
91
140
  /**
@@ -93,7 +142,13 @@ class PlayerCosmetics {
93
142
  * @type {string[]}
94
143
  */
95
144
  get clickEffects() {
96
- if (!this._clickfx) this._clickfx = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('clickeffects_')).map((x) => removeSnakeCaseString(x.replace('clickeffects_', ''))) || [] : [];
145
+ if (!this._clickfx) {
146
+ this._clickfx = this.allCosmetics
147
+ ? this.allCosmetics
148
+ .filter((x) => x.startsWith('clickeffects_'))
149
+ .map((x) => removeSnakeCaseString(x.replace('clickeffects_', ''))) || []
150
+ : [];
151
+ }
97
152
  return this._clickfx;
98
153
  }
99
154
  }
@@ -10,7 +10,7 @@ class ServerInfo {
10
10
  constructor(data, ping) {
11
11
  /**
12
12
  * Protocol used for retrieving info, should be 736
13
- * @type {Number}
13
+ * @type {number}
14
14
  */
15
15
  this.protocolUsed = data.version.protocol || 736;
16
16
  /**
@@ -1,5 +1,5 @@
1
- const Bid = require('./Bid');
2
1
  const BaseAuction = require('./BaseAuction');
2
+ const Bid = require('./Bid');
3
3
  /**
4
4
  * Auction class
5
5
  */
@@ -89,6 +89,7 @@ class Auction extends BaseAuction {
89
89
  return this.item;
90
90
  }
91
91
  }
92
+
92
93
  /**
93
94
  * @typedef {string} Rarity
94
95
  * * `VERY_SPECIAL`
@@ -101,4 +102,5 @@ class Auction extends BaseAuction {
101
102
  * * `UNCOMMON`
102
103
  * * `COMMON`
103
104
  */
105
+
104
106
  module.exports = Auction;
@@ -1,4 +1,3 @@
1
- /* eslint-disable require-jsdoc */
2
1
  /**
3
2
  * Auction info class
4
3
  */
@@ -36,6 +35,8 @@ class AuctionInfo {
36
35
  * Age
37
36
  * @type {number}
38
37
  */
38
+
39
+ // eslint-disable-next-line no-underscore-dangle
39
40
  this.age = parseInt(data._headers.get('age'), 10) || 0;
40
41
  }
41
42
 
@@ -51,4 +52,5 @@ class AuctionInfo {
51
52
  return `${this.page} / ${this.totalPages}`;
52
53
  }
53
54
  }
55
+
54
56
  module.exports = AuctionInfo;
@@ -32,7 +32,7 @@ class BaseAuction {
32
32
  * Item bytes
33
33
  * @type {ItemBytes|null}
34
34
  */
35
- this.itemBytes = includeItemBytes ? new ItemBytes(data.item_bytes) || null : null;
35
+ this.itemBytes = includeItemBytes ? new ItemBytes(data.item_bytes) : null;
36
36
  }
37
37
  /**
38
38
  * Auction ID
@@ -42,4 +42,5 @@ class BaseAuction {
42
42
  return this.auctionId;
43
43
  }
44
44
  }
45
+
45
46
  module.exports = BaseAuction;
@@ -45,4 +45,5 @@ class Bid {
45
45
  return `${this.bidder} bid ${this.amount} coins`;
46
46
  }
47
47
  }
48
+
48
49
  module.exports = Bid;
@@ -22,4 +22,5 @@ class PartialAuction extends BaseAuction {
22
22
  this.price = parseInt(data.price, 10) || 0;
23
23
  }
24
24
  }
25
+
25
26
  module.exports = PartialAuction;
@@ -1,5 +1,19 @@
1
- const dateRegExp = /(\d{1,2})(?:st|nd|rd|th|) ([A-z]+) (\d+)/;
1
+ const dateRegExp = /(\d{1,2})(?:st|nd|rd|th|) ([A-Za-z]+) (\d+)/;
2
2
  const versionRegExp = /v\d+(\.\d+){1,}/;
3
+
4
+ // eslint-disable-next-line jsdoc/require-jsdoc
5
+ function parseDate(stringDate) {
6
+ const matched = stringDate.match(dateRegExp);
7
+ if (!matched) return null;
8
+ return new Date(matched.slice(1).join(' '));
9
+ }
10
+
11
+ // eslint-disable-next-line jsdoc/require-jsdoc
12
+ function parseVer(stringVer) {
13
+ const matches = versionRegExp.exec(stringVer);
14
+ if (!matches?.length) return null;
15
+ return matches[0];
16
+ }
3
17
  /**
4
18
  * SkyblockNews
5
19
  */
@@ -32,7 +46,6 @@ class SkyblockNews {
32
46
  * The version from the title (Skyblock v0.12.57673856757.327.2 => v0.12.57673856757.327.2)
33
47
  * @author linearaccelerator
34
48
  * @type {string | null}
35
- * @version >6.0.1
36
49
  */
37
50
  this.version = parseVer(this.title);
38
51
  }
@@ -44,17 +57,4 @@ class SkyblockNews {
44
57
  return this.title;
45
58
  }
46
59
  }
47
- // eslint-disable-next-line require-jsdoc
48
- function parseDate(stringDate) {
49
- const matched = stringDate.match(dateRegExp);
50
- if (!matched) return null;
51
- return new Date(matched.slice(1).join(' ')); // Ok this is lazy, but should work
52
- }
53
-
54
- // eslint-disable-next-line require-jsdoc
55
- function parseVer(stringVer) {
56
- const matches = versionRegExp.exec(stringVer);
57
- if (!matches?.length) return null; // this shouldn't really happen
58
- return matches[0];
59
- }
60
60
  module.exports = SkyblockNews;
@@ -0,0 +1,49 @@
1
+ const { populateGoals } = require('../../utils/SkyblockUtils');
2
+ // eslint-disable-next-line no-unused-vars
3
+ const BingoDataType = require('./Static/BingoData.js');
4
+ // eslint-disable-next-line no-unused-vars
5
+ const BingoType = require('./Static/Bingo.js');
6
+ /**
7
+ * @typedef {BingoDataType} BingoData
8
+ * @typedef {BingoType} Bingo
9
+ */
10
+
11
+ /**
12
+ * Player Bingo Class
13
+ */
14
+ class PlayerBingo {
15
+ /**
16
+ * Constructor
17
+ * @param {Object} data data
18
+ * @param {BingoData|null} bingoData bingo data
19
+ */
20
+ constructor(data, bingoData) {
21
+ const events = data.success && Array.isArray(data.events) ? data.events : [];
22
+ /**
23
+ * Data per event
24
+ * @type {PlayerBingoDataPerEvent}
25
+ */
26
+ this.dataPerEvent = events.map((eventData) => {
27
+ let doneGoals = eventData.completed_goals;
28
+ if (!Array.isArray(doneGoals)) doneGoals = [];
29
+ const enrichable = parseInt(eventData.key, 10) === bingoData?.id;
30
+ if (enrichable) doneGoals = populateGoals(doneGoals, bingoData.goals);
31
+ return {
32
+ eventId: parseInt(eventData.key, 10) || null,
33
+ points: parseInt(eventData.points, 10) || 0,
34
+ goalsCompleted: doneGoals,
35
+ enrichedGoals: enrichable
36
+ };
37
+ });
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @typedef {Object} PlayerBingoDataPerEvent
43
+ * @property {number} eventId ID of event
44
+ * @property {number} points Points acquired
45
+ * @property {boolean} enrichedGoals Whether the goals are enriched (populated with data from static skyblock bingp data)
46
+ * @property {Bingo[]|string[]} goalsCompleted Special Bingo Array if enrichedGoals is true. You can however always treat SpecialBingoArray as string[]
47
+ */
48
+
49
+ module.exports = PlayerBingo;