hypixel-api-reborn 11.2.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 (84) hide show
  1. package/README.md +1 -1
  2. package/eslint.config.mjs +71 -0
  3. package/package.json +11 -17
  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/skyblock/getAuction.js +8 -6
  18. package/src/API/skyblock/getAuctions.js +15 -12
  19. package/src/API/skyblock/getAuctionsByPlayer.js +1 -1
  20. package/src/API/skyblock/getBazaar.js +1 -3
  21. package/src/API/skyblock/getBingo.js +1 -2
  22. package/src/API/skyblock/getBingoByPlayer.js +3 -3
  23. package/src/API/skyblock/getEndedAuctions.js +1 -0
  24. package/src/API/skyblock/getFireSales.js +1 -1
  25. package/src/API/skyblock/getGovernment.js +1 -2
  26. package/src/API/skyblock/getMember.js +1 -0
  27. package/src/API/skyblock/getMuseum.js +1 -0
  28. package/src/API/skyblock/getNews.js +1 -0
  29. package/src/API/skyblock/getProfiles.js +1 -0
  30. package/src/Client.js +42 -14
  31. package/src/Private/rateLimit.js +7 -11
  32. package/src/Private/requests.js +11 -12
  33. package/src/Private/updater.js +2 -3
  34. package/src/Private/uuidCache.js +1 -2
  35. package/src/Private/validate.js +19 -19
  36. package/src/structures/APIIncident.js +1 -2
  37. package/src/structures/APIStatus.js +0 -1
  38. package/src/structures/Boosters/Booster.js +9 -8
  39. package/src/structures/Game.js +1 -1
  40. package/src/structures/Guild/Guild.js +19 -36
  41. package/src/structures/Guild/GuildMember.js +2 -2
  42. package/src/structures/MiniGames/Arcade.js +242 -240
  43. package/src/structures/MiniGames/ArenaBrawl.js +11 -11
  44. package/src/structures/MiniGames/BedWars.js +197 -194
  45. package/src/structures/MiniGames/BlitzSurvivalGames.js +24 -23
  46. package/src/structures/MiniGames/CopsAndCrims.js +1 -0
  47. package/src/structures/MiniGames/Duels.js +9 -11
  48. package/src/structures/MiniGames/Pit.js +4 -5
  49. package/src/structures/MiniGames/SkyWars.js +197 -186
  50. package/src/structures/MiniGames/SmashHeroes.js +36 -34
  51. package/src/structures/MiniGames/SpeedUHC.js +17 -4
  52. package/src/structures/MiniGames/UHC.js +26 -25
  53. package/src/structures/MiniGames/WoolWars.js +6 -5
  54. package/src/structures/Pet.js +1 -1
  55. package/src/structures/Player.js +13 -104
  56. package/src/structures/PlayerCosmetics.js +5 -4
  57. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +2 -1
  58. package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -1
  59. package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
  60. package/src/structures/SkyBlock/PlayerBingo.js +7 -14
  61. package/src/structures/SkyBlock/SkyblockInventoryItem.js +4 -28
  62. package/src/structures/SkyBlock/SkyblockMember.js +78 -223
  63. package/src/structures/SkyBlock/SkyblockPet.js +3 -4
  64. package/src/structures/SkyBlock/Static/Bingo.js +10 -11
  65. package/src/structures/SkyBlock/Static/BingoData.js +1 -1
  66. package/src/structures/Static/Achievement.js +16 -15
  67. package/src/structures/Static/AchievementTier.js +2 -2
  68. package/src/structures/Static/Quest.js +2 -2
  69. package/src/utils/Constants.js +17 -517
  70. package/src/utils/{guildExp.js → Guild.js} +42 -12
  71. package/src/utils/Player.js +112 -0
  72. package/src/utils/SkyblockUtils.js +449 -192
  73. package/src/utils/arrayTools.js +1 -1
  74. package/src/utils/divide.js +1 -1
  75. package/src/utils/index.js +2 -1
  76. package/src/utils/isGuildID.js +1 -1
  77. package/src/utils/oscillation.js +4 -2
  78. package/src/utils/removeSnakeCase.js +11 -7
  79. package/src/utils/rgbToHexColor.js +1 -1
  80. package/src/utils/romanize.js +3 -3
  81. package/src/utils/toUuid.js +4 -4
  82. package/src/utils/varInt.js +2 -2
  83. package/typings/index.d.ts +272 -162
  84. package/src/utils/toIGN.js +0 -24
