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,13 +1,15 @@
1
1
  // See https://github.com/HypixelDev/PublicAPI/blob/db26b5fd3b7bb29da14e40e6d211143ec44a4519/Documentation/misc/Oscillation.md
2
2
  // Month oscillation started in December 2014, so every month that is pair ( odd in js!! ) is month A
3
3
  // Weekly oscillation started... just refer to the code in the docs
4
- // eslint-disable-next-line require-jsdoc
4
+
5
+ // eslint-disable-next-line jsdoc/require-jsdoc
5
6
  function monthAB(date = Date.now()) {
6
7
  return new Date(date).getMonth() % 2 ? 'a' : 'b';
7
8
  }
8
9
 
9
10
  const weeklyOscillationStart = 1417237200000;
10
- // eslint-disable-next-line require-jsdoc
11
+
12
+ // eslint-disable-next-line jsdoc/require-jsdoc
11
13
  function weekAB(date = Date.now()) {
12
14
  return (Math.abs(new Date(date).getTime() - weeklyOscillationStart) / 604800000) % 2 ? 'a' : 'b';
13
15
  }
@@ -1,19 +1,30 @@
1
- // eslint-disable-next-line require-jsdoc
2
- const single = (obj) => Object.keys(obj).reduce((pV, cV) => ({ ...pV, [cV.replace(/_[a-z]/gi, (x) => x[1].toUpperCase())]: obj[cV] }), {});
3
- // eslint-disable-next-line require-jsdoc
1
+ const single = (obj) => {
2
+ Object.keys(obj).reduce((pV, cV) => ({ ...pV, [cV.replace(/_[a-z]/gi, (x) => x[1].toUpperCase())]: obj[cV] }), {});
3
+ };
4
+
5
+ // eslint-disable-next-line jsdoc/require-jsdoc
4
6
  function validateJSON(obj) {
5
- return typeof obj === 'object' && JSON.stringify(obj)[0] === '{';
7
+ return 'object' === typeof obj && '{' === JSON.stringify(obj)[0];
6
8
  }
7
- // eslint-disable-next-line require-jsdoc
9
+
10
+ // eslint-disable-next-line jsdoc/require-jsdoc
8
11
  function recursive(obj, lowerCase = false) {
9
12
  if (!validateJSON(obj)) return obj;
10
- return Object.keys(obj).reduce((pV, cV) => ({ ...pV, [(lowerCase ? cV : cV.toLowerCase()).replace(/_[a-z]/gi, (x) => x[1].toUpperCase())]: recursive(obj[cV]) }), {});
13
+ return Object.keys(obj).reduce(
14
+ (pV, cV) => ({
15
+ ...pV,
16
+ [(lowerCase ? cV : cV.toLowerCase()).replace(/_[a-z]/gi, (x) => x[1].toUpperCase())]: recursive(obj[cV])
17
+ }),
18
+ {}
19
+ );
11
20
  }
12
- // eslint-disable-next-line require-jsdoc
21
+
22
+ // eslint-disable-next-line jsdoc/require-jsdoc
13
23
  function removeSnakeCaseString(str) {
14
- if (typeof str !== 'string') return null;
24
+ if ('string' !== typeof str) return null;
15
25
  return str.toLowerCase().replace(/_[a-z]/gi, (x) => x[1].toUpperCase());
16
26
  }
