hypixel-api-reborn 10.0.0 → 11.0.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.
- package/.prettierrc +13 -0
- package/README.md +28 -16
- package/package.json +60 -58
- package/src/API/getAPIStatus.js +8 -8
- package/src/API/getBoosters.js +6 -6
- package/src/API/getGameCounts.js +6 -6
- package/src/API/getGuild.js +18 -18
- package/src/API/getLeaderboards.js +13 -13
- package/src/API/getPlayer.js +22 -27
- package/src/API/getRecentGames.js +18 -18
- package/src/API/getServerInfo.js +66 -77
- package/src/API/getStatus.js +8 -8
- package/src/API/getWatchdogStats.js +6 -6
- package/src/API/index.js +19 -23
- package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -10
- package/src/API/skyblock/getSkyblockAuctions.js +64 -64
- package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -11
- package/src/API/skyblock/getSkyblockBazaar.js +10 -10
- package/src/API/skyblock/getSkyblockMember.js +28 -25
- package/src/API/skyblock/getSkyblockNews.js +6 -6
- package/src/API/skyblock/getSkyblockProfiles.js +44 -41
- package/src/Client.js +406 -450
- package/src/Errors.js +44 -39
- package/src/Private/defaultCache.js +77 -78
- package/src/Private/rateLimit.js +79 -98
- package/src/Private/requests.js +65 -54
- package/src/Private/updater.js +45 -45
- package/src/Private/uuidCache.js +37 -33
- package/src/Private/validate.js +97 -97
- package/src/index.js +82 -83
- package/src/structures/APIIncident.js +78 -78
- package/src/structures/APIStatus.js +47 -47
- package/src/structures/Boosters/Booster.js +83 -87
- package/src/structures/Color.js +129 -129
- package/src/structures/Game.js +164 -160
- package/src/structures/GameCounts.js +151 -151
- package/src/structures/Guild/Guild.js +204 -218
- package/src/structures/Guild/GuildMember.js +66 -66
- package/src/structures/Guild/GuildRank.js +48 -48
- package/src/structures/ItemBytes.js +33 -36
- package/src/structures/Leaderboard.js +31 -31
- package/src/structures/MiniGames/Arcade.js +567 -569
- package/src/structures/MiniGames/ArenaBrawl.js +52 -56
- package/src/structures/MiniGames/BedWars.js +423 -351
- package/src/structures/MiniGames/BlitzSurvivalGames.js +172 -148
- package/src/structures/MiniGames/BuildBattle.js +53 -53
- package/src/structures/MiniGames/CopsAndCrims.js +90 -90
- package/src/structures/MiniGames/Duels.js +694 -630
- package/src/structures/MiniGames/MegaWalls.js +137 -137
- package/src/structures/MiniGames/MurderMystery.js +93 -93
- package/src/structures/MiniGames/Paintball.js +67 -67
- package/src/structures/MiniGames/Pit.js +19 -19
- package/src/structures/MiniGames/Quakecraft.js +101 -101
- package/src/structures/MiniGames/SkyWars.js +508 -559
- package/src/structures/MiniGames/SmashHeroes.js +144 -151
- package/src/structures/MiniGames/SpeedUHC.js +115 -57
- package/src/structures/MiniGames/TNTGames.js +116 -116
- package/src/structures/MiniGames/TurboKartRacers.js +201 -176
- package/src/structures/MiniGames/UHC.js +164 -143
- package/src/structures/MiniGames/VampireZ.js +60 -60
- package/src/structures/MiniGames/Walls.js +52 -52
- package/src/structures/MiniGames/Warlords.js +62 -62
- package/src/structures/MiniGames/WoolWars.js +123 -0
- package/src/structures/Pet.js +96 -97
- package/src/structures/Pets.js +64 -64
- package/src/structures/Player.js +433 -449
- package/src/structures/PlayerCosmetics.js +100 -95
- package/src/structures/RecentGame.js +57 -57
- package/src/structures/ServerInfo.js +78 -78
- package/src/structures/SkyBlock/Auctions/Auction.js +104 -104
- package/src/structures/SkyBlock/Auctions/AuctionInfo.js +54 -54
- package/src/structures/SkyBlock/Auctions/BaseAuction.js +45 -45
- package/src/structures/SkyBlock/Auctions/Bid.js +48 -48
- package/src/structures/SkyBlock/Auctions/PartialAuction.js +25 -25
- package/src/structures/SkyBlock/Bazzar/Order.js +38 -38
- package/src/structures/SkyBlock/Bazzar/Product.js +53 -53
- package/src/structures/SkyBlock/News/SkyblockNews.js +60 -68
- package/src/structures/SkyBlock/SkyblockInventoryItem.js +124 -130
- package/src/structures/SkyBlock/SkyblockMember.js +820 -687
- package/src/structures/SkyBlock/SkyblockPet.js +71 -71
- package/src/structures/SkyBlock/SkyblockProfile.js +60 -60
- package/src/structures/Status.js +41 -41
- package/src/structures/Watchdog/Stats.js +36 -36
- package/src/utils/Constants.js +2789 -809
- package/src/utils/SkyblockUtils.js +208 -164
- package/src/utils/arrayTools.js +4 -4
- package/src/utils/divide.js +5 -5
- package/src/utils/guildExp.js +57 -67
- package/src/utils/index.js +13 -13
- package/src/utils/isGuildID.js +3 -3
- package/src/utils/isUUID.js +5 -5
- package/src/utils/oscillation.js +15 -23
- package/src/utils/removeSnakeCase.js +22 -35
- package/src/utils/rgbToHexColor.js +8 -8
- package/src/utils/romanize.js +11 -13
- package/src/utils/toIGN.js +20 -20
- package/src/utils/toUuid.js +19 -19
- package/src/utils/varInt.js +17 -21
- package/typings/index.d.ts +3532 -2644
- package/src/API/getFriends.js +0 -14
- package/src/API/getKeyInfo.js +0 -10
- package/src/API/getRankedSkyWars.js +0 -11
- package/src/structures/Friend.js +0 -38
- package/src/structures/KeyInfo.js +0 -42
- package/src/structures/MiniGames/SkyWarsRanked.js +0 -45
package/src/structures/Player.js
CHANGED
|
@@ -1,449 +1,433 @@
|
|
|
1
|
-
const SkyWars = require('./MiniGames/SkyWars');
|
|
2
|
-
const BedWars = require('./MiniGames/BedWars');
|
|
3
|
-
const UHC = require('./MiniGames/UHC');
|
|
4
|
-
const SpeedUHC = require('./MiniGames/SpeedUHC');
|
|
5
|
-
const MurderMystery = require('./MiniGames/MurderMystery');
|
|
6
|
-
const Duels = require('./MiniGames/Duels');
|
|
7
|
-
const BuildBattle = require('./MiniGames/BuildBattle');
|
|
8
|
-
const MegaWalls = require('./MiniGames/MegaWalls');
|
|
9
|
-
const CopsAndCrims = require('./MiniGames/CopsAndCrims');
|
|
10
|
-
const TNTGames = require('./MiniGames/TNTGames');
|
|
11
|
-
const SmashHeroes = require('./MiniGames/SmashHeroes');
|
|
12
|
-
const VampireZ = require('./MiniGames/VampireZ');
|
|
13
|
-
const BlitzSurvivalGames = require('./MiniGames/BlitzSurvivalGames');
|
|
14
|
-
const ArenaBrawl = require('./MiniGames/ArenaBrawl');
|
|
15
|
-
const Arcade = require('./MiniGames/Arcade');
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
-
const Pit = require('./MiniGames/Pit');
|
|
18
|
-
const Color = require('./Color');
|
|
19
|
-
const Game = require('./Game');
|
|
20
|
-
const PlayerCosmetics = require('./PlayerCosmetics');
|
|
21
|
-
const { recursive } = require('../utils/removeSnakeCase');
|
|
22
|
-
const TurboKartRacers = require('./MiniGames/TurboKartRacers');
|
|
23
|
-
const Paintball = require('./MiniGames/Paintball');
|
|
24
|
-
const Quakecraft = require('./MiniGames/Quakecraft');
|
|
25
|
-
const Walls = require('./MiniGames/Walls');
|
|
26
|
-
const Warlords = require('./MiniGames/Warlords');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @param {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
*
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
*
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
*
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
*
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
*
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
*
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
*
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
*
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
*
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
*
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
*
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
const
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const
|
|
349
|
-
return
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
return
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*/
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
* @
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
* @
|
|
407
|
-
*
|
|
408
|
-
* @property {
|
|
409
|
-
* @property {
|
|
410
|
-
* @property {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
* @
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
* @
|
|
419
|
-
*
|
|
420
|
-
* @property {
|
|
421
|
-
* @property {
|
|
422
|
-
* @property {
|
|
423
|
-
* @property {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
* @
|
|
427
|
-
* @property {
|
|
428
|
-
* @property {
|
|
429
|
-
* @property {
|
|
430
|
-
* @property {
|
|
431
|
-
* @property {
|
|
432
|
-
*/
|
|
433
|
-
|
|
434
|
-
* @typedef {Object} RanksPurchaseTime
|
|
435
|
-
* Time at which ranks were purchased. Beware, even if a player has MVP+(+), every value here *could* be null
|
|
436
|
-
* @property {Date|null} VIP VIP rank
|
|
437
|
-
* @property {Date|null} VIP_PLUS VIP+ rank
|
|
438
|
-
* @property {Date|null} MVP MVP rank
|
|
439
|
-
* @property {Date|null} MVP_PLUS MVP+ rank
|
|
440
|
-
*/
|
|
441
|
-
/**
|
|
442
|
-
* @typedef {Object} LevelProgress
|
|
443
|
-
* @property {number} xpToNext Total XP to a player's next level.
|
|
444
|
-
* @property {number} remainingXP XP to the player's next level.
|
|
445
|
-
* @property {number} currentXP XP the player current has.
|
|
446
|
-
* @property {number} percent Player level progress as a percentage.
|
|
447
|
-
* @property {number} percentRemaining Remaining percentage of the percent value.
|
|
448
|
-
*/
|
|
449
|
-
module.exports = Player;
|
|
1
|
+
const SkyWars = require('./MiniGames/SkyWars');
|
|
2
|
+
const BedWars = require('./MiniGames/BedWars');
|
|
3
|
+
const UHC = require('./MiniGames/UHC');
|
|
4
|
+
const SpeedUHC = require('./MiniGames/SpeedUHC');
|
|
5
|
+
const MurderMystery = require('./MiniGames/MurderMystery');
|
|
6
|
+
const Duels = require('./MiniGames/Duels');
|
|
7
|
+
const BuildBattle = require('./MiniGames/BuildBattle');
|
|
8
|
+
const MegaWalls = require('./MiniGames/MegaWalls');
|
|
9
|
+
const CopsAndCrims = require('./MiniGames/CopsAndCrims');
|
|
10
|
+
const TNTGames = require('./MiniGames/TNTGames');
|
|
11
|
+
const SmashHeroes = require('./MiniGames/SmashHeroes');
|
|
12
|
+
const VampireZ = require('./MiniGames/VampireZ');
|
|
13
|
+
const BlitzSurvivalGames = require('./MiniGames/BlitzSurvivalGames');
|
|
14
|
+
const ArenaBrawl = require('./MiniGames/ArenaBrawl');
|
|
15
|
+
const Arcade = require('./MiniGames/Arcade');
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
+
const Pit = require('./MiniGames/Pit');
|
|
18
|
+
const Color = require('./Color');
|
|
19
|
+
const Game = require('./Game');
|
|
20
|
+
const PlayerCosmetics = require('./PlayerCosmetics');
|
|
21
|
+
const { recursive } = require('../utils/removeSnakeCase');
|
|
22
|
+
const TurboKartRacers = require('./MiniGames/TurboKartRacers');
|
|
23
|
+
const Paintball = require('./MiniGames/Paintball');
|
|
24
|
+
const Quakecraft = require('./MiniGames/Quakecraft');
|
|
25
|
+
const Walls = require('./MiniGames/Walls');
|
|
26
|
+
const Warlords = require('./MiniGames/Warlords');
|
|
27
|
+
const WoolWars = require('./MiniGames/WoolWars');
|
|
28
|
+
/**
|
|
29
|
+
* Player class
|
|
30
|
+
*/
|
|
31
|
+
class Player {
|
|
32
|
+
/**
|
|
33
|
+
* @param {object} data Player data
|
|
34
|
+
* @param {Record<string, any>} extraPayload extra data requested alongside player
|
|
35
|
+
*/
|
|
36
|
+
constructor(data, extraPayload) {
|
|
37
|
+
/**
|
|
38
|
+
* Player nickname
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
this.nickname = data.displayname;
|
|
42
|
+
/**
|
|
43
|
+
* Player UUID
|
|
44
|
+
* @type {string}
|
|
45
|
+
*/
|
|
46
|
+
this.uuid = data.uuid;
|
|
47
|
+
/**
|
|
48
|
+
* Player nickname history known to Hypixel
|
|
49
|
+
* @type {Array<string>}
|
|
50
|
+
*/
|
|
51
|
+
this.history = data.knownAliases;
|
|
52
|
+
/**
|
|
53
|
+
* Player rank
|
|
54
|
+
* @type {PlayerRank}
|
|
55
|
+
*/
|
|
56
|
+
this.rank = getRank(data);
|
|
57
|
+
/**
|
|
58
|
+
* Player minecraft version
|
|
59
|
+
* @type {string|null}
|
|
60
|
+
*/
|
|
61
|
+
this.mcVersion = data.mcVersionRp || null;
|
|
62
|
+
/**
|
|
63
|
+
* Current chat channel, usually ALL, PARTY, or GUILD
|
|
64
|
+
* @type {string|null}
|
|
65
|
+
*/
|
|
66
|
+
this.channel = data.channel || null;
|
|
67
|
+
/**
|
|
68
|
+
* Timestamp when player last logged in
|
|
69
|
+
* @type {number|null}
|
|
70
|
+
*/
|
|
71
|
+
this.firstLoginTimestamp = data.firstLogin || null;
|
|
72
|
+
/**
|
|
73
|
+
* Timestamp when player last logged in as Date
|
|
74
|
+
* @type {Date|null}
|
|
75
|
+
*/
|
|
76
|
+
this.firstLogin = data.firstLogin ? new Date(data.firstLogin) : null;
|
|
77
|
+
/**
|
|
78
|
+
* Player's recently played game
|
|
79
|
+
* @type {Game|null}
|
|
80
|
+
*/
|
|
81
|
+
this.lastLoginTimestamp = data.lastLogin || null;
|
|
82
|
+
/**
|
|
83
|
+
* Timestamp when player first logged in
|
|
84
|
+
* @type {number|null}
|
|
85
|
+
*/
|
|
86
|
+
this.lastLogin = data.lastLogin ? new Date(data.lastLogin) : null;
|
|
87
|
+
/**
|
|
88
|
+
* Timestamp when player last logged out as Date
|
|
89
|
+
* @type {Date|null}
|
|
90
|
+
*/
|
|
91
|
+
this.lastLogoutTimestamp = data.lastLogout || null;
|
|
92
|
+
/**
|
|
93
|
+
* Timestamp when player first logged in as Date
|
|
94
|
+
* @type {Date|null}
|
|
95
|
+
*/
|
|
96
|
+
this.lastLogout = data.lastLogout ? new Date(data.lastLogout) : null;
|
|
97
|
+
/**
|
|
98
|
+
* Recently played game
|
|
99
|
+
* @type {Game|null}
|
|
100
|
+
*/
|
|
101
|
+
this.recentlyPlayedGame = data.mostRecentGameType ? new Game(data.mostRecentGameType) : null;
|
|
102
|
+
/**
|
|
103
|
+
* Player's plus color (must be a MVP+ rank)
|
|
104
|
+
* @type {Color|null}
|
|
105
|
+
*/
|
|
106
|
+
this.plusColor = this.rank === 'MVP+' || this.rank === 'MVP++' ? (data.rankPlusColor ? new Color(data.rankPlusColor) : new Color('RED')) : null;
|
|
107
|
+
/**
|
|
108
|
+
* MVP++ prefix color
|
|
109
|
+
* @type {Color|null}
|
|
110
|
+
*/
|
|
111
|
+
this.prefixColor = this.rank === 'MVP++' ? (data.monthlyRankColor ? new Color(data.monthlyRankColor) : new Color('GOLD')) : null;
|
|
112
|
+
/**
|
|
113
|
+
* Player karma
|
|
114
|
+
* @type {number}
|
|
115
|
+
*/
|
|
116
|
+
this.karma = data.karma || 0;
|
|
117
|
+
/**
|
|
118
|
+
* Player achievements
|
|
119
|
+
* @type {Object}
|
|
120
|
+
*/
|
|
121
|
+
this.achievements = recursive(data.achievements);
|
|
122
|
+
/**
|
|
123
|
+
* Player achievement points
|
|
124
|
+
* @type {number}
|
|
125
|
+
*/
|
|
126
|
+
this.achievementPoints = data.achievementPoints || 0;
|
|
127
|
+
/**
|
|
128
|
+
* Player total experience
|
|
129
|
+
* @type {number}
|
|
130
|
+
*/
|
|
131
|
+
this.totalExperience = data.networkExp || 0;
|
|
132
|
+
/**
|
|
133
|
+
* Player level
|
|
134
|
+
* @type {number}
|
|
135
|
+
*/
|
|
136
|
+
this.level = getPlayerLevel(this.totalExperience) || 0;
|
|
137
|
+
/**
|
|
138
|
+
* Player social media, if any
|
|
139
|
+
* @type {Array<PlayerSocialMedia>}
|
|
140
|
+
*/
|
|
141
|
+
this.socialMedia = getSocialMedia(data.socialMedia) || [];
|
|
142
|
+
/**
|
|
143
|
+
* Amount of gift bundles sent
|
|
144
|
+
* @type {number}
|
|
145
|
+
*/
|
|
146
|
+
this.giftBundlesSent = data.giftingMeta ? data.giftingMeta.realBundlesGiven || 0 : null;
|
|
147
|
+
/**
|
|
148
|
+
* Amount of gift bundles received
|
|
149
|
+
* @type {number}
|
|
150
|
+
*/
|
|
151
|
+
this.giftBundlesReceived = data.giftingMeta ? data.giftingMeta.realBundlesReceived || 0 : null;
|
|
152
|
+
/**
|
|
153
|
+
* Amount of gifts sent
|
|
154
|
+
* @type {number}
|
|
155
|
+
*/
|
|
156
|
+
this.giftsSent = data.giftingMeta ? data.giftingMeta.giftsGiven || 0 : null;
|
|
157
|
+
/**
|
|
158
|
+
* Is player online?
|
|
159
|
+
* @type {boolean}
|
|
160
|
+
*/
|
|
161
|
+
this.isOnline = this.lastLoginTimestamp > this.lastLogoutTimestamp;
|
|
162
|
+
/**
|
|
163
|
+
* Last time player claimed the daily reward
|
|
164
|
+
* @type {Date | null}
|
|
165
|
+
*/
|
|
166
|
+
this.lastDailyReward = new Date(data.lastAdsenseGenerateTime) || null;
|
|
167
|
+
/**
|
|
168
|
+
* Last time player claimed the daily reward, as timestamp
|
|
169
|
+
* @type {number | null}
|
|
170
|
+
*/
|
|
171
|
+
this.lastDailyRewardTimestamp = data.lastAdsenseGenerateTime || null;
|
|
172
|
+
/**
|
|
173
|
+
* Total amount of Daily Rewards
|
|
174
|
+
* @type {number | null}
|
|
175
|
+
*/
|
|
176
|
+
this.totalRewards = data.totalRewards || null;
|
|
177
|
+
/**
|
|
178
|
+
* Total amount of Daily Rewards claimed
|
|
179
|
+
* @type {number | null}
|
|
180
|
+
*/
|
|
181
|
+
this.totalDailyRewards = data.totalDailyRewards || null;
|
|
182
|
+
/**
|
|
183
|
+
* Honestly no clue what this is specifically
|
|
184
|
+
* @type {number | null}
|
|
185
|
+
*/
|
|
186
|
+
this.rewardStreak = data.rewardStreak || null;
|
|
187
|
+
/**
|
|
188
|
+
* Current Daily Rewards streak
|
|
189
|
+
* @type {number | null}
|
|
190
|
+
*/
|
|
191
|
+
this.rewardScore = data.rewardScore || null;
|
|
192
|
+
/**
|
|
193
|
+
* Highest Daily Rewards streak
|
|
194
|
+
* @type {number | null}
|
|
195
|
+
*/
|
|
196
|
+
this.rewardHighScore = data.rewardHighScore || null;
|
|
197
|
+
/**
|
|
198
|
+
* Player leveling progress.
|
|
199
|
+
* @type {LevelProgress}
|
|
200
|
+
*/
|
|
201
|
+
this.levelProgress = playerLevelProgress(data);
|
|
202
|
+
/**
|
|
203
|
+
* Player's Guild if requested in options
|
|
204
|
+
* @type {Guild|null}
|
|
205
|
+
*/
|
|
206
|
+
this.guild = extraPayload?.guild || null;
|
|
207
|
+
/**
|
|
208
|
+
* Recent Games if requested in options
|
|
209
|
+
* @type {RecentGame[]|null}
|
|
210
|
+
*/
|
|
211
|
+
this.recentGames = extraPayload?.recentGames || null;
|
|
212
|
+
/**
|
|
213
|
+
* Player stats for each mini-game
|
|
214
|
+
* @type {PlayerStats}
|
|
215
|
+
*/
|
|
216
|
+
this.stats = data.stats
|
|
217
|
+
? {
|
|
218
|
+
skywars: data.stats.SkyWars ? new SkyWars(data.stats.SkyWars) : null,
|
|
219
|
+
bedwars: data.stats.Bedwars ? new BedWars(data.stats.Bedwars) : null,
|
|
220
|
+
uhc: data.stats.UHC ? new UHC(data.stats.UHC) : null,
|
|
221
|
+
speeduhc: data.stats.SpeedUHC ? new SpeedUHC(data.stats.SpeedUHC) : null,
|
|
222
|
+
murdermystery: data.stats.MurderMystery ? new MurderMystery(data.stats.MurderMystery) : null,
|
|
223
|
+
duels: data.stats.Duels ? new Duels(data.stats.Duels) : null,
|
|
224
|
+
buildbattle: data.stats.BuildBattle ? new BuildBattle(data.stats.BuildBattle) : null,
|
|
225
|
+
megawalls: data.stats.Walls3 ? new MegaWalls(data.stats.Walls3) : null,
|
|
226
|
+
copsandcrims: data.stats.MCGO ? new CopsAndCrims(data.stats.MCGO) : null,
|
|
227
|
+
tntgames: data.stats.TNTGames ? new TNTGames(data.stats.TNTGames) : null,
|
|
228
|
+
smashheroes: data.stats.SuperSmash ? new SmashHeroes(data.stats.SuperSmash) : null,
|
|
229
|
+
vampirez: data.stats.VampireZ ? new VampireZ(data.stats.VampireZ) : null,
|
|
230
|
+
blitzsg: data.stats.HungerGames ? new BlitzSurvivalGames(data.stats.HungerGames) : null,
|
|
231
|
+
arena: data.stats.Arena ? new ArenaBrawl(data.stats.Arena) : null,
|
|
232
|
+
arcade: data.stats.Arcade ? new Arcade({ ...data.stats.Arcade, ...data.achievements }) : null,
|
|
233
|
+
paintball: data.stats.Paintball ? new Paintball(data.stats.Paintball) : null,
|
|
234
|
+
quakecraft: data.stats.Quake ? new Quakecraft(data.stats.Quake) : null,
|
|
235
|
+
turbokartracers: data.stats.GingerBread ? new TurboKartRacers(data.stats.GingerBread) : null,
|
|
236
|
+
walls: data.stats.Walls ? new Walls(data.stats.Walls) : null,
|
|
237
|
+
warlords: data.stats.Battleground ? new Warlords(data.stats.Battleground) : null,
|
|
238
|
+
woolwars: data.stats.WoolGames ? new WoolWars(data.stats.WoolGames) : null,
|
|
239
|
+
pit: null
|
|
240
|
+
}
|
|
241
|
+
: null;
|
|
242
|
+
/**
|
|
243
|
+
* User's current language
|
|
244
|
+
* @type {string}
|
|
245
|
+
* @default ENGLISH Default to english
|
|
246
|
+
*/
|
|
247
|
+
this.userLanguage = data.userLanguage || 'ENGLISH';
|
|
248
|
+
/**
|
|
249
|
+
* Claimed Leveling Rewards
|
|
250
|
+
* @type {number[]}
|
|
251
|
+
*/
|
|
252
|
+
this.claimedLevelingRewards = parseClaimedRewards(data) || [];
|
|
253
|
+
/**
|
|
254
|
+
* Global Cosmetics a player owns
|
|
255
|
+
* @type {PlayerCosmetics}
|
|
256
|
+
*/
|
|
257
|
+
this.globalCosmetics = new PlayerCosmetics(data) || null;
|
|
258
|
+
/**
|
|
259
|
+
* 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
|
+
* @type {RanksPurchaseTime}
|
|
261
|
+
*/
|
|
262
|
+
this.ranksPurchaseTime = {
|
|
263
|
+
VIP: data.levelUp_VIP ? new Date(data.levelUp_VIP) : null,
|
|
264
|
+
VIP_PLUS: data.levelUp_VIP_PLUS ? new Date(data.levelUp_VIP_PLUS) : null,
|
|
265
|
+
MVP: data.levelUp_MVP ? new Date(data.levelUp_MVP) : null,
|
|
266
|
+
MVP_PLUS: data.levelUp_MVP_PLUS ? new Date(data.levelUp_MVP_PLUS) : null
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Player Name ( at least last known to hypixel )
|
|
271
|
+
* @return {string}
|
|
272
|
+
*/
|
|
273
|
+
toString() {
|
|
274
|
+
return this.nickname;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
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
|
+
/**
|
|
378
|
+
* @typedef {string} PlayerRank
|
|
379
|
+
* * `Default`
|
|
380
|
+
* * `VIP`
|
|
381
|
+
* * `VIP+`
|
|
382
|
+
* * `MVP`
|
|
383
|
+
* * `MVP+`
|
|
384
|
+
* * `MVP++`
|
|
385
|
+
* * `Game Master`
|
|
386
|
+
* * `Admin`
|
|
387
|
+
* * `YouTube`
|
|
388
|
+
*/
|
|
389
|
+
/**
|
|
390
|
+
* @typedef {Object} PlayerSocialMedia
|
|
391
|
+
* Player social media object
|
|
392
|
+
* @property {string} name Twitter, YouTube, Instagram, Twitch, Hypixel, Discord
|
|
393
|
+
* @property {string} link Link to social media
|
|
394
|
+
* @property {string} id TWITTER, YOUTUBE, INSTRAGRAM, TWITCH, HYPIXEL, DISCORD
|
|
395
|
+
*/
|
|
396
|
+
/**
|
|
397
|
+
* @typedef {Object|null} PlayerStats
|
|
398
|
+
* Player stats for each mini-game. `null` if player has no stats.
|
|
399
|
+
* <br>
|
|
400
|
+
* Usage: `<Player>.stats.skywars`
|
|
401
|
+
* @property {SkyWars|null} skywars SkyWars
|
|
402
|
+
* @property {BedWars|null} bedwars BedWars
|
|
403
|
+
* @property {UHC|null} uhc UHC
|
|
404
|
+
* @property {SpeedUHC|null} speedUHC Speed UHC
|
|
405
|
+
* @property {MurderMystery|null} murdermystery Murder Mystery
|
|
406
|
+
* @property {Duels|null} duels Duels
|
|
407
|
+
* @property {BuildBattle|null} buildbattle BuildBattle
|
|
408
|
+
* @property {MegaWalls|null} megawalls MegaWalls
|
|
409
|
+
* @property {CopsAndCrims|null} copsandcrims Cops and Crims
|
|
410
|
+
* @property {TNTGames|null} tntgames The TNT Games
|
|
411
|
+
* @property {SmashHeroes|null} smashheroes Smash Heroes
|
|
412
|
+
* @property {VampireZ|null} vampirez VampireZ
|
|
413
|
+
* @property {BlitzSurvivalGames|null} blitzsg Blitz Survival Games
|
|
414
|
+
* @property {ArenaBrawl|null} arena Arena Brawl
|
|
415
|
+
* @property {Arcade|null} arcade Arcade
|
|
416
|
+
*/
|
|
417
|
+
/**
|
|
418
|
+
* @typedef {Object} RanksPurchaseTime
|
|
419
|
+
* Time at which ranks were purchased. Beware, even if a player has MVP+(+), every value here *could* be null
|
|
420
|
+
* @property {Date|null} VIP VIP rank
|
|
421
|
+
* @property {Date|null} VIP_PLUS VIP+ rank
|
|
422
|
+
* @property {Date|null} MVP MVP rank
|
|
423
|
+
* @property {Date|null} MVP_PLUS MVP+ rank
|
|
424
|
+
*/
|
|
425
|
+
/**
|
|
426
|
+
* @typedef {Object} LevelProgress
|
|
427
|
+
* @property {number} xpToNext Total XP to a player's next level.
|
|
428
|
+
* @property {number} remainingXP XP to the player's next level.
|
|
429
|
+
* @property {number} currentXP XP the player current has.
|
|
430
|
+
* @property {number} percent Player level progress as a percentage.
|
|
431
|
+
* @property {number} percentRemaining Remaining percentage of the percent value.
|
|
432
|
+
*/
|
|
433
|
+
module.exports = Player;
|