@@ -0,0 +1,112 @@
1
+ /* eslint-disable jsdoc/require-jsdoc */
2
+ function getRank(player) {
3
+ let rank;
4
+ if (player.prefix) {
5
+ rank = player.prefix.replace(/§[0-9|a-z]|\[|\]/g, '');
6
+ } else if (player.rank && 'NORMAL' !== player.rank) {
7
+ switch (player.rank) {
8
+ case 'YOUTUBER':
9
+ rank = 'YouTube';
10
+ break;
11
+ case 'GAME_MASTER':
12
+ rank = 'Game Master';
13
+ break;
14
+ case 'ADMIN':
15
+ rank = 'Admin';
16
+ break;
17
+ default:
18
+ rank = '';
19
+ break;
20
+ }
21
+ } else {
22
+ switch (player.newPackageRank) {
23
+ case 'MVP_PLUS':
24
+ rank = player.monthlyPackageRank && 'SUPERSTAR' === player.monthlyPackageRank ? 'MVP++' : 'MVP+';
25
+ break;
26
+ case 'MVP':
27
+ rank = 'MVP';
28
+ break;
29
+ case 'VIP_PLUS':
30
+ rank = 'VIP+';
31
+ break;
32
+ case 'VIP':
33
+ rank = 'VIP';
34
+ break;
35
+ default:
36
+ rank = player.monthlyPackageRank && 'SUPERSTAR' === player.monthlyPackageRank ? 'MVP++' : 'Default';
37
+ }
38
+ }
39
+ return rank;
40
+ }
41
+
42
+ function getPlayerLevel(exp) {
43
+ const base = 10000;
44
+ const growth = 2500;
45
+ const reversePqPrefix = -(base - 0.5 * growth) / growth;
46
+ const reverseConst = reversePqPrefix * reversePqPrefix;
47
+ const growthDivides2 = 2 / growth;
48
+ const num = 1 + reversePqPrefix + Math.sqrt(reverseConst + growthDivides2 * exp);
49
+ const level = Math.round(num * 100) / 100;
50
+ return level;
51
+ }
52
+
53
+ function xpToNextLevel(player) {
54
+ const lvl = getPlayerLevel(player.networkExp);
55
+ const xpToNext = 2500 * Math.floor(lvl) + 5000;
56
+ if (10000 > player.networkExp) return 10000;
57
+ return xpToNext;
58
+ }
59
+
60
+ function levelToXP(player) {
61
+ let level = Number(Math.floor(getPlayerLevel(player.networkExp)));
62
+ level = level - 1;
63
+ const xp = 1250 * level ** 2 + 8750 * level;
64
+ return xp;
65
+ }
66
+
67
+ function playerLevelProgress(player) {
68
+ const xpFromLevel = levelToXP(player);
69
+ let currentXP = player.networkExp - xpFromLevel;
70
+ const xpToNext = xpToNextLevel(player);
71
+ const remainingXP = xpToNext - currentXP + 2500;
72
+ currentXP = currentXP - 2500;
73
+ const percent = Math.round((currentXP / xpToNext) * 100 * 100) / 100;
74
+ const percentRemaining = Math.round((100 - percent) * 100) / 100;
75
+ return {
76
+ xpToNext,
77
+ remainingXP,
78
+ currentXP,
79
+ percent,
80
+ percentRemaining
81
+ };
82
+ }
83
+
84
+ function getSocialMedia(data) {
85
+ if (!data) return null;
86
+ const links = data.links;
87
+ const formattedNames = ['Twitter', 'YouTube', 'Instagram', 'Twitch', 'Hypixel', 'Discord'];
88
+ const upperNames = ['TWITTER', 'YOUTUBE', 'INSTAGRAM', 'TWITCH', 'HYPIXEL', 'DISCORD'];
89
+ if (!links) return null;
90
+ return Object.keys(links)
91
+ .map((x) => upperNames.indexOf(x))
92
+ .filter((x) => -1 !== x)
93
+ .map((x) => ({ name: formattedNames[x], link: links[upperNames[x]], id: upperNames[x] }));
94
+ }
95
+
96
+ function parseClaimedRewards(data) {
97
+ if (!data) return null;
98
+ return Object.keys(data)
99
+ .map((x) => x.match(/levelingReward_(\d+)/))
100
+ .filter((x) => x)
101
+ .map((x) => parseInt(x[1], 10));
102
+ }
103
+
104
+ module.exports = {
105
+ getRank,
106
+ getPlayerLevel,
107
+ xpToNextLevel,
108
+ levelToXP,
109
+ playerLevelProgress,
110
+ getSocialMedia,
111
+ parseClaimedRewards
112
+ };