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
|
@@ -1,40 +1,55 @@
|
|
|
1
|
+
const { getGuildLevel, ranks, calculateExpHistory } = require('../../utils/Guild');
|
|
1
2
|
const GuildMember = require('./GuildMember');
|
|
2
3
|
const GuildRank = require('./GuildRank');
|
|
3
4
|
const Color = require('../Color');
|
|
4
5
|
const Game = require('../Game');
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
8
|
+
function members(data) {
|
|
9
|
+
return data.members.length ? data.members.map((m) => new GuildMember(m)) : [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
13
|
+
function totalWeeklyGexp(data) {
|
|
14
|
+
return members(data)
|
|
15
|
+
.map((m) => m.weeklyExperience)
|
|
16
|
+
.reduce((acc, cur) => acc + cur);
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* Guild class
|
|
8
21
|
*/
|
|
9
22
|
class Guild {
|
|
10
23
|
/**
|
|
11
24
|
* @param {data} data Guild data
|
|
12
|
-
* @param {string} [me] Player uuid
|
|
25
|
+
* @param {string} [me] Player uuid u#sed to search for this guild
|
|
13
26
|
*/
|
|
14
27
|
constructor(data, me = '') {
|
|
15
28
|
/**
|
|
16
29
|
* Guild ID
|
|
17
30
|
* @type {string}
|
|
18
31
|
*/
|
|
32
|
+
|
|
33
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
19
34
|
this.id = data._id;
|
|
20
35
|
/**
|
|
21
36
|
* Guild name
|
|
22
|
-
* @type {
|
|
37
|
+
* @type {string}
|
|
23
38
|
*/
|
|
24
39
|
this.name = data.name;
|
|
25
40
|
/**
|
|
26
41
|
* Guild description
|
|
27
|
-
* @type {
|
|
42
|
+
* @type {string}
|
|
28
43
|
*/
|
|
29
|
-
this.description = data.description
|
|
44
|
+
this.description = data.description ?? '';
|
|
30
45
|
/**
|
|
31
46
|
* Guild experience
|
|
32
|
-
* @type {
|
|
47
|
+
* @type {number}
|
|
33
48
|
*/
|
|
34
49
|
this.experience = data.exp || 0;
|
|
35
50
|
/**
|
|
36
51
|
* Guild level
|
|
37
|
-
* @type {
|
|
52
|
+
* @type {number}
|
|
38
53
|
*/
|
|
39
54
|
this.level = getGuildLevel(this.experience);
|
|
40
55
|
/**
|
|
@@ -64,7 +79,9 @@ class Guild {
|
|
|
64
79
|
* @return {Array<GuildRank>}
|
|
65
80
|
*/
|
|
66
81
|
this.getRanksByNewest = function () {
|
|
67
|
-
return this.ranks.length
|
|
82
|
+
return this.ranks.length
|
|
83
|
+
? this.ranks.map((r) => new GuildRank(r)).sort((a, b) => b.createdAt - a.createdAt)
|
|
84
|
+
: null;
|
|
68
85
|
};
|
|
69
86
|
/**
|
|
70
87
|
* A map containing all guild members, keyed by their uuids
|
|
@@ -86,7 +103,7 @@ class Guild {
|
|
|
86
103
|
};
|
|
87
104
|
/**
|
|
88
105
|
* Date of guild creation as timestamp
|
|
89
|
-
* @type {
|
|
106
|
+
* @type {string}
|
|
90
107
|
*/
|
|
91
108
|
this.createdAtTimestamp = data.created;
|
|
92
109
|
/**
|
|
@@ -98,17 +115,17 @@ class Guild {
|
|
|
98
115
|
* Whether this guild can be joined using /g join
|
|
99
116
|
* @type {boolean}
|
|
100
117
|
*/
|
|
101
|
-
this.joinable = data.joinable
|
|
118
|
+
this.joinable = data.joinable ?? false;
|
|
102
119
|
/**
|
|
103
120
|
* Whether this guild is listed in the Guild Finder
|
|
104
121
|
* @type {boolean}
|
|
105
122
|
*/
|
|
106
|
-
this.publiclyListed =
|
|
123
|
+
this.publiclyListed = Boolean(data.publiclyListed);
|
|
107
124
|
/**
|
|
108
125
|
* Timestamp guild chat will be unmuted at.
|
|
109
126
|
* @type {number|null}
|
|
110
127
|
*/
|
|
111
|
-
this.chatMuteUntilTimestamp = data.chatMute
|
|
128
|
+
this.chatMuteUntilTimestamp = data.chatMute ?? null;
|
|
112
129
|
/**
|
|
113
130
|
* Timestamp guild chat will be unmuted at as Date.
|
|
114
131
|
* @type {Date|null}
|
|
@@ -118,12 +135,12 @@ class Guild {
|
|
|
118
135
|
* Timestamp guild chat will be unmuted at.
|
|
119
136
|
* @type {Array<{ Pattern: string, Color: string }>}
|
|
120
137
|
*/
|
|
121
|
-
this.banner = data.banner
|
|
138
|
+
this.banner = data.banner ?? null;
|
|
122
139
|
/**
|
|
123
140
|
* Guild tag
|
|
124
141
|
* @type {string}
|
|
125
142
|
*/
|
|
126
|
-
this.tag = data.tag
|
|
143
|
+
this.tag = data.tag ?? null;
|
|
127
144
|
/**
|
|
128
145
|
* Guild tag color
|
|
129
146
|
* @type {Color}
|
|
@@ -145,9 +162,9 @@ class Guild {
|
|
|
145
162
|
* @type {{winners: number, experienceKings: number, onlinePlayers: number}}
|
|
146
163
|
*/
|
|
147
164
|
this.achievements = {
|
|
148
|
-
winners: data.achievements
|
|
149
|
-
experienceKings: data.achievements
|
|
150
|
-
onlinePlayers: data.achievements
|
|
165
|
+
winners: data.achievements.WINNERS ?? 0,
|
|
166
|
+
experienceKings: data.achievements.EXPERIENCE_KINGS ?? 0,
|
|
167
|
+
onlinePlayers: data.achievements.ONLINE_PLAYERS ?? 0
|
|
151
168
|
};
|
|
152
169
|
/**
|
|
153
170
|
* Guild preferred games
|
|
@@ -167,38 +184,8 @@ class Guild {
|
|
|
167
184
|
* @type {GuildMember}
|
|
168
185
|
*/
|
|
169
186
|
get guildMaster() {
|
|
170
|
-
return this.members.find((member) =>
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// eslint-disable-next-line require-jsdoc
|
|
174
|
-
function members(data) {
|
|
175
|
-
return data.members.length ? data.members.map((m) => new GuildMember(m)) : [];
|
|
176
|
-
}
|
|
177
|
-
// eslint-disable-next-line require-jsdoc
|
|
178
|
-
function ranks(data) {
|
|
179
|
-
return data.ranks && data.ranks.length ? data.ranks.map((r) => new GuildRank(r)).sort((a, b) => a.priority - b.priority) : [];
|
|
180
|
-
}
|
|
181
|
-
// eslint-disable-next-line require-jsdoc
|
|
182
|
-
function totalWeeklyGexp(data) {
|
|
183
|
-
return members(data)
|
|
184
|
-
.map((m) => m.weeklyExperience)
|
|
185
|
-
.reduce((acc, cur) => acc + cur);
|
|
186
|
-
}
|
|
187
|
-
// eslint-disable-next-line require-jsdoc
|
|
188
|
-
function calculateExpHistory(data) {
|
|
189
|
-
const finalObj = {};
|
|
190
|
-
for (const day of Object.keys(data.members[0].expHistory)) {
|
|
191
|
-
let gexp = 0;
|
|
192
|
-
for (const member of data.members) {
|
|
193
|
-
gexp += member.expHistory[day] || 0;
|
|
194
|
-
}
|
|
195
|
-
finalObj[day] = expLimit(gexp);
|
|
187
|
+
return this.members.find((member) => 'Guild Master' === member.rank || 'GUILDMASTER' === member.rank);
|
|
196
188
|
}
|
|
197
|
-
return parseHistory(finalObj);
|
|
198
|
-
}
|
|
199
|
-
// eslint-disable-next-line require-jsdoc
|
|
200
|
-
function expLimit(exp) {
|
|
201
|
-
return exp > 2e5 ? (exp > 7e5 ? 2.5e5 + Math.round(exp * 0.03) : 2e5 + Math.round((exp - 2e5) / 10)) : exp;
|
|
202
189
|
}
|
|
203
190
|
|
|
204
191
|
module.exports = Guild;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { parseHistory } = require('../../utils/
|
|
1
|
+
const { parseHistory } = require('../../utils/Guild');
|
|
2
2
|
/**
|
|
3
3
|
* GuildMember class
|
|
4
4
|
*/
|
|
@@ -9,12 +9,12 @@ class GuildMember {
|
|
|
9
9
|
constructor(data) {
|
|
10
10
|
/**
|
|
11
11
|
* Guild member UUID
|
|
12
|
-
* @type {
|
|
12
|
+
* @type {string}
|
|
13
13
|
*/
|
|
14
14
|
this.uuid = data.uuid;
|
|
15
15
|
/**
|
|
16
16
|
* Timestamp this member joined at
|
|
17
|
-
* @type {
|
|
17
|
+
* @type {number}
|
|
18
18
|
*/
|
|
19
19
|
this.joinedAtTimestamp = data.joined;
|
|
20
20
|
/**
|
|
@@ -24,25 +24,25 @@ class GuildMember {
|
|
|
24
24
|
this.joinedAt = new Date(data.joined);
|
|
25
25
|
/**
|
|
26
26
|
* The number of challenges completed that count towards the current quest
|
|
27
|
-
* @type {
|
|
27
|
+
* @type {number}
|
|
28
28
|
*/
|
|
29
29
|
this.questParticipation = data.questParticipation || 0;
|
|
30
30
|
/**
|
|
31
31
|
* Member's rank
|
|
32
|
-
* @type {
|
|
32
|
+
* @type {string}
|
|
33
33
|
*/
|
|
34
34
|
this.rank = data.rank;
|
|
35
35
|
/**
|
|
36
36
|
* Timestamp this member will be unmuted at ( if muted )
|
|
37
37
|
* @type {Number|null}
|
|
38
38
|
*/
|
|
39
|
-
this.mutedUntilTimestamp = data.mutedTill
|
|
39
|
+
this.mutedUntilTimestamp = data.mutedTill ?? null;
|
|
40
40
|
/**
|
|
41
41
|
* Timestamp this member will be unmuted at as Date ( if muted )
|
|
42
42
|
* @type {Date|null}
|
|
43
43
|
*/
|
|
44
44
|
this.mutedUntil = data.mutedTill ? new Date(data.mutedTill) : null;
|
|
45
|
-
const xpCheck = data.expHistory && typeof Object.values(data.expHistory)[0]
|
|
45
|
+
const xpCheck = data.expHistory && 'number' === typeof Object.values(data.expHistory)[0];
|
|
46
46
|
/**
|
|
47
47
|
* Experience history per day, resets at 5 am UTC
|
|
48
48
|
* @type {Array<ExpHistory>}
|
|
@@ -50,7 +50,7 @@ class GuildMember {
|
|
|
50
50
|
this.expHistory = parseHistory(data.expHistory);
|
|
51
51
|
/**
|
|
52
52
|
* Experience per week, resets every Monday at 5 am UTC
|
|
53
|
-
* @type {
|
|
53
|
+
* @type {number}
|
|
54
54
|
*/
|
|
55
55
|
this.weeklyExperience = xpCheck ? Object.values(data.expHistory).reduce((pV, cV) => pV + cV, 0) : null;
|
|
56
56
|
}
|
|
@@ -8,7 +8,7 @@ class GuildRank {
|
|
|
8
8
|
constructor(data) {
|
|
9
9
|
/**
|
|
10
10
|
* Guild rank name
|
|
11
|
-
* @type {
|
|
11
|
+
* @type {string}
|
|
12
12
|
*/
|
|
13
13
|
this.name = data.name;
|
|
14
14
|
/**
|
|
@@ -20,7 +20,7 @@ class GuildRank {
|
|
|
20
20
|
* Guild rank tag that appears in guild chat. null if none
|
|
21
21
|
* @type {string|null}
|
|
22
22
|
*/
|
|
23
|
-
this.tag = data.tag
|
|
23
|
+
this.tag = data.tag ?? null;
|
|
24
24
|
/**
|
|
25
25
|
* Timestamp this rank was created at
|
|
26
26
|
* @type {number}
|