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
@@ -1,5 +1,12 @@
1
+ /* eslint-disable jsdoc/require-jsdoc */
2
+ const GuildRank = require('../structures/Guild/GuildRank');
1
3
  const dateRegExp = /(\d{4})-(\d{2})-(\d{2})/;
2
- // eslint-disable-next-line require-jsdoc
4
+
5
+ function parseDate(date) {
6
+ date[1] -= 1;
7
+ return new Date(Math.round(new Date(new Date().setUTCFullYear(...date)).setUTCHours(5, 0, 0) / 1000) * 1000);
8
+ }
9
+
3
10
  function parseHistory(historyData) {
4
11
  return Object.entries(historyData).map((x, index) => ({
5
12
  day: x[0],
@@ -17,13 +24,6 @@ function parseHistory(historyData) {
17
24
  }));
18
25
  }
19
26
 
20
- // eslint-disable-next-line require-jsdoc
21
- function parseDate(date) {
22
- date[1] -= 1;
23
- return new Date(Math.round(new Date(new Date().setUTCFullYear(...date)).setUTCHours(5, 0, 0) / 1000) * 1000);
24
- }
25
-
26
- // eslint-disable-next-line require-jsdoc
27
27
  function getGuildLevel(exp) {
28
28
  const EXP_NEEDED = [
29
29
  100000, 150000, 250000, 500000, 750000, 1000000, 1250000, 1500000, 2000000, 2500000, 2500000, 2500000, 2500000,
@@ -32,15 +32,15 @@ function getGuildLevel(exp) {
32
32
 
33
33
  let level = 0;
34
34
 
35
- for (let i = 0; i <= 1000; i += 1) {
36
- let need = 0;
35
+ for (let i = 0; 1000 >= i; i += 1) {
36
+ let need;
37
37
  if (i >= EXP_NEEDED.length) {
38
38
  need = EXP_NEEDED[EXP_NEEDED.length - 1];
39
39
  } else {
40
40
  need = EXP_NEEDED[i];
41
41
  }
42
42
 
43
- if (exp - need < 0) {
43
+ if (0 > exp - need) {
44
44
  return Math.round((level + exp / need) * 100) / 100;
45
45
  }
46
46
  level += 1;
@@ -50,6 +50,28 @@ function getGuildLevel(exp) {
50
50
  return 1000;
51
51
  }
52
52
 
53
+ function ranks(data) {
54
+ return data.ranks && data.ranks.length
55
+ ? data.ranks.map((r) => new GuildRank(r)).sort((a, b) => a.priority - b.priority)
56
+ : [];
57
+ }
58
+
59
+ function expLimit(exp) {
60
+ return 2e5 < exp ? (7e5 < exp ? 2.5e5 + Math.round(exp * 0.03) : 2e5 + Math.round((exp - 2e5) / 10)) : exp;
61
+ }
62
+
63
+ function calculateExpHistory(data) {
64
+ const finalObj = {};
65
+ for (const day of Object.keys(data.members[0].expHistory)) {
66
+ let gexp = 0;
67
+ for (const member of data.members) {
68
+ gexp += member.expHistory[day] || 0;
69
+ }
70
+ finalObj[day] = expLimit(gexp);
71
+ }
72
+ return parseHistory(finalObj);
73
+ }
74
+
53
75
  /**
54
76
  * @typedef {object} ExpHistory
55
77
  * @property {string} day String Date ( unparsed )
@@ -57,4 +79,12 @@ function getGuildLevel(exp) {
57
79
  * @property {number} exp Experience of the day
58
80
  * @property {number} totalExp Experience earned from day 0 to this day
59
81
  */
60
- module.exports = { parseHistory, getGuildLevel };
82
+
83
+ module.exports = {
84
+ parseDate,
85
+ parseHistory,
86
+ getGuildLevel,
87
+ ranks,
88
+ expLimit,
89
+ calculateExpHistory
90
+ };
@@ -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
+ };