hypixel-api-reborn 10.0.0 → 11.0.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 +13 -0
- package/README.md +28 -16
- package/package.json +60 -58
- package/src/API/getAPIStatus.js +8 -8
- package/src/API/getBoosters.js +6 -6
- package/src/API/getGameCounts.js +6 -6
- package/src/API/getGuild.js +18 -18
- package/src/API/getLeaderboards.js +13 -13
- package/src/API/getPlayer.js +22 -27
- package/src/API/getRecentGames.js +18 -18
- package/src/API/getServerInfo.js +66 -77
- package/src/API/getStatus.js +8 -8
- package/src/API/getWatchdogStats.js +6 -6
- package/src/API/index.js +19 -23
- package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -10
- package/src/API/skyblock/getSkyblockAuctions.js +64 -64
- package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -11
- package/src/API/skyblock/getSkyblockBazaar.js +10 -10
- package/src/API/skyblock/getSkyblockMember.js +28 -25
- package/src/API/skyblock/getSkyblockNews.js +6 -6
- package/src/API/skyblock/getSkyblockProfiles.js +44 -41
- package/src/Client.js +406 -450
- package/src/Errors.js +44 -39
- package/src/Private/defaultCache.js +77 -78
- package/src/Private/rateLimit.js +79 -98
- package/src/Private/requests.js +65 -54
- package/src/Private/updater.js +45 -45
- package/src/Private/uuidCache.js +37 -33
- package/src/Private/validate.js +97 -97
- package/src/index.js +82 -83
- package/src/structures/APIIncident.js +78 -78
- package/src/structures/APIStatus.js +47 -47
- package/src/structures/Boosters/Booster.js +83 -87
- package/src/structures/Color.js +129 -129
- package/src/structures/Game.js +164 -160
- package/src/structures/GameCounts.js +151 -151
- package/src/structures/Guild/Guild.js +204 -218
- package/src/structures/Guild/GuildMember.js +66 -66
- package/src/structures/Guild/GuildRank.js +48 -48
- package/src/structures/ItemBytes.js +33 -36
- package/src/structures/Leaderboard.js +31 -31
- package/src/structures/MiniGames/Arcade.js +567 -569
- package/src/structures/MiniGames/ArenaBrawl.js +52 -56
- package/src/structures/MiniGames/BedWars.js +423 -351
- package/src/structures/MiniGames/BlitzSurvivalGames.js +172 -148
- package/src/structures/MiniGames/BuildBattle.js +53 -53
- package/src/structures/MiniGames/CopsAndCrims.js +90 -90
- package/src/structures/MiniGames/Duels.js +694 -630
- package/src/structures/MiniGames/MegaWalls.js +137 -137
- package/src/structures/MiniGames/MurderMystery.js +93 -93
- package/src/structures/MiniGames/Paintball.js +67 -67
- package/src/structures/MiniGames/Pit.js +19 -19
- package/src/structures/MiniGames/Quakecraft.js +101 -101
- package/src/structures/MiniGames/SkyWars.js +508 -559
- package/src/structures/MiniGames/SmashHeroes.js +144 -151
- package/src/structures/MiniGames/SpeedUHC.js +115 -57
- package/src/structures/MiniGames/TNTGames.js +116 -116
- package/src/structures/MiniGames/TurboKartRacers.js +201 -176
- package/src/structures/MiniGames/UHC.js +164 -143
- package/src/structures/MiniGames/VampireZ.js +60 -60
- package/src/structures/MiniGames/Walls.js +52 -52
- package/src/structures/MiniGames/Warlords.js +62 -62
- package/src/structures/MiniGames/WoolWars.js +123 -0
- package/src/structures/Pet.js +96 -97
- package/src/structures/Pets.js +64 -64
- package/src/structures/Player.js +433 -449
- package/src/structures/PlayerCosmetics.js +100 -95
- package/src/structures/RecentGame.js +57 -57
- package/src/structures/ServerInfo.js +78 -78
- package/src/structures/SkyBlock/Auctions/Auction.js +104 -104
- package/src/structures/SkyBlock/Auctions/AuctionInfo.js +54 -54
- package/src/structures/SkyBlock/Auctions/BaseAuction.js +45 -45
- package/src/structures/SkyBlock/Auctions/Bid.js +48 -48
- package/src/structures/SkyBlock/Auctions/PartialAuction.js +25 -25
- package/src/structures/SkyBlock/Bazzar/Order.js +38 -38
- package/src/structures/SkyBlock/Bazzar/Product.js +53 -53
- package/src/structures/SkyBlock/News/SkyblockNews.js +60 -68
- package/src/structures/SkyBlock/SkyblockInventoryItem.js +124 -130
- package/src/structures/SkyBlock/SkyblockMember.js +820 -687
- package/src/structures/SkyBlock/SkyblockPet.js +71 -71
- package/src/structures/SkyBlock/SkyblockProfile.js +60 -60
- package/src/structures/Status.js +41 -41
- package/src/structures/Watchdog/Stats.js +36 -36
- package/src/utils/Constants.js +2789 -809
- package/src/utils/SkyblockUtils.js +208 -164
- package/src/utils/arrayTools.js +4 -4
- package/src/utils/divide.js +5 -5
- package/src/utils/guildExp.js +57 -67
- package/src/utils/index.js +13 -13
- package/src/utils/isGuildID.js +3 -3
- package/src/utils/isUUID.js +5 -5
- package/src/utils/oscillation.js +15 -23
- package/src/utils/removeSnakeCase.js +22 -35
- package/src/utils/rgbToHexColor.js +8 -8
- package/src/utils/romanize.js +11 -13
- package/src/utils/toIGN.js +20 -20
- package/src/utils/toUuid.js +19 -19
- package/src/utils/varInt.js +17 -21
- package/typings/index.d.ts +3532 -2644
- package/src/API/getFriends.js +0 -14
- package/src/API/getKeyInfo.js +0 -10
- package/src/API/getRankedSkyWars.js +0 -11
- package/src/structures/Friend.js +0 -38
- package/src/structures/KeyInfo.js +0 -42
- package/src/structures/MiniGames/SkyWarsRanked.js +0 -45
package/.prettierrc
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bracketSameLine": true,
|
|
3
|
+
"trailingComma": "none",
|
|
4
|
+
"arrowParens": "always",
|
|
5
|
+
"bracketSpacing": true,
|
|
6
|
+
"proseWrap": "always",
|
|
7
|
+
"singleQuote": true,
|
|
8
|
+
"printWidth": 210,
|
|
9
|
+
"useTabs": false,
|
|
10
|
+
"tabWidth": 2,
|
|
11
|
+
"semi": true,
|
|
12
|
+
"endOfLine": "lf"
|
|
13
|
+
}
|
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
<div align="center">
|
|
3
2
|
<img src="https://i.imgur.com/cDFoQZU.png?1">
|
|
4
3
|
<h1>Hypixel API • Reborn</h1>
|
|
@@ -15,39 +14,52 @@
|
|
|
15
14
|
</div>
|
|
16
15
|
|
|
17
16
|
### Links
|
|
18
|
-
|
|
17
|
+
|
|
18
|
+
[Discord Support](https://discord.gg/NSEBNMM) | [Documentation](https://hypixel-api-reborn.github.io/) | [NPM](https://www.npmjs.com/package/hypixel-api-reborn) |
|
|
19
|
+
[GitHub](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn) | [ToDo](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/projects/1) | [CLI](https://github.com/Hypixel-API-Reborn/cli)
|
|
19
20
|
|
|
20
21
|
#### Requirements
|
|
21
22
|
|
|
22
|
-
**For Node.js users >= v14.x.x** <br>
|
|
23
|
-
**For TypeScript users >= v3.5**
|
|
23
|
+
**For Node.js users >= v14.x.x** <br> **For TypeScript users >= v3.5**
|
|
24
24
|
|
|
25
25
|
### Installation & Usage
|
|
26
|
+
|
|
26
27
|
```shell
|
|
27
28
|
npm i hypixel-api-reborn
|
|
28
29
|
```
|
|
30
|
+
|
|
29
31
|
```js
|
|
30
32
|
const Hypixel = require('hypixel-api-reborn');
|
|
31
33
|
const hypixel = new Hypixel.Client('API-KEY');
|
|
32
34
|
// https://stavzdev.is-inside.me/cCMiZdoy.gif
|
|
33
35
|
|
|
34
36
|
// getPlayer
|
|
35
|
-
hypixel
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
37
|
+
hypixel
|
|
38
|
+
.getPlayer('StavZDev')
|
|
39
|
+
.then((player) => {
|
|
40
|
+
console.log(player.level); // 141
|
|
41
|
+
})
|
|
42
|
+
.catch((e) => {
|
|
43
|
+
console.error(e);
|
|
44
|
+
});
|
|
40
45
|
|
|
41
46
|
// getGuild
|
|
42
|
-
hypixel
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
+
hypixel
|
|
48
|
+
.getGuild('name', 'The Foundation')
|
|
49
|
+
.then((guild) => {
|
|
50
|
+
console.log(guild.level); // 111
|
|
51
|
+
})
|
|
52
|
+
.catch((e) => {
|
|
53
|
+
console.error(e);
|
|
54
|
+
});
|
|
47
55
|
```
|
|
48
|
-
|
|
56
|
+
|
|
57
|
+
For more examples go to our [documentation](https://hypixel-api-reborn.github.io/).
|
|
58
|
+
|
|
49
59
|
## Changelog
|
|
50
|
-
|
|
60
|
+
|
|
61
|
+
[v11.0.0](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/releases/tag/11.0.0)
|
|
51
62
|
|
|
52
63
|
### Try it now
|
|
64
|
+
|
|
53
65
|
**[Code Sandbox](https://codesandbox.io/s/clever-babbage-xqmfw?file=/src/index.js)**
|
package/package.json
CHANGED
|
@@ -1,58 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hypixel-api-reborn",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Feature-rich Hypixel API wrapper for Node.js",
|
|
5
|
-
"main": "./src/index.js",
|
|
6
|
-
"types": "./typings/index.d.ts",
|
|
7
|
-
"keywords": [
|
|
8
|
-
"minecraft",
|
|
9
|
-
"client",
|
|
10
|
-
"hypixel",
|
|
11
|
-
"api",
|
|
12
|
-
"hypixel-api",
|
|
13
|
-
"intellisense"
|
|
14
|
-
],
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/issues"
|
|
17
|
-
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"eslint": "eslint src",
|
|
20
|
-
"eslint:fix": "eslint src --fix",
|
|
21
|
-
"lint:dev": "npm run eslint && npm run dtslint",
|
|
22
|
-
"test": "mocha tests --exit",
|
|
23
|
-
"
|
|
24
|
-
"docgen": "docgen -s src -o ../docs/master.json",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
},
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">=14.0.0"
|
|
31
|
-
},
|
|
32
|
-
"author": "StavZ",
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"node-fetch": "^2.6.1",
|
|
35
|
-
"object-path": "^0.11.8",
|
|
36
|
-
"prismarine-nbt": "^1.
|
|
37
|
-
"rss-parser": "^3.
|
|
38
|
-
},
|
|
39
|
-
"license": "MIT",
|
|
40
|
-
"readme": "https://hypixel.stavzdev.me/",
|
|
41
|
-
"repository": {
|
|
42
|
-
"url": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn"
|
|
43
|
-
},
|
|
44
|
-
"publisher": "StavZ",
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"@types/node": "^
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
48
|
-
"@typescript-eslint/parser": "^4.
|
|
49
|
-
"chai": "^4.3.4",
|
|
50
|
-
"dtslint": "^4.1.6",
|
|
51
|
-
"eslint": "^7.32.0",
|
|
52
|
-
"eslint-config-google": "^0.14.0",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "hypixel-api-reborn",
|
|
3
|
+
"version": "11.0.1",
|
|
4
|
+
"description": "Feature-rich Hypixel API wrapper for Node.js",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./typings/index.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"minecraft",
|
|
9
|
+
"client",
|
|
10
|
+
"hypixel",
|
|
11
|
+
"api",
|
|
12
|
+
"hypixel-api",
|
|
13
|
+
"intellisense"
|
|
14
|
+
],
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/issues"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"eslint": "npx eslint src/ typings/",
|
|
20
|
+
"eslint:fix": "npx eslint src/ typings/ --fix",
|
|
21
|
+
"lint:dev": "npm run eslint && npm run dtslint",
|
|
22
|
+
"test": "npx mocha tests --exit",
|
|
23
|
+
"docgen": "npx docgen -s src -o ../docs/master.json",
|
|
24
|
+
"docgen:custom": "npx docgen -s src --custom docs/index.yml -o ../docs/master.json",
|
|
25
|
+
"dtslint": "npx dtslint typings",
|
|
26
|
+
"prettier": "npx prettier --write src/ typings/",
|
|
27
|
+
"prettier:check": "npx prettier --check src/ typings/"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=14.0.0"
|
|
31
|
+
},
|
|
32
|
+
"author": "StavZ",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"node-fetch": "^2.6.1",
|
|
35
|
+
"object-path": "^0.11.8",
|
|
36
|
+
"prismarine-nbt": "^2.1.0",
|
|
37
|
+
"rss-parser": "^3.13.0"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"readme": "https://hypixel.stavzdev.me/",
|
|
41
|
+
"repository": {
|
|
42
|
+
"url": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn"
|
|
43
|
+
},
|
|
44
|
+
"publisher": "StavZ",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^20.6.5",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
48
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
49
|
+
"chai": "^4.3.4",
|
|
50
|
+
"dtslint": "^4.1.6",
|
|
51
|
+
"eslint": "^7.32.0",
|
|
52
|
+
"eslint-config-google": "^0.14.0",
|
|
53
|
+
"eslint-config-prettier": "^9.0.0",
|
|
54
|
+
"mocha": "^9.1.2",
|
|
55
|
+
"node-env-run": "^4.0.2",
|
|
56
|
+
"path": "^0.12.7",
|
|
57
|
+
"prettier": "^3.0.3",
|
|
58
|
+
"typescript": "^4.3.3"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/API/getAPIStatus.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const Rss = require('rss-parser');
|
|
2
|
-
const Parser = new Rss();
|
|
3
|
-
module.exports = async function (options) {
|
|
4
|
-
const Status = require('../structures/APIStatus.js');
|
|
5
|
-
const parsed = await Parser.parseURL('https://status.hypixel.net/history.rss');
|
|
6
|
-
if (options.raw) return parsed;
|
|
7
|
-
return new Status(parsed);
|
|
8
|
-
};
|
|
1
|
+
const Rss = require('rss-parser');
|
|
2
|
+
const Parser = new Rss();
|
|
3
|
+
module.exports = async function (options) {
|
|
4
|
+
const Status = require('../structures/APIStatus.js');
|
|
5
|
+
const parsed = await Parser.parseURL('https://status.hypixel.net/history.rss');
|
|
6
|
+
if (options.raw) return parsed;
|
|
7
|
+
return new Status(parsed);
|
|
8
|
+
};
|
package/src/API/getBoosters.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
module.exports = async function () {
|
|
2
|
-
const Booster = require('../structures/Boosters/Booster');
|
|
3
|
-
const res = await this._makeRequest('/boosters');
|
|
4
|
-
if (res.raw) return res;
|
|
5
|
-
return res.boosters.length ? res.boosters.map((b) => new Booster(b)).reverse() : [];
|
|
6
|
-
};
|
|
1
|
+
module.exports = async function () {
|
|
2
|
+
const Booster = require('../structures/Boosters/Booster');
|
|
3
|
+
const res = await this._makeRequest('/boosters');
|
|
4
|
+
if (res.raw) return res;
|
|
5
|
+
return res.boosters.length ? res.boosters.map((b) => new Booster(b)).reverse() : [];
|
|
6
|
+
};
|
package/src/API/getGameCounts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const GameCounts = require('../structures/GameCounts');
|
|
2
|
-
module.exports = async function () {
|
|
3
|
-
const res = await this._makeRequest('/counts');
|
|
4
|
-
if (res.raw) return res;
|
|
5
|
-
return new GameCounts(res);
|
|
6
|
-
};
|
|
1
|
+
const GameCounts = require('../structures/GameCounts');
|
|
2
|
+
module.exports = async function () {
|
|
3
|
+
const res = await this._makeRequest('/counts');
|
|
4
|
+
if (res.raw) return res;
|
|
5
|
+
return new GameCounts(res);
|
|
6
|
+
};
|
package/src/API/getGuild.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
const Errors = require('../Errors');
|
|
2
|
-
const toUuid = require('../utils/toUuid');
|
|
3
|
-
const isGuildID = require('../utils/isGuildID');
|
|
4
|
-
module.exports = async function (searchParameter, query) {
|
|
5
|
-
if (!query) throw new Error(Errors.NO_GUILD_QUERY);
|
|
6
|
-
const Guild = require('../structures/Guild/Guild');
|
|
7
|
-
if (searchParameter === 'id' && !isGuildID(query)) throw new Error(Errors.INVALID_GUILD_ID);
|
|
8
|
-
const isPlayerQuery = searchParameter === 'player';
|
|
9
|
-
if (isPlayerQuery) query = await toUuid(query);
|
|
10
|
-
if (!['id', 'name', 'player'].includes(searchParameter)) throw new Error(Errors.INVALID_GUILD_SEARCH_PARAMETER);
|
|
11
|
-
const res = await this._makeRequest(`/guild?${searchParameter}=${encodeURI(query)}`);
|
|
12
|
-
if (res.raw) return res;
|
|
13
|
-
if (!res.guild && searchParameter !== 'player') {
|
|
14
|
-
throw new Error(Errors.GUILD_DOES_NOT_EXIST);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return res.guild ? new Guild(res.guild, isPlayerQuery ? query : null) : null;
|
|
18
|
-
};
|
|
1
|
+
const Errors = require('../Errors');
|
|
2
|
+
const toUuid = require('../utils/toUuid');
|
|
3
|
+
const isGuildID = require('../utils/isGuildID');
|
|
4
|
+
module.exports = async function (searchParameter, query) {
|
|
5
|
+
if (!query) throw new Error(Errors.NO_GUILD_QUERY);
|
|
6
|
+
const Guild = require('../structures/Guild/Guild');
|
|
7
|
+
if (searchParameter === 'id' && !isGuildID(query)) throw new Error(Errors.INVALID_GUILD_ID);
|
|
8
|
+
const isPlayerQuery = searchParameter === 'player';
|
|
9
|
+
if (isPlayerQuery) query = await toUuid(query);
|
|
10
|
+
if (!['id', 'name', 'player'].includes(searchParameter)) throw new Error(Errors.INVALID_GUILD_SEARCH_PARAMETER);
|
|
11
|
+
const res = await this._makeRequest(`/guild?${searchParameter}=${encodeURI(query)}`);
|
|
12
|
+
if (res.raw) return res;
|
|
13
|
+
if (!res.guild && searchParameter !== 'player') {
|
|
14
|
+
throw new Error(Errors.GUILD_DOES_NOT_EXIST);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return res.guild ? new Guild(res.guild, isPlayerQuery ? query : null) : null;
|
|
18
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const Errors = require('../Errors');
|
|
2
|
-
module.exports = async function () {
|
|
3
|
-
const Leaderboard = require('../structures/Leaderboard');
|
|
4
|
-
const res = await this._makeRequest('/leaderboards');
|
|
5
|
-
if (res.raw) return res;
|
|
6
|
-
if (!res.leaderboards) throw new Error(Errors.SOMETHING_WENT_WRONG.replace(/{cause}/, 'Try again.'));
|
|
7
|
-
const lbnames = Object.create(require('../utils/Constants').leaderboardNames);
|
|
8
|
-
// eslint-disable-next-line guard-for-in
|
|
9
|
-
for (const name in lbnames) {
|
|
10
|
-
lbnames[name] = res.leaderboards[lbnames[name]].length ? res.leaderboards[lbnames[name]].map((lb) => new Leaderboard(lb)) : [];
|
|
11
|
-
}
|
|
12
|
-
return lbnames;
|
|
13
|
-
};
|
|
1
|
+
const Errors = require('../Errors');
|
|
2
|
+
module.exports = async function () {
|
|
3
|
+
const Leaderboard = require('../structures/Leaderboard');
|
|
4
|
+
const res = await this._makeRequest('/leaderboards');
|
|
5
|
+
if (res.raw) return res;
|
|
6
|
+
if (!res.leaderboards) throw new Error(Errors.SOMETHING_WENT_WRONG.replace(/{cause}/, 'Try again.'));
|
|
7
|
+
const lbnames = Object.create(require('../utils/Constants').leaderboardNames);
|
|
8
|
+
// eslint-disable-next-line guard-for-in
|
|
9
|
+
for (const name in lbnames) {
|
|
10
|
+
lbnames[name] = res.leaderboards[lbnames[name]].length ? res.leaderboards[lbnames[name]].map((lb) => new Leaderboard(lb)) : [];
|
|
11
|
+
}
|
|
12
|
+
return lbnames;
|
|
13
|
+
};
|
package/src/API/getPlayer.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
const Errors = require('../Errors');
|
|
2
|
-
const toUuid = require('../utils/toUuid');
|
|
3
|
-
const getGuild = require('./getGuild');
|
|
4
|
-
const getRecentGames = require('./getRecentGames');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (res.
|
|
12
|
-
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
rankedSW = getRankedSkyWars.call(this, query);
|
|
24
|
-
}
|
|
25
|
-
[guild, recentGames, rankedSW] = await Promise.all([guild, recentGames, rankedSW]);
|
|
26
|
-
return new Player(res.player, { guild, recentGames, rankedSW });
|
|
27
|
-
};
|
|
1
|
+
const Errors = require('../Errors');
|
|
2
|
+
const toUuid = require('../utils/toUuid');
|
|
3
|
+
const getGuild = require('./getGuild');
|
|
4
|
+
const getRecentGames = require('./getRecentGames');
|
|
5
|
+
module.exports = async function (query, options = { guild: false, recentGames: false }) {
|
|
6
|
+
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
7
|
+
const Player = require('../structures/Player');
|
|
8
|
+
query = await toUuid(query);
|
|
9
|
+
const res = await this._makeRequest(`/player?uuid=${query}`);
|
|
10
|
+
if (res.raw) return res;
|
|
11
|
+
if (query && !res.player) throw new Error(Errors.PLAYER_HAS_NEVER_LOGGED);
|
|
12
|
+
let guild = null;
|
|
13
|
+
let recentGames = null;
|
|
14
|
+
if (options.guild) {
|
|
15
|
+
guild = getGuild.call(this, 'player', query);
|
|
16
|
+
}
|
|
17
|
+
if (options.recentGames) {
|
|
18
|
+
recentGames = getRecentGames.call(this, query);
|
|
19
|
+
}
|
|
20
|
+
[guild, recentGames] = await Promise.all([guild, recentGames]);
|
|
21
|
+
return new Player(res.player, { guild, recentGames });
|
|
22
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
const Errors = require('../Errors');
|
|
2
|
-
const toUuid = require('../utils/toUuid');
|
|
3
|
-
const day3 = 1000 * 60 * 60 * 24 * 3;
|
|
4
|
-
module.exports = async function (query, playerData) {
|
|
5
|
-
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
6
|
-
const RecentGame = require('../structures/RecentGame');
|
|
7
|
-
|
|
8
|
-
query = await toUuid(query);
|
|
9
|
-
|
|
10
|
-
const res = await this._makeRequest(`/recentgames?uuid=${query}`);
|
|
11
|
-
if (res.raw) return res;
|
|
12
|
-
if (res.games === []) {
|
|
13
|
-
if (!playerData) throw new Error(Errors.PLAYER_IS_INACTIVE);
|
|
14
|
-
if (Date.now() - playerData.lastLogoutTimestamp < day3) throw new Error(Errors.PLAYER_DISABLED_ENDPOINT);
|
|
15
|
-
throw new Error(Errors.PLAYER_IS_INACTIVE);
|
|
16
|
-
}
|
|
17
|
-
return res.games.map((x) => new RecentGame(x));
|
|
18
|
-
};
|
|
1
|
+
const Errors = require('../Errors');
|
|
2
|
+
const toUuid = require('../utils/toUuid');
|
|
3
|
+
const day3 = 1000 * 60 * 60 * 24 * 3;
|
|
4
|
+
module.exports = async function (query, playerData) {
|
|
5
|
+
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
6
|
+
const RecentGame = require('../structures/RecentGame');
|
|
7
|
+
|
|
8
|
+
query = await toUuid(query);
|
|
9
|
+
|
|
10
|
+
const res = await this._makeRequest(`/recentgames?uuid=${query}`);
|
|
11
|
+
if (res.raw) return res;
|
|
12
|
+
if (res.games === []) {
|
|
13
|
+
if (!playerData) throw new Error(Errors.PLAYER_IS_INACTIVE);
|
|
14
|
+
if (Date.now() - playerData.lastLogoutTimestamp < day3) throw new Error(Errors.PLAYER_DISABLED_ENDPOINT);
|
|
15
|
+
throw new Error(Errors.PLAYER_IS_INACTIVE);
|
|
16
|
+
}
|
|
17
|
+
return res.games.map((x) => new RecentGame(x));
|
|
18
|
+
};
|
package/src/API/getServerInfo.js
CHANGED
|
@@ -1,77 +1,66 @@
|
|
|
1
|
-
const net = require('net');
|
|
2
|
-
const Errors = require('../Errors');
|
|
3
|
-
const ServerInfo = require('../structures/ServerInfo');
|
|
4
|
-
const varInt = require('../utils/varInt');
|
|
5
|
-
const packetsToSend = [
|
|
6
|
-
|
|
7
|
-
'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* @param {string} stringJson Parseable JSON string
|
|
68
|
-
* @param {number} ping Ping of the server
|
|
69
|
-
* @returns {Object} Object
|
|
70
|
-
*/
|
|
71
|
-
function parseData (stringJson, ping) {
|
|
72
|
-
try {
|
|
73
|
-
return new ServerInfo(JSON.parse(stringJson), ping);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
1
|
+
const net = require('net');
|
|
2
|
+
const Errors = require('../Errors');
|
|
3
|
+
const ServerInfo = require('../structures/ServerInfo');
|
|
4
|
+
const varInt = require('../utils/varInt');
|
|
5
|
+
const packetsToSend = ['1500E0050E6D632E6879706978656C2E6E657463DD01', '0100', '09010000000000000000'].map((x) => Buffer.from(x, 'hex')); // To avoid dependency hell, these are precompiled as hex.
|
|
6
|
+
module.exports = async function (repeats) {
|
|
7
|
+
if (repeats < 0 || typeof repeats !== 'number') repeats = 3;
|
|
8
|
+
if (repeats > 10) repeats = 10;
|
|
9
|
+
let aggregatedData = '';
|
|
10
|
+
let dataLength = 0;
|
|
11
|
+
return await new Promise((resolve, reject) => {
|
|
12
|
+
const cli = net.createConnection(25565, 'mc.hypixel.net', () => {
|
|
13
|
+
cli.write(packetsToSend[0]);
|
|
14
|
+
cli.write(packetsToSend[1]);
|
|
15
|
+
});
|
|
16
|
+
cli.on('error', () => {
|
|
17
|
+
reject(Errors.CONNECTION_ERROR);
|
|
18
|
+
});
|
|
19
|
+
cli.on('data', async (data) => {
|
|
20
|
+
if (!aggregatedData) {
|
|
21
|
+
const varIntBorder = data.findIndex((x) => x === 0x00) + 1;
|
|
22
|
+
dataLength = varInt(
|
|
23
|
+
data
|
|
24
|
+
.toString('hex', 0, varIntBorder)
|
|
25
|
+
.match(/(..)/g)
|
|
26
|
+
.map((x) => parseInt(x, 16))
|
|
27
|
+
);
|
|
28
|
+
dataLength -= varIntBorder * 8;
|
|
29
|
+
aggregatedData += data.toString('utf-8', 5);
|
|
30
|
+
} else aggregatedData += data.toString('utf-8');
|
|
31
|
+
|
|
32
|
+
if (dataLength >= aggregatedData.length) return;
|
|
33
|
+
cli.removeAllListeners('data'); // Remove this listener
|
|
34
|
+
resolve(parseData(aggregatedData, await getPing(repeats, cli)));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
// eslint-disable-next-line require-jsdoc
|
|
39
|
+
async function getPing(amount, cli) {
|
|
40
|
+
let pingSum = 0;
|
|
41
|
+
for (let i = 0; i < amount; i++) {
|
|
42
|
+
pingSum += await ping(cli);
|
|
43
|
+
}
|
|
44
|
+
cli.destroy();
|
|
45
|
+
return Math.round(pingSum / amount);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line require-jsdoc
|
|
49
|
+
async function ping(cli) {
|
|
50
|
+
await cli.write(packetsToSend[2]);
|
|
51
|
+
const time = Date.now();
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
cli.once('data', () => {
|
|
54
|
+
resolve(Date.now() - time);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line require-jsdoc
|
|
60
|
+
function parseData(stringJson, ping) {
|
|
61
|
+
try {
|
|
62
|
+
return new ServerInfo(JSON.parse(stringJson), ping);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/API/getStatus.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const toUuid = require('../utils/toUuid');
|
|
2
|
-
module.exports = async function (query) {
|
|
3
|
-
const Status = require('../structures/Status');
|
|
4
|
-
query = await toUuid(query);
|
|
5
|
-
const res = await this._makeRequest(`/status?uuid=${query}`);
|
|
6
|
-
if (res.raw) return res;
|
|
7
|
-
return new Status(res.session);
|
|
8
|
-
};
|
|
1
|
+
const toUuid = require('../utils/toUuid');
|
|
2
|
+
module.exports = async function (query) {
|
|
3
|
+
const Status = require('../structures/Status');
|
|
4
|
+
query = await toUuid(query);
|
|
5
|
+
const res = await this._makeRequest(`/status?uuid=${query}`);
|
|
6
|
+
if (res.raw) return res;
|
|
7
|
+
return new Status(res.session);
|
|
8
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
module.exports = async function () {
|
|
2
|
-
const WatchdogStats = require('../structures/Watchdog/Stats');
|
|
3
|
-
const res = await this._makeRequest('/punishmentstats');
|
|
4
|
-
if (res.raw) return res;
|
|
5
|
-
return new WatchdogStats(res);
|
|
6
|
-
};
|
|
1
|
+
module.exports = async function () {
|
|
2
|
+
const WatchdogStats = require('../structures/Watchdog/Stats');
|
|
3
|
+
const res = await this._makeRequest('/punishmentstats');
|
|
4
|
+
if (res.raw) return res;
|
|
5
|
+
return new WatchdogStats(res);
|
|
6
|
+
};
|
package/src/API/index.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
getAPIStatus: require('./getAPIStatus'),
|
|
3
|
-
getBoosters: require('./getBoosters'),
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
getSkyblockMember: require('./skyblock/getSkyblockMember'),
|
|
21
|
-
getSkyblockNews: require('./skyblock/getSkyblockNews'),
|
|
22
|
-
getSkyblockProfiles: require('./skyblock/getSkyblockProfiles')
|
|
23
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
getAPIStatus: require('./getAPIStatus'),
|
|
3
|
+
getBoosters: require('./getBoosters'),
|
|
4
|
+
getGameCounts: require('./getGameCounts'),
|
|
5
|
+
getGuild: require('./getGuild'),
|
|
6
|
+
getLeaderboards: require('./getLeaderboards'),
|
|
7
|
+
getPlayer: require('./getPlayer'),
|
|
8
|
+
getRecentGames: require('./getRecentGames'),
|
|
9
|
+
getServerInfo: require('./getServerInfo'),
|
|
10
|
+
getStatus: require('./getStatus'),
|
|
11
|
+
getWatchdogStats: require('./getWatchdogStats'),
|
|
12
|
+
getEndedSkyblockAuctions: require('./skyblock/getEndedSkyblockAuctions'),
|
|
13
|
+
getSkyblockAuctions: require('./skyblock/getSkyblockAuctions'),
|
|
14
|
+
getSkyblockAuctionsByPlayer: require('./skyblock/getSkyblockAuctionsByPlayer'),
|
|
15
|
+
getSkyblockBazaar: require('./skyblock/getSkyblockBazaar'),
|
|
16
|
+
getSkyblockMember: require('./skyblock/getSkyblockMember'),
|
|
17
|
+
getSkyblockNews: require('./skyblock/getSkyblockNews'),
|
|
18
|
+
getSkyblockProfiles: require('./skyblock/getSkyblockProfiles')
|
|
19
|
+
};
|