hypixel-api-reborn 11.2.0 → 11.3.0

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 (101) hide show
  1. package/README.md +1 -1
  2. package/eslint.config.mjs +71 -0
  3. package/package.json +14 -20
  4. package/src/API/getAchievements.js +1 -0
  5. package/src/API/getBoosters.js +1 -0
  6. package/src/API/getChallenges.js +1 -0
  7. package/src/API/getGameCounts.js +1 -0
  8. package/src/API/getGuild.js +4 -3
  9. package/src/API/getGuildAchievements.js +1 -0
  10. package/src/API/getLeaderboards.js +1 -1
  11. package/src/API/getPlayer.js +1 -0
  12. package/src/API/getQuests.js +1 -0
  13. package/src/API/getRecentGames.js +5 -9
  14. package/src/API/getServerInfo.js +40 -37
  15. package/src/API/getStatus.js +1 -0
  16. package/src/API/getWatchdogStats.js +1 -0
  17. package/src/API/housing/getActiveHouses.js +7 -0
  18. package/src/API/housing/getHouse.js +9 -0
  19. package/src/API/housing/getPlayerHouses.js +11 -0
  20. package/src/API/index.js +6 -1
  21. package/src/API/skyblock/getAuction.js +8 -6
  22. package/src/API/skyblock/getAuctions.js +15 -12
  23. package/src/API/skyblock/getAuctionsByPlayer.js +1 -1
  24. package/src/API/skyblock/getBazaar.js +1 -3
  25. package/src/API/skyblock/getBingo.js +1 -2
  26. package/src/API/skyblock/getBingoByPlayer.js +3 -3
  27. package/src/API/skyblock/getEndedAuctions.js +1 -0
  28. package/src/API/skyblock/getFireSales.js +1 -1
  29. package/src/API/skyblock/getGarden.js +7 -0
  30. package/src/API/skyblock/getGovernment.js +1 -2
  31. package/src/API/skyblock/getMember.js +5 -2
  32. package/src/API/skyblock/getMuseum.js +1 -0
  33. package/src/API/skyblock/getNews.js +1 -0
  34. package/src/API/skyblock/getProfiles.js +5 -2
  35. package/src/Client.js +88 -16
  36. package/src/Private/rateLimit.js +7 -11
  37. package/src/Private/requests.js +12 -13
  38. package/src/Private/updater.js +2 -3
  39. package/src/Private/uuidCache.js +1 -2
  40. package/src/Private/validate.js +19 -19
  41. package/src/index.js +5 -0
  42. package/src/structures/APIIncident.js +1 -2
  43. package/src/structures/APIStatus.js +0 -1
  44. package/src/structures/Boosters/Booster.js +9 -8
  45. package/src/structures/Game.js +1 -1
  46. package/src/structures/Guild/Guild.js +19 -36
  47. package/src/structures/Guild/GuildMember.js +2 -2
  48. package/src/structures/House.js +54 -0
  49. package/src/structures/MiniGames/Arcade.js +798 -312
  50. package/src/structures/MiniGames/ArenaBrawl.js +98 -32
  51. package/src/structures/MiniGames/BedWars.js +197 -194
  52. package/src/structures/MiniGames/BlitzSurvivalGames.js +381 -129
  53. package/src/structures/MiniGames/BuildBattle.js +19 -8
  54. package/src/structures/MiniGames/CopsAndCrims.js +253 -25
  55. package/src/structures/MiniGames/Duels.js +905 -664
  56. package/src/structures/MiniGames/MegaWalls.js +390 -51
  57. package/src/structures/MiniGames/MurderMystery.js +151 -30
  58. package/src/structures/MiniGames/Paintball.js +31 -11
  59. package/src/structures/MiniGames/Pit.js +4 -5
  60. package/src/structures/MiniGames/Quakecraft.js +113 -50
  61. package/src/structures/MiniGames/SkyWars.js +528 -372
  62. package/src/structures/MiniGames/SmashHeroes.js +201 -73
  63. package/src/structures/MiniGames/SpeedUHC.js +77 -24
  64. package/src/structures/MiniGames/TNTGames.js +242 -73
  65. package/src/structures/MiniGames/TurboKartRacers.js +55 -115
  66. package/src/structures/MiniGames/UHC.js +144 -132
  67. package/src/structures/MiniGames/VampireZ.js +70 -37
  68. package/src/structures/MiniGames/Warlords.js +126 -1
  69. package/src/structures/MiniGames/WoolWars.js +60 -9
  70. package/src/structures/Pet.js +1 -1
  71. package/src/structures/Player.js +43 -128
  72. package/src/structures/PlayerCosmetics.js +5 -4
  73. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +2 -1
  74. package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -1
  75. package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
  76. package/src/structures/SkyBlock/PlayerBingo.js +7 -14
  77. package/src/structures/SkyBlock/SkyblockGarden.js +146 -0
  78. package/src/structures/SkyBlock/SkyblockInventoryItem.js +4 -28
  79. package/src/structures/SkyBlock/SkyblockMember.js +90 -228
  80. package/src/structures/SkyBlock/SkyblockPet.js +3 -4
  81. package/src/structures/SkyBlock/Static/Bingo.js +10 -11
  82. package/src/structures/SkyBlock/Static/BingoData.js +1 -1
  83. package/src/structures/Static/Achievement.js +16 -15
  84. package/src/structures/Static/AchievementTier.js +2 -2
  85. package/src/structures/Static/Quest.js +2 -2
  86. package/src/utils/Constants.js +522 -520
  87. package/src/utils/{guildExp.js → Guild.js} +42 -12
  88. package/src/utils/Player.js +112 -0
  89. package/src/utils/SkyblockUtils.js +482 -192
  90. package/src/utils/arrayTools.js +1 -1
  91. package/src/utils/divide.js +1 -1
  92. package/src/utils/index.js +2 -1
  93. package/src/utils/isGuildID.js +1 -1
  94. package/src/utils/oscillation.js +4 -2
  95. package/src/utils/removeSnakeCase.js +11 -7
  96. package/src/utils/rgbToHexColor.js +1 -1
  97. package/src/utils/romanize.js +3 -3
  98. package/src/utils/toUuid.js +4 -4
  99. package/src/utils/varInt.js +2 -2
  100. package/typings/index.d.ts +1186 -967
  101. package/src/utils/toIGN.js +0 -24
