hypixel-api-reborn 8.3.0 → 10.0.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.
- package/README.md +2 -2
- package/package.json +9 -9
- package/src/API/getAPIStatus.js +2 -1
- package/src/API/getBoosters.js +1 -0
- package/src/API/getFriends.js +1 -0
- package/src/API/getGameCounts.js +1 -0
- package/src/API/getGuild.js +4 -2
- package/src/API/getKeyInfo.js +1 -0
- package/src/API/getLeaderboards.js +1 -0
- package/src/API/getPlayer.js +18 -3
- package/src/API/getRankedSkyWars.js +11 -0
- package/src/API/getRecentGames.js +1 -0
- package/src/API/getStatus.js +1 -0
- package/src/API/getWatchdogStats.js +1 -0
- package/src/API/index.js +23 -9
- package/src/API/skyblock/getEndedSkyblockAuctions.js +1 -0
- package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +1 -0
- package/src/API/skyblock/getSkyblockBazaar.js +1 -0
- package/src/API/skyblock/getSkyblockMember.js +1 -0
- package/src/API/skyblock/getSkyblockNews.js +1 -0
- package/src/API/skyblock/getSkyblockProfiles.js +1 -0
- package/src/Client.js +57 -13
- package/src/Errors.js +3 -1
- package/src/Private/defaultCache.js +78 -0
- package/src/Private/rateLimit.js +4 -4
- package/src/Private/requests.js +24 -9
- package/src/Private/updater.js +45 -0
- package/src/Private/validate.js +6 -4
- package/src/structures/Game.js +3 -3
- package/src/structures/Guild/Guild.js +7 -1
- package/src/structures/MiniGames/Arcade.js +8 -8
- package/src/structures/MiniGames/BedWars.js +22 -0
- package/src/structures/MiniGames/Duels.js +291 -60
- package/src/structures/MiniGames/SkyWars.js +14 -6
- package/src/structures/MiniGames/SkyWarsRanked.js +45 -0
- package/src/structures/MiniGames/TurboKartRacers.js +130 -0
- package/src/structures/Player.js +15 -23
- package/src/structures/ServerInfo.js +1 -1
- package/src/structures/SkyBlock/News/SkyblockNews.js +4 -4
- package/src/structures/SkyBlock/SkyblockInventoryItem.js +29 -1
- package/src/structures/SkyBlock/SkyblockMember.js +25 -13
- package/src/utils/Constants.js +14 -0
- package/src/utils/index.js +13 -9
- package/src/utils/rgbToHexColor.js +8 -0
- package/src/utils/romanize.js +13 -0
- package/src/utils/varInt.js +1 -1
- package/typings/index.d.ts +423 -358
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/* eslint-disable require-jsdoc */
|
|
3
|
+
const fetch = require('node-fetch');
|
|
4
|
+
const Errors = require('../Errors');
|
|
5
|
+
class Updater {
|
|
6
|
+
async checkForUpdates () {
|
|
7
|
+
const currentVersion = require('../../package.json').version;
|
|
8
|
+
const request = await fetch('https://registry.npmjs.org/hypixel-api-reborn');
|
|
9
|
+
if (!request.ok) return console.log(Errors.UPDATER_REQUEST_NOT_OK);
|
|
10
|
+
const metadata = await request.json();
|
|
11
|
+
const latestVersion = metadata['dist-tags'].latest;
|
|
12
|
+
const compare = this.compare(currentVersion, latestVersion);
|
|
13
|
+
if (compare === -1) {
|
|
14
|
+
this.notify(latestVersion);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
notify (newVersion) {
|
|
18
|
+
console.log(`
|
|
19
|
+
|
|
20
|
+
New version of hypixel-api-reborn is available!
|
|
21
|
+
|
|
22
|
+
v${newVersion}
|
|
23
|
+
Changelog: https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/releases/tag/${newVersion}
|
|
24
|
+
|
|
25
|
+
\x1b[33mnpm i hypixel-api-reborn@${newVersion}\x1b[0m
|
|
26
|
+
or
|
|
27
|
+
\x1b[33myarn add hypixel-api-reborn@${newVersion}\x1b[0m
|
|
28
|
+
|
|
29
|
+
`);
|
|
30
|
+
}
|
|
31
|
+
compare (a, b) {
|
|
32
|
+
const pa = a.split('.');
|
|
33
|
+
const pb = b.split('.');
|
|
34
|
+
for (let i = 0; i < 3; i++) {
|
|
35
|
+
const na = Number(pa[i]);
|
|
36
|
+
const nb = Number(pb[i]);
|
|
37
|
+
if (na > nb) return 1;
|
|
38
|
+
if (nb > na) return -1;
|
|
39
|
+
if (!isNaN(na) && isNaN(nb)) return 1;
|
|
40
|
+
if (isNaN(na) && !isNaN(nb)) return -1;
|
|
41
|
+
}
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
module.exports = Updater;
|
package/src/Private/validate.js
CHANGED
|
@@ -36,7 +36,9 @@ class Validation {
|
|
|
36
36
|
rateLimit: options.rateLimit || 'AUTO',
|
|
37
37
|
keyLimit: options.keyLimit || 120,
|
|
38
38
|
syncWithHeaders: !!options.syncWithHeaders,
|
|
39
|
-
headers: options.headers || {}
|
|
39
|
+
headers: options.headers || {},
|
|
40
|
+
silent: !!options.silent,
|
|
41
|
+
checkForUpdates: options.checkForUpdates || false
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -60,7 +62,7 @@ class Validation {
|
|
|
60
62
|
*/
|
|
61
63
|
cacheSuboptions (input) {
|
|
62
64
|
if (typeof input !== 'object' || input === null) return false;
|
|
63
|
-
if (!input.noCacheCheck && !input.noCaching) return false;
|
|
65
|
+
if (!input.noCacheCheck && !input.noCaching && !input.raw) return false;
|
|
64
66
|
return true;
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -87,9 +89,9 @@ class Validation {
|
|
|
87
89
|
* @returns {void}
|
|
88
90
|
* @private
|
|
89
91
|
*/
|
|
90
|
-
validateNodeVersion() {
|
|
92
|
+
validateNodeVersion () {
|
|
91
93
|
const nodeVersion = parseInt(process.version.match(/v(\d{2})\.\d{1,}\.\d+/)[1], 10);
|
|
92
|
-
if (nodeVersion < 12
|
|
94
|
+
if (nodeVersion < 12) throw new Error(Errors.NODE_VERSION_ERR);
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
module.exports = Validation;
|
package/src/structures/Game.js
CHANGED
|
@@ -48,7 +48,7 @@ class Game {
|
|
|
48
48
|
* @type {GameId[]}
|
|
49
49
|
*/
|
|
50
50
|
static get IDS() {
|
|
51
|
-
return games.map((x)=>x.id);
|
|
51
|
+
return games.map((x) => x.id);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -56,7 +56,7 @@ class Game {
|
|
|
56
56
|
* @type {GameCode[]}
|
|
57
57
|
*/
|
|
58
58
|
static get CODES() {
|
|
59
|
-
return games.map((x)=>x.code);
|
|
59
|
+
return games.map((x) => x.code);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -64,7 +64,7 @@ class Game {
|
|
|
64
64
|
* @type {GameString[]}
|
|
65
65
|
*/
|
|
66
66
|
static get NAMES() {
|
|
67
|
-
return games.map((x)=>x.name);
|
|
67
|
+
return games.map((x) => x.name);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
@@ -9,8 +9,9 @@ const {getGuildLevel, parseHistory} = require('../../utils/guildExp');
|
|
|
9
9
|
class Guild {
|
|
10
10
|
/**
|
|
11
11
|
* @param {data} data Guild data
|
|
12
|
+
* @param {string} [me] Player uuid used to search for this guild
|
|
12
13
|
*/
|
|
13
|
-
constructor (data) {
|
|
14
|
+
constructor (data, me = '') {
|
|
14
15
|
/**
|
|
15
16
|
* Guild ID
|
|
16
17
|
* @type {string}
|
|
@@ -41,6 +42,11 @@ class Guild {
|
|
|
41
42
|
* @type {Array<GuildMember>}
|
|
42
43
|
*/
|
|
43
44
|
this.members = members(data);
|
|
45
|
+
/**
|
|
46
|
+
* Me, if a player UUID is used to get the guild
|
|
47
|
+
* @type {GuildMember|null}
|
|
48
|
+
*/
|
|
49
|
+
this.me = this.members.find((member) => member.uuid === me);
|
|
44
50
|
/**
|
|
45
51
|
* Guild ranks
|
|
46
52
|
* @type {Array<GuildRank>}
|
|
@@ -32,12 +32,12 @@ class Arcade {
|
|
|
32
32
|
* Weekly coins
|
|
33
33
|
* @type {number}
|
|
34
34
|
*/
|
|
35
|
-
this.weeklyCoins = parseInt(data[`weekly_coins_${weekAB()}`] || 0);
|
|
35
|
+
this.weeklyCoins = parseInt(data[`weekly_coins_${weekAB()}`] || 0, 10);
|
|
36
36
|
/**
|
|
37
37
|
* Monthly coins
|
|
38
38
|
* @type {number}
|
|
39
39
|
*/
|
|
40
|
-
this.monthlyCoins = parseInt(data[`monthly_coins_${monthAB()}`] || 0);
|
|
40
|
+
this.monthlyCoins = parseInt(data[`monthly_coins_${monthAB()}`] || 0, 10);
|
|
41
41
|
/**
|
|
42
42
|
* Hints Disabled
|
|
43
43
|
* @type {Boolean}
|
|
@@ -182,22 +182,22 @@ class BaseGame {
|
|
|
182
182
|
* Wins
|
|
183
183
|
* @type {?number}
|
|
184
184
|
*/
|
|
185
|
-
this.wins = parseInt(data['wins_' + gameName]) || 0;
|
|
185
|
+
this.wins = parseInt(data['wins_' + gameName], 10) || 0;
|
|
186
186
|
/**
|
|
187
187
|
* Kills, only available in combat games
|
|
188
188
|
* @type {?number}
|
|
189
189
|
*/
|
|
190
|
-
this.kills = parseInt(data['kills_' + gameName]) || 0;
|
|
190
|
+
this.kills = parseInt(data['kills_' + gameName], 10) || 0;
|
|
191
191
|
/**
|
|
192
192
|
* Deaths, only available in combat games
|
|
193
193
|
* @type {?number}
|
|
194
194
|
*/
|
|
195
|
-
this.deaths = parseInt(data['deaths_' + gameName]) || 0;
|
|
195
|
+
this.deaths = parseInt(data['deaths_' + gameName], 10) || 0;
|
|
196
196
|
/**
|
|
197
197
|
* Rounds Played, only available in Santa says, Simon Says, and HITW
|
|
198
198
|
* @type {?number}
|
|
199
199
|
*/
|
|
200
|
-
this.roundsPlayed = parseInt(data['rounds_' + gameName]) || 0;
|
|
200
|
+
this.roundsPlayed = parseInt(data['rounds_' + gameName], 10) || 0;
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
203
203
|
* Extend BaseGame without creating a new class
|
|
@@ -244,12 +244,12 @@ class GalaxyWars {
|
|
|
244
244
|
* Total weekly kills
|
|
245
245
|
* @type {number}
|
|
246
246
|
*/
|
|
247
|
-
this.weeklyKills = parseInt(data[`weekly_kills_${weekAB()}`] || 0);
|
|
247
|
+
this.weeklyKills = parseInt(data[`weekly_kills_${weekAB()}`] || 0, 10);
|
|
248
248
|
/**
|
|
249
249
|
* Total Monthly kills
|
|
250
250
|
* @type {number}
|
|
251
251
|
*/
|
|
252
|
-
this.monthlyKills = parseInt(data[`monthly_kills_${monthAB()}`] || 0);
|
|
252
|
+
this.monthlyKills = parseInt(data[`monthly_kills_${monthAB()}`] || 0, 10);
|
|
253
253
|
/**
|
|
254
254
|
* Attacker Kills
|
|
255
255
|
* @type {number}
|
|
@@ -105,6 +105,19 @@ class BedWars {
|
|
|
105
105
|
diamond: data.diamond_resources_collected_bedwars || 0,
|
|
106
106
|
emerald: data.emerald_resources_collected_bedwars || 0
|
|
107
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Loot chests
|
|
110
|
+
* @type {BedWarsLootChests}
|
|
111
|
+
*/
|
|
112
|
+
this.lootChests = {
|
|
113
|
+
christmas: data.bedwars_christmas_boxes || 0,
|
|
114
|
+
lunar: data.bedwars_lunar_boxes || 0,
|
|
115
|
+
normal: data.bedwars_boxes || 0,
|
|
116
|
+
easter: data.bedwars_easter_boxes || 0,
|
|
117
|
+
halloween: data.bedwars_halloween_boxes || 0,
|
|
118
|
+
golden: data.bedwars_golden_boxes || 0,
|
|
119
|
+
total: (data.bedwars_christmas_boxes + data.bedwars_lunar_boxes + data.bedwars_boxes + data.bedwars_easter_boxes + data.bedwars_halloween_boxes + data.bedwars_golden_boxes) || 0
|
|
120
|
+
};
|
|
108
121
|
/**
|
|
109
122
|
* Beds lost/broken/BL Ratio
|
|
110
123
|
* @type {BedWarsBeds}
|
|
@@ -291,6 +304,15 @@ function getLevelForExp (exp) {
|
|
|
291
304
|
* @property {number} diamond Diamond
|
|
292
305
|
* @property {number} emerald Emerald
|
|
293
306
|
*/
|
|
307
|
+
/**
|
|
308
|
+
* @typedef {object} BedWarsLootChests
|
|
309
|
+
* @property {number} christmas Christmas chests
|
|
310
|
+
* @property {number} halloween Halloween chests
|
|
311
|
+
* @property {number} easter Easter chests
|
|
312
|
+
* @property {number} christmas Christmas chests
|
|
313
|
+
* @property {number} golden Golden chests
|
|
314
|
+
* @property {number} normal Normal chests
|
|
315
|
+
*/
|
|
294
316
|
/**
|
|
295
317
|
* @typedef {object} BedWarsBeds
|
|
296
318
|
* @property {number} lost Beds lost
|