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.
- package/.prettierrc +3 -3
- package/README.md +6 -4
- package/eslint.config.mjs +71 -0
- package/package.json +21 -25
- package/src/API/getAchievements.js +7 -0
- package/src/API/getBoosters.js +1 -0
- package/src/API/getChallenges.js +7 -0
- package/src/API/getGameCounts.js +1 -0
- package/src/API/getGuild.js +5 -4
- package/src/API/getGuildAchievements.js +7 -0
- package/src/API/getLeaderboards.js +4 -2
- package/src/API/getPlayer.js +2 -1
- package/src/API/getQuests.js +7 -0
- package/src/API/getRecentGames.js +6 -10
- package/src/API/getServerInfo.js +42 -37
- package/src/API/getStatus.js +2 -1
- package/src/API/getWatchdogStats.js +1 -0
- package/src/API/index.js +28 -17
- package/src/API/skyblock/getAuction.js +21 -0
- package/src/API/skyblock/{getSkyblockAuctions.js → getAuctions.js} +19 -12
- package/src/API/skyblock/{getSkyblockAuctionsByPlayer.js → getAuctionsByPlayer.js} +2 -2
- package/src/API/skyblock/{getSkyblockBazaar.js → getBazaar.js} +1 -3
- package/src/API/skyblock/getBingo.js +7 -0
- package/src/API/skyblock/getBingoByPlayer.js +14 -0
- package/src/API/skyblock/{getEndedSkyblockAuctions.js → getEndedAuctions.js} +1 -0
- package/src/API/skyblock/getFireSales.js +7 -0
- package/src/API/skyblock/getGovernment.js +7 -0
- package/src/API/skyblock/{getSkyblockMember.js → getMember.js} +10 -3
- package/src/API/skyblock/getMuseum.js +15 -0
- package/src/API/skyblock/{getSkyblockNews.js → getNews.js} +1 -0
- package/src/API/skyblock/{getSkyblockProfiles.js → getProfiles.js} +14 -7
- package/src/Client.js +127 -25
- package/src/Errors.js +38 -17
- package/src/Private/rateLimit.js +17 -13
- package/src/Private/requests.js +27 -16
- package/src/Private/updater.js +11 -8
- package/src/Private/uuidCache.js +23 -30
- package/src/Private/validate.js +33 -22
- package/src/index.js +9 -0
- package/src/structures/APIIncident.js +4 -11
- package/src/structures/APIStatus.js +0 -1
- package/src/structures/Boosters/Booster.js +14 -13
- package/src/structures/Color.js +93 -48
- package/src/structures/Game.js +4 -2
- package/src/structures/Guild/Guild.js +35 -48
- package/src/structures/Guild/GuildMember.js +8 -8
- package/src/structures/Guild/GuildRank.js +2 -2
- package/src/structures/MiniGames/Arcade.js +242 -235
- package/src/structures/MiniGames/ArenaBrawl.js +11 -11
- package/src/structures/MiniGames/BedWars.js +262 -131
- package/src/structures/MiniGames/BlitzSurvivalGames.js +24 -23
- package/src/structures/MiniGames/CopsAndCrims.js +1 -0
- package/src/structures/MiniGames/Duels.js +92 -33
- package/src/structures/MiniGames/MegaWalls.js +3 -1
- package/src/structures/MiniGames/MurderMystery.js +2 -2
- package/src/structures/MiniGames/Pit.js +230 -2
- package/src/structures/MiniGames/PitInventoryItem.js +43 -0
- package/src/structures/MiniGames/SkyWars.js +211 -195
- package/src/structures/MiniGames/SmashHeroes.js +37 -35
- package/src/structures/MiniGames/SpeedUHC.js +17 -4
- package/src/structures/MiniGames/TNTGames.js +1 -1
- package/src/structures/MiniGames/UHC.js +33 -14
- package/src/structures/MiniGames/WoolWars.js +6 -5
- package/src/structures/Pet.js +1 -1
- package/src/structures/Player.js +26 -121
- package/src/structures/PlayerCosmetics.js +67 -12
- package/src/structures/ServerInfo.js +1 -1
- package/src/structures/SkyBlock/Auctions/Auction.js +3 -1
- package/src/structures/SkyBlock/Auctions/AuctionInfo.js +3 -1
- package/src/structures/SkyBlock/Auctions/BaseAuction.js +2 -1
- package/src/structures/SkyBlock/Auctions/Bid.js +1 -0
- package/src/structures/SkyBlock/Auctions/PartialAuction.js +1 -0
- package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
- package/src/structures/SkyBlock/PlayerBingo.js +49 -0
- package/src/structures/SkyBlock/SkyblockInventoryItem.js +76 -32
- package/src/structures/SkyBlock/SkyblockMember.js +252 -289
- package/src/structures/SkyBlock/SkyblockMuseum.js +60 -0
- package/src/structures/SkyBlock/SkyblockMuseumItem.js +54 -0
- package/src/structures/SkyBlock/SkyblockPet.js +3 -3
- package/src/structures/SkyBlock/SkyblockProfile.js +37 -23
- package/src/structures/SkyBlock/Static/Bingo.js +101 -0
- package/src/structures/SkyBlock/Static/BingoData.js +45 -0
- package/src/structures/SkyBlock/Static/Candidate.js +40 -0
- package/src/structures/SkyBlock/Static/FireSale.js +55 -0
- package/src/structures/SkyBlock/Static/Government.js +74 -0
- package/src/structures/SkyBlock/Static/Perk.js +24 -0
- package/src/structures/Static/Achievement.js +87 -0
- package/src/structures/Static/AchievementTier.js +33 -0
- package/src/structures/Static/Achievements.js +30 -0
- package/src/structures/Static/Challenges.js +29 -0
- package/src/structures/Static/GameAchievements.js +36 -0
- package/src/structures/Static/GameChallenges.js +40 -0
- package/src/structures/Static/GameQuests.js +24 -0
- package/src/structures/Static/GuildAchievements.js +34 -0
- package/src/structures/Static/Quest.js +66 -0
- package/src/structures/Static/Quests.js +31 -0
- package/src/structures/Status.js +2 -2
- package/src/utils/Constants.js +384 -543
- package/src/utils/{guildExp.js → Guild.js} +46 -13
- package/src/utils/Player.js +112 -0
- package/src/utils/SkyblockUtils.js +448 -186
- package/src/utils/arrayTools.js +1 -1
- package/src/utils/divide.js +1 -1
- package/src/utils/index.js +2 -1
- package/src/utils/isGuildID.js +1 -1
- package/src/utils/oscillation.js +4 -2
- package/src/utils/removeSnakeCase.js +19 -8
- package/src/utils/rgbToHexColor.js +1 -1
- package/src/utils/romanize.js +35 -4
- package/src/utils/toUuid.js +12 -7
- package/src/utils/varInt.js +2 -2
- package/typings/index.d.ts +1246 -446
- package/src/utils/toIGN.js +0 -20
package/src/utils/oscillation.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
7
|
+
return 'object' === typeof obj && '{' === JSON.stringify(obj)[0];
|
|
6
8
|
}
|
|
7
|
-
|
|
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(
|
|
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
|
-
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
13
23
|
function removeSnakeCaseString(str) {
|
|
14
|
-
if (typeof str
|
|
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,
|
package/src/utils/romanize.js
CHANGED
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
module.exports = (num) => {
|
|
2
2
|
if (isNaN(num)) return NaN;
|
|
3
|
-
const digits = String(
|
|
4
|
-
const key = [
|
|
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[
|
|
39
|
+
roman = (key[Number(digits.pop()) + i * 10] || '') + roman;
|
|
9
40
|
}
|
|
10
|
-
return Array(
|
|
41
|
+
return Array(Number(digits.join('')) + 1).join('M') + roman;
|
|
11
42
|
};
|
package/src/utils/toUuid.js
CHANGED
|
@@ -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
|
|
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
|
|
11
|
-
const
|
|
12
|
-
|
|
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
|
|
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
|
};
|
package/src/utils/varInt.js
CHANGED
|
@@ -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 (
|
|
10
|
+
if (5 < numRead) {
|
|
11
11
|
return NaN;
|
|
12
12
|
}
|
|
13
13
|
} while (numRead < bytes.length);
|