27
+
17
28
  module.exports = {
18
29
  single,
19
30
  recursive,
@@ -2,7 +2,7 @@ module.exports = (rgb) => {
2
2
  let hexCode = '#';
3
3
  for (const num of rgb) {
4
4
  const hex = Number(num).toString(16);
5
- hexCode += hex.length === 1 ? '0' + hex : hex;
5
+ hexCode += 1 === hex.length ? '0' + hex : hex;
6
6
  }
7
7
  return hexCode;
8
8
  };
@@ -1,11 +1,42 @@
1
1
  module.exports = (num) => {
2
2
  if (isNaN(num)) return NaN;
3
- const digits = String(+num).split('');
4
- const key = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
3
+ const digits = String(Number(num)).split('');
4
+ const key = [
5
+ '',
6
+ 'C',
7
+ 'CC',
8
+ 'CCC',
9
+ 'CD',
10
+ 'D',
11
+ 'DC',
12
+ 'DCC',
13
+ 'DCCC',
14
+ 'CM',
15
+ '',
16
+ 'X',
17
+ 'XX',
18
+ 'XXX',
19
+ 'XL',
20
+ 'L',
21
+ 'LX',
22
+ 'LXX',
23
+ 'LXXX',
24
+ 'XC',
25
+ '',
26
+ 'I',
27
+ 'II',
28
+ 'III',
29
+ 'IV',
30
+ 'V',
31
+ 'VI',
32
+ 'VII',
33
+ 'VIII',
34
+ 'IX'
35
+ ];
5
36
  let roman = '';
6
37
  let i = 3;
7
38
  while (i--) {
8
- roman = (key[+digits.pop() + i * 10] || '') + roman;
39
+ roman = (key[Number(digits.pop()) + i * 10] || '') + roman;
9
40
  }
10
- return Array(+digits.join('') + 1).join('M') + roman;
41
+ return Array(Number(digits.join('')) + 1).join('M') + roman;
11
42
  };
@@ -1,19 +1,24 @@
1
- const fetch = require('../Private/uuidCache');
1
+ const fetch = require('../Private/uuidCache.js');
2
2
  const isUUID = require('./isUUID.js');
3
3
  const Errors = require('../Errors');
4
4
 
5
- module.exports = async (input) => {
5
+ module.exports = async (input, cacheTime = 600, useThirdPartyAPI = '') => {
6
6
  if (!input) throw new Error(Errors.NO_NICKNAME_UUID);
7
- if (typeof input !== 'string') throw new Error(Errors.UUID_NICKNAME_MUST_BE_A_STRING);
7
+ if ('string' !== typeof input) throw new Error(Errors.UUID_NICKNAME_MUST_BE_A_STRING);
8
8
  if (isUUID(input)) return input.replace(/-/g, '');
9
9
  try {
10
- const res = await fetch(`https://api.mojang.com/users/profiles/minecraft/${input}`, input);
11
- const parsedRes = await res.json();
12
- if (res.status === 404) {
10
+ const customUrl = true === useThirdPartyAPI ? 'https://api.minetools.eu/uuid/' : useThirdPartyAPI;
11
+ const url = useThirdPartyAPI ? `${customUrl}${input}` : `https://mowojang.matdoes.dev/${input}`;
12
+ const res = await fetch(url, input, cacheTime);
13
+ if (404 === res.status) {
13
14
  return Promise.reject(new Error(Errors.PLAYER_DOES_NOT_EXIST));
15
+ } else if (200 !== res.status) {
16
+ throw new Error('Unknown Error whilst retrieving player information');
14
17
  }
15
- return parsedRes.id;
18
+ return res.id;
16
19
  } catch {
20
+ // 2nd Try
21
+ if (!useThirdPartyAPI) return module.exports(input, cacheTime, true);
17
22
  throw new Error(Errors.PLAYER_DOES_NOT_EXIST);
18
23
  }
19
24
  };
@@ -1,4 +1,4 @@
1
- // eslint-disable-next-line require-jsdoc
1
+ // eslint-disable-next-line jsdoc/require-jsdoc
2
2
  function readVarInt(bytes) {
3
3
  let numRead = 0;
4
4
  let result = 0;
@@ -7,7 +7,7 @@ function readVarInt(bytes) {
7
7
  const value = read & 0b01111111;
8
8
  result |= value << (7 * numRead);
9
9
  numRead++;
10
- if (numRead > 5) {
10
+ if (5 < numRead) {
11
11
  return NaN;
12
12
  }
13
13
  } while (numRead < bytes.length);