@@ -34,13 +34,62 @@ class WoolWars {
34
34
  * @type {number}
35
35
  */
36
36
  this.coins = data.coins || 0;
37
+ /**
38
+ * Wins
39
+ * @type {number}
40
+ */
41
+ this.wins = data.wins || 0;
42
+ /**
43
+ * gamesPlayed
44
+ * @type {number}
45
+ */
46
+ this.gamesPlayed = data.games_played || 0;
47
+ /**
48
+ * woolsPlaced
49
+ * @type {number}
50
+ */
51
+ this.woolsPlaced = data.wool_placed || 0;
52
+ /**
53
+ * blocksBroken
54
+ * @type {number}
55
+ */
56
+ this.blocksBroken = data.blocks_broken || 0;
57
+ /**
58
+ * placeBreakRatio
59
+ * @type {number}
60
+ */
61
+ this.placeBreakRatio = divide(this.woolsPlaced, this.blocksBroken);
62
+ /**
63
+ * kills
64
+ * @type {number}
65
+ */
66
+ this.kills = data.kills || 0;
67
+ /**
68
+ * deaths
69
+ * @type {number}
70
+ */
71
+ this.deaths = data.deaths || 0;
72
+ /**
73
+ * KDRatio
74
+ * @type {number}
75
+ */
76
+ this.KDRatio = divide(this.kills, this.deaths);
77
+ /**
78
+ * assists
79
+ * @type {number}
80
+ */
81
+ this.assists = data.assists || 0;
82
+ /**
83
+ * powerups
84
+ * @type {number}
85
+ */
86
+ this.powerups = data.powerups_gotten || 0;
37
87
  /**
38
88
  * Selected class, or NONE if field isn't present in API for some reason
39
89
  * @type {'ASSAULT'|'TANK'|'GOLEM'|'SWORDSMAN'|'ENGINEER'|'ARCHER'|'NONE'}
40
90
  */
41
91
  this.selectedClass = data.wool_wars?.selected_class || 'NONE';
42
92
  this.stats = {
43
- overall: WoolWars.generateStatsFor(data.wool_wars?.stats, ''),
44
93
  assault: WoolWars.generateStatsFor(data.wool_wars?.stats, 'assault'),
45
94
  tank: WoolWars.generateStatsFor(data.wool_wars?.stats, 'tank'),
46
95
  golem: WoolWars.generateStatsFor(data.wool_wars?.stats, 'golem'),
@@ -48,7 +97,6 @@ class WoolWars {
48
97
  engineer: WoolWars.generateStatsFor(data.wool_wars?.stats, 'engineer'),
49
98
  archer: WoolWars.generateStatsFor(data.wool_wars?.stats, 'archer')
50
99
  };
51
- // Misc fields ig
52
100
  /**
53
101
  * Owned Cosmetics
54
102
  * @type {string[]}
@@ -66,30 +114,32 @@ class WoolWars {
66
114
  * @return {number}
67
115
  */
68
116
  static convertXPToLevel(exp) {
69
- const minimalExp = [0, 1e3, 3e3, 6e3, 1e4, 15e3]; // NB: progression is 1k, 2k, 3k, 4k, 5k
117
+ const minimalExp = [0, 1e3, 3e3, 6e3, 1e4, 15e3];
70
118
  const baseLevel = minimalExp.length;
71
119
  const baseExp = minimalExp[minimalExp.length - 1];
72
120
  const expToLevel100 = 49e4;
73
121
  if (exp < baseExp) return minimalExp.findIndex((x) => exp < x);
74
122
  const theoreticalLevel = (exp - baseExp) / 5e3 + baseLevel;
75
- if (theoreticalLevel > 100) return 100 + this.convertXPToLevel(exp - expToLevel100);
123
+ if (100 < theoreticalLevel) return 100 + this.convertXPToLevel(exp - expToLevel100);
76
124
  return theoreticalLevel;
77
125
  }
78
126
  /**
79
127
  * Generates stats per class/overall
80
- * @param {Record<string, unknwon>} data data
128
+ * @param {Record<string, any>} data data
81
129
  * @param {string} [_class=''] Class
82
130
  * @return {WoolWarsStats}
83
131
  */
84
132
  static generateStatsFor(data, _class) {
85
133
  // N.B i called it _class instead of class because reserved keyword
86
- const workingData = (_class ? data?.['classes']?.[_class] : data) || {};
134
+
135
+ // eslint-disable-next-line no-underscore-dangle
136
+ const workingData = (_class ? data?.classes?.[_class] : data) || {};
87
137
  return {
88
- roundWins: workingData.wins || 0,
138
+ wins: workingData.wins || 0,
89
139
  gamesPlayed: workingData.games_played || 0,
90
140
  woolsPlaced: workingData.wool_placed || 0,
91
141
  blocksBroken: workingData.blocks_broken || 0,
92
- placeBreakRatio: divide(workingData.wool_placed, workingData.blocks_broken),
142
+ placeBreakRatio: divide(workingData.wool_placed || 0, workingData.blocks_broken || 0),
93
143
  kills: workingData.kills || 0,
94
144
  deaths: workingData.deaths || 0,
95
145
  KDRatio: divide(workingData.kills, workingData.deaths),
@@ -106,10 +156,11 @@ class WoolWars {
106
156
  * @property {string} game_speed Game speed
107
157
  * @property {string} speed Player speed
108
158
  * @property {'Enabled'|'Disabled'} no_class No class
159
+ * @property {boolean} respawn_enable Respawning enabled
109
160
  */
110
161
  /**
111
162
  * @typedef {Object} WoolWarsStats
112
- * @property {number} roundWins round wins
163
+ * @property {number} wins wins
113
164
  * @property {number} gamesPlayed games played
114
165
  * @property {number} woolsPlaced wools placed
115
166
  * @property {number} blocksBroken blocks broken
@@ -29,7 +29,7 @@ class Pet {
29
29
  * Stats of the pet, if any
30
30
  * @type {object}
31
31
  */
32
- if (!stats) return; // don't parse stats because there is none.
32
+ if (!stats) return;
33
33
  /**
34
34
  * Hunger value ( 100 is highest )
35
35
  * @type {?number}
@@ -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');
@@ -24,6 +31,8 @@ const Walls = require('./MiniGames/Walls');
24
31
  const Warlords = require('./MiniGames/Warlords');
25
32
  const WoolWars = require('./MiniGames/WoolWars');
26
33
  const Pit = require('./MiniGames/Pit');
34
+ const Guild = require('./Guild/Guild');
35
+ const RecentGame = require('./RecentGame');
27
36
  /**
28
37
  * Player class
29
38
  */
@@ -93,7 +102,7 @@ class Player {
93
102
  * @type {Color|null}
94
103
  */
95
104
  this.plusColor =
96
- this.rank === 'MVP+' || this.rank === 'MVP++'
105
+ 'MVP+' === this.rank || 'MVP++' === this.rank
97
106
  ? data.rankPlusColor
98
107
  ? new Color(data.rankPlusColor)
99
108
  : new Color('RED')
@@ -103,7 +112,7 @@ class Player {
103
112
  * @type {Color|null}
104
113
  */
105
114
  this.prefixColor =
106
- this.rank === 'MVP++' ? (data.monthlyRankColor ? new Color(data.monthlyRankColor) : new Color('GOLD')) : null;
115
+ 'MVP++' === this.rank ? (data.monthlyRankColor ? new Color(data.monthlyRankColor) : new Color('GOLD')) : null;
107
116
  /**
108
117
  * Player karma
109
118
  * @type {number}
@@ -158,7 +167,7 @@ class Player {
158
167
  * Last time player claimed the daily reward
159
168
  * @type {Date | null}
160
169
  */
161
- this.lastDailyReward = new Date(data.lastAdsenseGenerateTime) || null;
170
+ this.lastDailyReward = data.lastAdsenseGenerateTime ? new Date(data.lastAdsenseGenerateTime) : null;
162
171
  /**
163
172
  * Last time player claimed the daily reward, as timestamp
164
173
  * @type {number | null}
@@ -210,28 +219,28 @@ class Player {
210
219
  */
211
220
  this.stats = data.stats
212
221
  ? {
213
- skywars: data.stats.SkyWars ? new SkyWars(data.stats.SkyWars) : null,
222
+ arcade: data.stats.Arcade ? new Arcade({ ...data.stats.Arcade, ...data.achievements }) : null,
223
+ arena: data.stats.Arena ? new ArenaBrawl(data.stats.Arena) : null,
214
224
  bedwars: data.stats.Bedwars ? new BedWars(data.stats.Bedwars) : null,
215
- uhc: data.stats.UHC ? new UHC(data.stats.UHC) : null,
216
- speeduhc: data.stats.SpeedUHC ? new SpeedUHC(data.stats.SpeedUHC) : null,
217
- murdermystery: data.stats.MurderMystery ? new MurderMystery(data.stats.MurderMystery) : null,
218
- duels: data.stats.Duels ? new Duels(data.stats.Duels) : null,
225
+ blitzsg: data.stats.HungerGames ? new BlitzSurvivalGames(data.stats.HungerGames) : null,
219
226
  buildbattle: data.stats.BuildBattle ? new BuildBattle(data.stats.BuildBattle) : null,
220
- megawalls: data.stats.Walls3 ? new MegaWalls(data.stats.Walls3) : null,
221
227
  copsandcrims: data.stats.MCGO ? new CopsAndCrims(data.stats.MCGO) : null,
222
- tntgames: data.stats.TNTGames ? new TNTGames(data.stats.TNTGames) : null,
223
- smashheroes: data.stats.SuperSmash ? new SmashHeroes(data.stats.SuperSmash) : null,
224
- vampirez: data.stats.VampireZ ? new VampireZ(data.stats.VampireZ) : null,
225
- blitzsg: data.stats.HungerGames ? new BlitzSurvivalGames(data.stats.HungerGames) : null,
226
- arena: data.stats.Arena ? new ArenaBrawl(data.stats.Arena) : null,
227
- arcade: data.stats.Arcade ? new Arcade({ ...data.stats.Arcade, ...data.achievements }) : null,
228
+ duels: data.stats.Duels ? new Duels(data.stats.Duels) : null,
229
+ megawalls: data.stats.Walls3 ? new MegaWalls(data.stats.Walls3) : null,
230
+ murdermystery: data.stats.MurderMystery ? new MurderMystery(data.stats.MurderMystery) : null,
228
231
  paintball: data.stats.Paintball ? new Paintball(data.stats.Paintball) : null,
232
+ pit: data.stats.Pit ? new Pit(data.stats.Pit) : null,
229
233
  quakecraft: data.stats.Quake ? new Quakecraft(data.stats.Quake) : null,
234
+ skywars: data.stats.SkyWars ? new SkyWars(data.stats.SkyWars) : null,
235
+ smashheroes: data.stats.SuperSmash ? new SmashHeroes(data.stats.SuperSmash) : null,
236
+ speeduhc: data.stats.SpeedUHC ? new SpeedUHC(data.stats.SpeedUHC) : null,
237
+ tntgames: data.stats.TNTGames ? new TNTGames(data.stats.TNTGames) : null,
230
238
  turbokartracers: data.stats.GingerBread ? new TurboKartRacers(data.stats.GingerBread) : null,
239
+ uhc: data.stats.UHC ? new UHC(data.stats.UHC) : null,
240
+ vampirez: data.stats.VampireZ ? new VampireZ(data.stats.VampireZ) : null,
231
241
  walls: data.stats.Walls ? new Walls(data.stats.Walls) : null,
232
242
  warlords: data.stats.Battleground ? new Warlords(data.stats.Battleground) : null,
233
- woolwars: data.stats.WoolGames ? new WoolWars(data.stats.WoolGames) : null,
234
- pit: data.stats.Pit ? new Pit(data.stats.Pit) : null
243
+ woolwars: data.stats.WoolGames ? new WoolWars(data.stats.WoolGames) : null
235
244
  }
236
245
  : null;
237
246
  /**
@@ -249,7 +258,7 @@ class Player {
249
258
  * Global Cosmetics a player owns
250
259
  * @type {PlayerCosmetics}
251
260
  */
252
- this.globalCosmetics = new PlayerCosmetics(data) || null;
261
+ this.globalCosmetics = data ? new PlayerCosmetics(data) : null;
253
262
  /**
254
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
255
264
  * @type {RanksPurchaseTime}
@@ -269,106 +278,6 @@ class Player {
269
278
  return this.nickname;
270
279
  }
271
280
  }
272
-
273
- // eslint-disable-next-line require-jsdoc
274
- function getRank(player) {
275
- let rank;
276
- if (player.prefix) {
277
- rank = player.prefix.replace(/§[0-9|a-z]|\[|\]/g, '');
278
- } else if (player.rank && player.rank !== 'NORMAL') {
279
- switch (player.rank) {
280
- case 'YOUTUBER':
281
- rank = 'YouTube';
282
- break;
283
- case 'GAME_MASTER':
284
- rank = 'Game Master';
285
- break;
286
- case 'ADMIN':
287
- rank = 'Admin';
288
- break;
289
- }
290
- } else {
291
- switch (player.newPackageRank) {
292
- case 'MVP_PLUS':
293
- rank = player.monthlyPackageRank && player.monthlyPackageRank === 'SUPERSTAR' ? 'MVP++' : 'MVP+';
294
- break;
295
- case 'MVP':
296
- rank = 'MVP';
297
- break;
298
- case 'VIP_PLUS':
299
- rank = 'VIP+';
300
- break;
301
- case 'VIP':
302
- rank = 'VIP';
303
- break;
304
- default:
305
- rank = player.monthlyPackageRank && player.monthlyPackageRank === 'SUPERSTAR' ? 'MVP++' : 'Default';
306
- }
307
- }
308
- return rank;
309
- }
310
- // eslint-disable-next-line require-jsdoc
311
- function getPlayerLevel(exp) {
312
- const base = 10000;
313
- const growth = 2500;
314
- const reversePqPrefix = -(base - 0.5 * growth) / growth;
315
- const reverseConst = reversePqPrefix * reversePqPrefix;
316
- const growthDivides2 = 2 / growth;
317
- const num = 1 + reversePqPrefix + Math.sqrt(reverseConst + growthDivides2 * exp);
318
- const level = Math.round(num * 100) / 100;
319
- return level;
320
- }
321
- // eslint-disable-next-line require-jsdoc
322
- function xpToNextLevel(player) {
323
- const lvl = getPlayerLevel(player.networkExp);
324
- const xpToNext = 2500 * Math.floor(lvl) + 5000;
325
- if (player.networkExp < 10000) return 10000;
326
- return xpToNext;
327
- }
328
- // eslint-disable-next-line require-jsdoc
329
- function levelToXP(player) {
330
- let level = Number(Math.floor(getPlayerLevel(player.networkExp)));
331
- level = level - 1;
332
- const xp = 1250 * level ** 2 + 8750 * level;
333
- return xp;
334
- }
335
- // eslint-disable-next-line require-jsdoc
336
- function playerLevelProgress(player) {
337
- const xpFromLevel = levelToXP(player);
338
- let currentXP = player.networkExp - xpFromLevel;
339
- const xpToNext = xpToNextLevel(player);
340
- const remainingXP = xpToNext - currentXP + 2500;
341
- currentXP = currentXP - 2500;
342
- const percent = Math.round((currentXP / xpToNext) * 100 * 100) / 100;
343
- const percentRemaining = Math.round((100 - percent) * 100) / 100;
344
- return {
345
- xpToNext,
346
- remainingXP,
347
- currentXP,
348
- percent,
349
- percentRemaining
350
- };
351
- }
352
- // eslint-disable-next-line require-jsdoc
353
- function getSocialMedia(data) {
354
- if (!data) return null;
355
- const links = data.links;
356
- const formattedNames = ['Twitter', 'YouTube', 'Instagram', 'Twitch', 'Hypixel', 'Discord'];
357
- const upperNames = ['TWITTER', 'YOUTUBE', 'INSTAGRAM', 'TWITCH', 'HYPIXEL', 'DISCORD'];
358
- if (!links) return null;
359
- return Object.keys(links)
360
- .map((x) => upperNames.indexOf(x))
361
- .filter((x) => x !== -1)
362
- .map((x) => ({ name: formattedNames[x], link: links[upperNames[x]], id: upperNames[x] }));
363
- }
364
- // eslint-disable-next-line require-jsdoc
365
- function parseClaimedRewards(data) {
366
- if (!data) return null;
367
- return Object.keys(data)
368
- .map((x) => x.match(/levelingReward_(\d+)/))
369
- .filter((x) => x)
370
- .map((x) => parseInt(x[1], 10));
371
- }
372
281
  /**
373
282
  * @typedef {string} PlayerRank
374
283
  * * `Default`
@@ -393,21 +302,27 @@ function parseClaimedRewards(data) {
393
302
  * Player stats for each mini-game. `null` if player has no stats.
394
303
  * <br>
395
304
  * Usage: `<Player>.stats.skywars`
396
- * @property {SkyWars|null} skywars SkyWars
305
+ * @property {Arcade|null} arcade Arcade
306
+ * @property {ArenaBrawl|null} arena Arena Brawl
397
307
  * @property {BedWars|null} bedwars BedWars
398
- * @property {UHC|null} uhc UHC
399
- * @property {SpeedUHC|null} speedUHC Speed UHC
400
- * @property {MurderMystery|null} murdermystery Murder Mystery
401
- * @property {Duels|null} duels Duels
308
+ * @property {BlitzSurvivalGames|null} blitzsg Blitz Survival Games
402
309
  * @property {BuildBattle|null} buildbattle BuildBattle
403
- * @property {MegaWalls|null} megawalls MegaWalls
404
310
  * @property {CopsAndCrims|null} copsandcrims Cops and Crims
405
- * @property {TNTGames|null} tntgames The TNT Games
311
+ * @property {Duels|null} duels Duels
312
+ * @property {MegaWalls|null} megawalls MegaWalls
313
+ * @property {MurderMystery|null} murdermystery Murder Mystery
314
+ * @property {Paintball|null} paintball Paint Ball
315
+ * @property {Pit|null} pit Pit
316
+ * @property {Quakecraft|null} quakecraft Quake Craft
317
+ * @property {SkyWars|null} skywars SkyWars
406
318
  * @property {SmashHeroes|null} smashheroes Smash Heroes
319
+ * @property {SpeedUHC|null} speedUHC Speed UHC
320
+ * @property {TNTGames|null} tntgames The TNT Games
321
+ * @property {TurboKartRacers|null} turbokartracers Turbo Kart Racers
322
+ * @property {UHC|null} uhc UHC
407
323
  * @property {VampireZ|null} vampirez VampireZ
408
- * @property {BlitzSurvivalGames|null} blitzsg Blitz Survival Games
409
- * @property {ArenaBrawl|null} arena Arena Brawl
410
- * @property {Arcade|null} arcade Arcade
324
+ * @property {Walls|null} walls Walls
325
+ * @property {Warlords|null} warlords Warlords
411
326
  * @property {WoolWars|null} woolwars Wool Wars
412
327
  */
413
328
  /**
@@ -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
  */
@@ -113,14 +114,14 @@ class PlayerCosmetics {
113
114
  * @type {string[]}
114
115
  */
115
116
  get rankColors() {
116
- if (!this._rankcolors) {
117
- this._rankcolors = this.allCosmetics
117
+ if (!this._rankColors) {
118
+ this._rankColors = this.allCosmetics
118
119
  ? this.allCosmetics
119
120
  .filter((x) => x.startsWith('rankcolor_'))
120
121
  .map((x) => removeSnakeCaseString(x.replace('rankcolor_', ''))) || []
121
122
  : [];
122
123
  }
123
- return this._rankcolors;
124
+ return this._rankColors;
124
125
  }
125
126
  /**
126
127
  * Particle Packs
@@ -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
 
@@ -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
@@ -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;
@@ -1,6 +1,11 @@
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');
1
6
  /**
2
- * @typedef {require('./Static/BingoData.js')} BingoData
3
- * @typedef {require('./Static/Bingo.js')} Bingo
7
+ * @typedef {BingoDataType} BingoData
8
+ * @typedef {BingoType} Bingo
4
9
  */
5
10
 
6
11
  /**
@@ -33,18 +38,6 @@ class PlayerBingo {
33
38
  }
34
39
  }
35
40
 
36
- // eslint-disable-next-line require-jsdoc
37
- function populateGoals(achieved, all) {
38
- const populatedAchieved = [];
39
- const unachieved = [];
40
- for (const goal of all) {
41
- if (achieved.find((str) => str === goal.name)) populatedAchieved.push(goal);
42
- else unachieved.push(goal);
43
- }
44
- populatedAchieved.unachievedGoals = unachieved;
45
- return populatedAchieved;
46
- }
47
-
48
41
  /**
49
42
  * @typedef {Object} PlayerBingoDataPerEvent
50
43
  * @property {number} eventId ID of event
@@ -0,0 +1,146 @@
1
+ const { getLevelByXp } = require('../../utils/SkyblockUtils');
2
+
3
+ /**
4
+ * Skyblock Garden class
5
+ */
6
+ class SkyblockGarden {
7
+ /**
8
+ * @param {object} data Skyblock member data
9
+ */
10
+ constructor(data) {
11
+ /**
12
+ * level
13
+ * @type {SkyblockSkillLevel}
14
+ */
15
+ this.level = getLevelByXp(data?.garden?.garden_experience || 0, 'garden');
16
+ /**
17
+ * Current Barn Skin
18
+ * @type {string}
19
+ */
20
+ this.barnSkin = data.garden?.selected_barn_skin || '';
21
+ /**
22
+ * Unlocked Plots
23
+ * @type {string[]}
24
+ */
25
+ this.unlockedPlots = data.garden?.unlocked_plots_ids || [];
26
+ /**
27
+ * Visitor Stats
28
+ * @type {SkyblockGardenVisitor}
29
+ */
30
+ this.visitors = {
31
+ visited: data.garden?.commission_data?.visits || {},
32
+ completed: data.garden?.commission_data?.completed || {},
33
+ served: {
34
+ total: data.garden?.commission_data?.total_completed || 0,
35
+ unique: data.garden?.commission_data?.unique_npcs_served || 0
36
+ }
37
+ };
38
+ /**
39
+ * Crop Milestones
40
+ * @type {SkyblockGarenCropMilestones}
41
+ */
42
+ this.cropMilestones = {
43
+ wheat: getLevelByXp(data.garden?.resources_collected?.WHEAT || 0, 'wheat'),
44
+ carrot: getLevelByXp(data.garden?.resources_collected?.CARROT_ITEM || 0, 'carrot'),
45
+ sugarCane: getLevelByXp(data.garden?.resources_collected?.SUGAR_CANE || 0, 'sugarCane'),
46
+ potato: getLevelByXp(data.garden?.resources_collected?.POTATO_ITEM || 0, 'potato'),
47
+ pumpkin: getLevelByXp(data.garden?.resources_collected?.PUMPKIN || 0, 'pumpkin'),
48
+ melon: getLevelByXp(data.garden?.resources_collected?.MELON || 0, 'melon'),
49
+ cactus: getLevelByXp(data.garden?.resources_collected?.CACTUS || 0, 'cactus'),
50
+ cocoBeans: getLevelByXp(data.garden?.resources_collected?.['INK_SACK:3'] || 0, 'cocoBeans'),
51
+ mushroom: getLevelByXp(data.garden?.resources_collected?.MUSHROOM_COLLECTION || 0, 'mushroom'),
52
+ netherWart: getLevelByXp(data.garden?.resources_collected?.NETHER_STALK || 0, 'netherWart')
53
+ };
54
+ /**
55
+ * Composter
56
+ * @type {SkyblockGardenComposter}
57
+ */
58
+ this.composter = {
59
+ organicMatter: data.garden?.composter_data?.organic_matter || 0,
60
+ fuelUnits: data.garden?.composter_data?.fuel_units || 0,
61
+ compostUnits: data.garden?.composter_data?.compost_units || 0,
62
+ compostItems: data.garden?.composter_data?.compost_items || 0,
63
+ conversionTicks: data.garden?.composter_data?.conversion_ticks || 0,
64
+ upgrades: {
65
+ speed: data.garden?.composter_data?.upgrades?.speed || 0,
66
+ multiDrop: data.garden?.composter_data?.upgrades?.multi_drop || 0,
67
+ fuelCap: data.garden?.composter_data?.upgrades?.fuel_cap || 0,
68
+ organicMatterCap: data.garden?.composter_data?.upgrades?.organic_matter_cap || 0,
69
+ costReduction: data.garden?.composter_data?.upgrades?.cost_reduction || 0
70
+ }
71
+ };
72
+ /**
73
+ * Crop Upgrades
74
+ * @type {SkyblockGarenCrops}
75
+ */
76
+ this.cropUpgrades = {
77
+ wheat: data.garden?.crop_upgrade_levels?.WHEAT || 0,
78
+ carrot: data.garden?.crop_upgrade_levels?.CARROT_ITEM || 0,
79
+ sugarCane: data.garden?.crop_upgrade_levels?.SUGAR_CANE || 0,
80
+ potato: data.garden?.crop_upgrade_levels?.POTATO_ITEM || 0,
81
+ pumpkin: data.garden?.crop_upgrade_levels?.PUMPKIN || 0,
82
+ melon: data.garden?.crop_upgrade_levels?.MELON || 0,
83
+ cactus: data.garden?.crop_upgrade_levels?.CACTUS || 0,
84
+ cocoBeans: data.garden?.crop_upgrade_levels?.['INK_SACK:3'] || 0,
85
+ mushroom: data.garden?.crop_upgrade_levels?.MUSHROOM_COLLECTION || 0,
86
+ netherWart: data.garden?.crop_upgrade_levels?.NETHER_STALK || 0
87
+ };
88
+ }
89
+ }
90
+
91
+ /**
92
+ * @typedef {object} SkyblockGardenVisitor
93
+ * @property {Record<string, number>} visited Visited
94
+ * @property {Record<string, number>} completed Completed
95
+ * @property {SkyblockGardenVisitorServed} served served
96
+ */
97
+ /**
98
+ * @typedef {object} SkyblockGardenVisitorServed
99
+ * @property {number} total total
100
+ * @property {number} unique unique
101
+ */
102
+ /**
103
+ * @typedef {object} SkyblockGardenComposter
104
+ * @property {number} organicMatter Organic Matter
105
+ * @property {number} fuelUnits Fuel Units
106
+ * @property {number} compostUnits Compost Units
107
+ * @property {number} compostItems Compost Items
108
+ * @property {number} conversionTicks Conversion Ticks
109
+ * @property {SkyblockGardenComposterUpgrades} upgrades upgrades
110
+ */
111
+ /**
112
+ * @typedef {object} SkyblockGardenComposterUpgrades
113
+ * @property {number} speed Speed
114
+ * @property {number} multiDrop Multi Drop
115
+ * @property {number} fuelCap Fuel Cap
116
+ * @property {number} organicMatterCap Organic Matter Cap
117
+ * @property {number} costReduction Cost Reduction
118
+ */
119
+ /**
120
+ * @typedef {object} SkyblockGarenCrops
121
+ * @property {number} wheat Wheat
122
+ * @property {number} carrot Carrot
123
+ * @property {number} sugarCane Sugar Cane
124
+ * @property {number} potato Potato
125
+ * @property {number} pumpkin Pumpkin
126
+ * @property {number} melon Melon
127
+ * @property {number} cactus Cactus
128
+ * @property {number} cocoBeans Coco Beans
129
+ * @property {number} mushroom Mushroom
130
+ * @property {number} netherWart Nether Wart
131
+ */
132
+ /**
133
+ * @typedef {object} SkyblockGarenCropMilestones
134
+ * @property {SkyblockSkillLevel} wheat Wheat
135
+ * @property {SkyblockSkillLevel} carrot Carrot
136
+ * @property {SkyblockSkillLevel} sugarCane Sugar Cane
137
+ * @property {SkyblockSkillLevel} potato Potato
138
+ * @property {SkyblockSkillLevel} pumpkin Pumpkin
139
+ * @property {SkyblockSkillLevel} melon Melon
140
+ * @property {SkyblockSkillLevel} cactus Cactus
141
+ * @property {SkyblockSkillLevel} cocoBeans Coco Beans
142
+ * @property {SkyblockSkillLevel} mushroom Mushroom
143
+ * @property {SkyblockSkillLevel} netherWart Nether Wart
144
+ */
145
+
146
+ module.exports = SkyblockGarden;