hypixel-api-reborn 11.0.1 → 11.2.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.
Files changed (96) hide show
  1. package/.prettierrc +13 -13
  2. package/LICENSE +20 -20
  3. package/README.md +67 -65
  4. package/package.json +20 -18
  5. package/src/API/getAPIStatus.js +1 -1
  6. package/src/API/getAchievements.js +6 -0
  7. package/src/API/getChallenges.js +6 -0
  8. package/src/API/getGuild.js +1 -1
  9. package/src/API/getGuildAchievements.js +6 -0
  10. package/src/API/getLeaderboards.js +3 -1
  11. package/src/API/getPlayer.js +1 -1
  12. package/src/API/getQuests.js +6 -0
  13. package/src/API/getRecentGames.js +1 -1
  14. package/src/API/getServerInfo.js +3 -1
  15. package/src/API/getStatus.js +1 -1
  16. package/src/API/index.js +28 -17
  17. package/src/API/skyblock/getAuction.js +19 -0
  18. package/src/API/skyblock/{getSkyblockAuctions.js → getAuctions.js} +6 -2
  19. package/src/API/skyblock/{getSkyblockAuctionsByPlayer.js → getAuctionsByPlayer.js} +1 -1
  20. package/src/API/skyblock/getBingo.js +8 -0
  21. package/src/API/skyblock/getBingoByPlayer.js +14 -0
  22. package/src/API/skyblock/getFireSales.js +7 -0
  23. package/src/API/skyblock/getGovernment.js +8 -0
  24. package/src/API/skyblock/{getSkyblockMember.js → getMember.js} +10 -6
  25. package/src/API/skyblock/getMuseum.js +14 -0
  26. package/src/API/skyblock/{getSkyblockProfiles.js → getProfiles.js} +14 -12
  27. package/src/Client.js +91 -17
  28. package/src/Errors.js +39 -17
  29. package/src/Private/rateLimit.js +10 -2
  30. package/src/Private/requests.js +20 -8
  31. package/src/Private/updater.js +10 -20
  32. package/src/Private/uuidCache.js +23 -29
  33. package/src/Private/validate.js +20 -9
  34. package/src/index.js +9 -0
  35. package/src/structures/APIIncident.js +3 -9
  36. package/src/structures/Boosters/Booster.js +5 -5
  37. package/src/structures/Color.js +93 -48
  38. package/src/structures/Game.js +3 -1
  39. package/src/structures/Guild/Guild.js +21 -17
  40. package/src/structures/Guild/GuildMember.js +6 -6
  41. package/src/structures/Guild/GuildRank.js +2 -2
  42. package/src/structures/MiniGames/Arcade.js +22 -17
  43. package/src/structures/MiniGames/BedWars.js +152 -24
  44. package/src/structures/MiniGames/Duels.js +84 -23
  45. package/src/structures/MiniGames/MegaWalls.js +3 -1
  46. package/src/structures/MiniGames/MurderMystery.js +2 -2
  47. package/src/structures/MiniGames/Pit.js +231 -2
  48. package/src/structures/MiniGames/PitInventoryItem.js +43 -0
  49. package/src/structures/MiniGames/SkyWars.js +19 -14
  50. package/src/structures/MiniGames/SmashHeroes.js +1 -1
  51. package/src/structures/MiniGames/TNTGames.js +1 -1
  52. package/src/structures/MiniGames/UHC.js +21 -3
  53. package/src/structures/MiniGames/WoolWars.js +1 -1
  54. package/src/structures/Player.js +16 -20
  55. package/src/structures/PlayerCosmetics.js +64 -10
  56. package/src/structures/ServerInfo.js +1 -1
  57. package/src/structures/SkyBlock/Auctions/Auction.js +3 -1
  58. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +1 -0
  59. package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -0
  60. package/src/structures/SkyBlock/Auctions/Bid.js +1 -0
  61. package/src/structures/SkyBlock/Auctions/PartialAuction.js +1 -0
  62. package/src/structures/SkyBlock/PlayerBingo.js +56 -0
  63. package/src/structures/SkyBlock/SkyblockInventoryItem.js +86 -18
  64. package/src/structures/SkyBlock/SkyblockMember.js +252 -144
  65. package/src/structures/SkyBlock/SkyblockMuseum.js +60 -0
  66. package/src/structures/SkyBlock/SkyblockMuseumItem.js +54 -0
  67. package/src/structures/SkyBlock/SkyblockPet.js +1 -0
  68. package/src/structures/SkyBlock/SkyblockProfile.js +37 -23
  69. package/src/structures/SkyBlock/Static/Bingo.js +102 -0
  70. package/src/structures/SkyBlock/Static/BingoData.js +45 -0
  71. package/src/structures/SkyBlock/Static/Candidate.js +40 -0
  72. package/src/structures/SkyBlock/Static/FireSale.js +55 -0
  73. package/src/structures/SkyBlock/Static/Government.js +74 -0
  74. package/src/structures/SkyBlock/Static/Perk.js +24 -0
  75. package/src/structures/Static/Achievement.js +86 -0
  76. package/src/structures/Static/AchievementTier.js +33 -0
  77. package/src/structures/Static/Achievements.js +30 -0
  78. package/src/structures/Static/Challenges.js +29 -0
  79. package/src/structures/Static/GameAchievements.js +36 -0
  80. package/src/structures/Static/GameChallenges.js +40 -0
  81. package/src/structures/Static/GameQuests.js +24 -0
  82. package/src/structures/Static/GuildAchievements.js +34 -0
  83. package/src/structures/Static/Quest.js +66 -0
  84. package/src/structures/Static/Quests.js +31 -0
  85. package/src/structures/Status.js +2 -2
  86. package/src/utils/Constants.js +385 -42
  87. package/src/utils/SkyblockUtils.js +12 -7
  88. package/src/utils/guildExp.js +4 -1
  89. package/src/utils/removeSnakeCase.js +9 -2
  90. package/src/utils/romanize.js +32 -1
  91. package/src/utils/toIGN.js +6 -2
  92. package/src/utils/toUuid.js +10 -5
  93. package/typings/index.d.ts +989 -297
  94. /package/src/API/skyblock/{getSkyblockBazaar.js → getBazaar.js} +0 -0
  95. /package/src/API/skyblock/{getEndedSkyblockAuctions.js → getEndedAuctions.js} +0 -0
  96. /package/src/API/skyblock/{getSkyblockNews.js → getNews.js} +0 -0
package/.prettierrc CHANGED
@@ -1,13 +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
- }
1
+ {
2
+ "bracketSameLine": true,
3
+ "trailingComma": "none",
4
+ "arrowParens": "always",
5
+ "bracketSpacing": true,
6
+ "proseWrap": "always",
7
+ "singleQuote": true,
8
+ "printWidth": 120,
9
+ "endOfLine": "lf",
10
+ "useTabs": false,
11
+ "tabWidth": 2,
12
+ "semi": true
13
+ }
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 StavZDev
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2020 StavZDev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,65 +1,67 @@
1
- <div align="center">
2
- <img src="https://i.imgur.com/cDFoQZU.png?1">
3
- <h1>Hypixel API • Reborn</h1>
4
- <a href="https://discord.gg/NSEBNMM"><img src="https://discordapp.com/api/guilds/660416184252104705/embed.png"></a>
5
- <a href="https://travis-ci.org/StavZ/hypixel-api-reborn"><img src="https://flat.badgen.net/travis/hypixel-api-reborn/hypixel-api-reborn"></a>
6
- <a href="https://app.codacy.com/gh/Hypixel-API-Reborn/hypixel-api-reborn?utm_source=github.com&utm_medium=referral&utm_content=Hypixel-API-Reborn/hypixel-api-reborn&utm_campaign=Badge_Grade"><img src="https://flat.badgen.net/codacy/grade/71cd7e95499b496cb2dd11c29b9def33/master"></a>
7
- <img src="https://flat.badgen.net/npm/v/hypixel-api-reborn">
8
- <img src="https://flat.badgen.net/npm/node/hypixel-api-reborn">
9
- <img src="https://flat.badgen.net/npm/license/hypixel-api-reborn">
10
- <a href="https://github.com/Hypixel-API-Reborn/hypixel-api-reborn"><img src="https://flat.badgen.net/github/stars/hypixel-api-reborn/hypixel-api-reborn"></a>
11
- <a href="https://www.npmjs.com/package/hypixel-api-reborn"><img src="https://nodei.co/npm/hypixel-api-reborn.png?compact=true"></a>
12
- <h2>A feature-rich Hypixel API wrapper for Node.js</h2>
13
- <br>
14
- </div>
15
-
16
- ### Links
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)
20
-
21
- #### Requirements
22
-
23
- **For Node.js users >= v14.x.x** <br> **For TypeScript users >= v3.5**
24
-
25
- ### Installation & Usage
26
-
27
- ```shell
28
- npm i hypixel-api-reborn
29
- ```
30
-
31
- ```js
32
- const Hypixel = require('hypixel-api-reborn');
33
- const hypixel = new Hypixel.Client('API-KEY');
34
- // https://stavzdev.is-inside.me/cCMiZdoy.gif
35
-
36
- // getPlayer
37
- hypixel
38
- .getPlayer('StavZDev')
39
- .then((player) => {
40
- console.log(player.level); // 141
41
- })
42
- .catch((e) => {
43
- console.error(e);
44
- });
45
-
46
- // getGuild
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
- });
55
- ```
56
-
57
- For more examples go to our [documentation](https://hypixel-api-reborn.github.io/).
58
-
59
- ## Changelog
60
-
61
- [v11.0.0](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/releases/tag/11.0.0)
62
-
63
- ### Try it now
64
-
65
- **[Code Sandbox](https://codesandbox.io/s/clever-babbage-xqmfw?file=/src/index.js)**
1
+ <div align="center">
2
+ <img src="https://i.imgur.com/cDFoQZU.png?1">
3
+ <h1>Hypixel API • Reborn</h1>
4
+ <a href="https://discord.gg/NSEBNMM"><img src="https://discordapp.com/api/guilds/660416184252104705/embed.png"></a>
5
+ <a href="https://travis-ci.org/StavZ/hypixel-api-reborn"><img src="https://flat.badgen.net/travis/hypixel-api-reborn/hypixel-api-reborn"></a>
6
+ <a href="https://app.codacy.com/gh/Hypixel-API-Reborn/hypixel-api-reborn?utm_source=github.com&utm_medium=referral&utm_content=Hypixel-API-Reborn/hypixel-api-reborn&utm_campaign=Badge_Grade"><img src="https://flat.badgen.net/codacy/grade/71cd7e95499b496cb2dd11c29b9def33/master"></a>
7
+ <img src="https://flat.badgen.net/npm/v/hypixel-api-reborn">
8
+ <img src="https://flat.badgen.net/npm/node/hypixel-api-reborn">
9
+ <img src="https://flat.badgen.net/npm/license/hypixel-api-reborn">
10
+ <a href="https://github.com/Hypixel-API-Reborn/hypixel-api-reborn"><img src="https://flat.badgen.net/github/stars/hypixel-api-reborn/hypixel-api-reborn"></a>
11
+ <a href="https://www.npmjs.com/package/hypixel-api-reborn"><img src="https://nodei.co/npm/hypixel-api-reborn.png?compact=true"></a>
12
+ <h2>A feature-rich Hypixel API wrapper for Node.js</h2>
13
+ <br>
14
+ </div>
15
+
16
+ ### Links
17
+
18
+ [Discord Support](https://discord.gg/NSEBNMM) | [Documentation](https://hypixel-api-reborn.github.io/) |
19
+ [NPM](https://www.npmjs.com/package/hypixel-api-reborn) |
20
+ [GitHub](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn) |
21
+ [ToDo](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/projects/1) |
22
+ [CLI](https://github.com/Hypixel-API-Reborn/cli)
23
+
24
+ #### Requirements
25
+
26
+ **For Node.js users >= v14.x.x** <br> **For TypeScript users >= v3.5**
27
+
28
+ ### Installation & Usage
29
+
30
+ ```shell
31
+ npm i hypixel-api-reborn
32
+ ```
33
+
34
+ ```js
35
+ const Hypixel = require('hypixel-api-reborn');
36
+ const hypixel = new Hypixel.Client('API-KEY');
37
+
38
+ // getPlayer
39
+ hypixel
40
+ .getPlayer('StavZDev')
41
+ .then((player) => {
42
+ console.log(player.level); // 141
43
+ })
44
+ .catch((e) => {
45
+ console.error(e);
46
+ });
47
+
48
+ // getGuild
49
+ hypixel
50
+ .getGuild('name', 'The Foundation')
51
+ .then((guild) => {
52
+ console.log(guild.level); // 111
53
+ })
54
+ .catch((e) => {
55
+ console.error(e);
56
+ });
57
+ ```
58
+
59
+ For more examples go to our [documentation](https://hypixel-api-reborn.github.io/).
60
+
61
+ ## Changelog
62
+
63
+ [v11.0.0](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/releases/tag/11.0.0)
64
+
65
+ ### Try it now
66
+
67
+ **[Code Sandbox](https://codesandbox.io/s/clever-babbage-xqmfw?file=/src/index.js)**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypixel-api-reborn",
3
- "version": "11.0.1",
3
+ "version": "11.2.0",
4
4
  "description": "Feature-rich Hypixel API wrapper for Node.js",
5
5
  "main": "./src/index.js",
6
6
  "types": "./typings/index.d.ts",
@@ -16,12 +16,11 @@
16
16
  "url": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/issues"
17
17
  },
18
18
  "scripts": {
19
- "eslint": "npx eslint src/ typings/",
20
- "eslint:fix": "npx eslint src/ typings/ --fix",
19
+ "lint": "npx eslint src/ typings/",
20
+ "lint:fix": "npx eslint src/ typings/ --fix",
21
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",
22
+ "tests": "npx mocha tests --exit --recursive",
23
+ "docgen": "npx docgen -s src -o ./master.json",
25
24
  "dtslint": "npx dtslint typings",
26
25
  "prettier": "npx prettier --write src/ typings/",
27
26
  "prettier:check": "npx prettier --check src/ typings/"
@@ -31,10 +30,12 @@
31
30
  },
32
31
  "author": "StavZ",
33
32
  "dependencies": {
34
- "node-fetch": "^2.6.1",
33
+ "node-cache": "^5.1.2",
34
+ "node-fetch": "^3.3.2",
35
35
  "object-path": "^0.11.8",
36
- "prismarine-nbt": "^2.1.0",
37
- "rss-parser": "^3.13.0"
36
+ "prismarine-nbt": "^2.5.0",
37
+ "rss-parser": "^3.13.0",
38
+ "skyhelper-networth": "^1.19.0"
38
39
  },
39
40
  "license": "MIT",
40
41
  "readme": "https://hypixel.stavzdev.me/",
@@ -43,18 +44,19 @@
43
44
  },
44
45
  "publisher": "StavZ",
45
46
  "devDependencies": {
46
- "@types/node": "^20.6.5",
47
- "@typescript-eslint/eslint-plugin": "^4.33.0",
48
- "@typescript-eslint/parser": "^4.33.0",
47
+ "@discordjs/docgen": "github:discordjs/docgen",
48
+ "@types/node": "^20.11.19",
49
+ "@typescript-eslint/eslint-plugin": "^7.0.2",
50
+ "@typescript-eslint/parser": "^7.0.2",
49
51
  "chai": "^4.3.4",
50
- "dtslint": "^4.1.6",
51
- "eslint": "^7.32.0",
52
+ "dtslint": "^4.2.1",
53
+ "eslint": "^8.56.0",
52
54
  "eslint-config-google": "^0.14.0",
53
- "eslint-config-prettier": "^9.0.0",
54
- "mocha": "^9.1.2",
55
+ "eslint-config-prettier": "^9.1.0",
56
+ "mocha": "^10.4.0",
55
57
  "node-env-run": "^4.0.2",
56
58
  "path": "^0.12.7",
57
- "prettier": "^3.0.3",
58
- "typescript": "^4.3.3"
59
+ "prettier": "^3.2.5",
60
+ "typescript": "^5.3.3"
59
61
  }
60
62
  }
@@ -3,6 +3,6 @@ const Parser = new Rss();
3
3
  module.exports = async function (options) {
4
4
  const Status = require('../structures/APIStatus.js');
5
5
  const parsed = await Parser.parseURL('https://status.hypixel.net/history.rss');
6
- if (options.raw) return parsed;
6
+ if (options && options.raw) return parsed;
7
7
  return new Status(parsed);
8
8
  };
@@ -0,0 +1,6 @@
1
+ module.exports = async function () {
2
+ const Achievements = require('../structures/Static/Achievements');
3
+ const res = await this._makeRequest('/resources/achievements');
4
+ if (res.raw) return res;
5
+ return new Achievements(res);
6
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = async function () {
2
+ const Challenges = require('../structures/Static/Challenges');
3
+ const res = await this._makeRequest('/resources/challenges');
4
+ if (res.raw) return res;
5
+ return new Challenges(res);
6
+ };
@@ -6,7 +6,7 @@ module.exports = async function (searchParameter, query) {
6
6
  const Guild = require('../structures/Guild/Guild');
7
7
  if (searchParameter === 'id' && !isGuildID(query)) throw new Error(Errors.INVALID_GUILD_ID);
8
8
  const isPlayerQuery = searchParameter === 'player';
9
- if (isPlayerQuery) query = await toUuid(query);
9
+ if (isPlayerQuery) query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
10
10
  if (!['id', 'name', 'player'].includes(searchParameter)) throw new Error(Errors.INVALID_GUILD_SEARCH_PARAMETER);
11
11
  const res = await this._makeRequest(`/guild?${searchParameter}=${encodeURI(query)}`);
12
12
  if (res.raw) return res;
@@ -0,0 +1,6 @@
1
+ module.exports = async function () {
2
+ const GuildAchievements = require('../structures/Static/GuildAchievements');
3
+ const res = await this._makeRequest('/resources/guilds/achievements');
4
+ if (res.raw) return res;
5
+ return new GuildAchievements(res);
6
+ };
@@ -7,7 +7,9 @@ module.exports = async function () {
7
7
  const lbnames = Object.create(require('../utils/Constants').leaderboardNames);
8
8
  // eslint-disable-next-line guard-for-in
9
9
  for (const name in lbnames) {
10
- lbnames[name] = res.leaderboards[lbnames[name]].length ? res.leaderboards[lbnames[name]].map((lb) => new Leaderboard(lb)) : [];
10
+ lbnames[name] = res.leaderboards[lbnames[name]].length
11
+ ? res.leaderboards[lbnames[name]].map((lb) => new Leaderboard(lb))
12
+ : [];
11
13
  }
12
14
  return lbnames;
13
15
  };
@@ -5,7 +5,7 @@ const getRecentGames = require('./getRecentGames');
5
5
  module.exports = async function (query, options = { guild: false, recentGames: false }) {
6
6
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
7
7
  const Player = require('../structures/Player');
8
- query = await toUuid(query);
8
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
9
9
  const res = await this._makeRequest(`/player?uuid=${query}`);
10
10
  if (res.raw) return res;
11
11
  if (query && !res.player) throw new Error(Errors.PLAYER_HAS_NEVER_LOGGED);
@@ -0,0 +1,6 @@
1
+ module.exports = async function () {
2
+ const Quests = require('../structures/Static/Quests');
3
+ const res = await this._makeRequest('/resources/quests');
4
+ if (res.raw) return res;
5
+ return new Quests(res);
6
+ };
@@ -5,7 +5,7 @@ module.exports = async function (query, playerData) {
5
5
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
6
6
  const RecentGame = require('../structures/RecentGame');
7
7
 
8
- query = await toUuid(query);
8
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
9
9
 
10
10
  const res = await this._makeRequest(`/recentgames?uuid=${query}`);
11
11
  if (res.raw) return res;
@@ -2,7 +2,9 @@ const net = require('net');
2
2
  const Errors = require('../Errors');
3
3
  const ServerInfo = require('../structures/ServerInfo');
4
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.
5
+ const packetsToSend = ['1500E0050E6D632E6879706978656C2E6E657463DD01', '0100', '09010000000000000000'].map((x) =>
6
+ Buffer.from(x, 'hex')
7
+ ); // To avoid dependency hell, these are precompiled as hex.
6
8
  module.exports = async function (repeats) {
7
9
  if (repeats < 0 || typeof repeats !== 'number') repeats = 3;
8
10
  if (repeats > 10) repeats = 10;
@@ -1,7 +1,7 @@
1
1
  const toUuid = require('../utils/toUuid');
2
2
  module.exports = async function (query) {
3
3
  const Status = require('../structures/Status');
4
- query = await toUuid(query);
4
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
5
5
  const res = await this._makeRequest(`/status?uuid=${query}`);
6
6
  if (res.raw) return res;
7
7
  return new Status(res.session);
package/src/API/index.js CHANGED
@@ -1,19 +1,30 @@
1
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')
2
+ getAchievements: require('./getAchievements.js'),
3
+ getAPIStatus: require('./getAPIStatus.js'),
4
+ getBoosters: require('./getBoosters.js'),
5
+ getChallenges: require('./getChallenges.js'),
6
+ getGameCounts: require('./getGameCounts.js'),
7
+ getGuild: require('./getGuild.js'),
8
+ getGuildAchievements: require('./getGuildAchievements.js'),
9
+ getLeaderboards: require('./getLeaderboards.js'),
10
+ getPlayer: require('./getPlayer.js'),
11
+ getQuests: require('./getQuests.js'),
12
+ getRecentGames: require('./getRecentGames.js'),
13
+ getServerInfo: require('./getServerInfo.js'),
14
+ getStatus: require('./getStatus.js'),
15
+ getWatchdogStats: require('./getWatchdogStats.js'),
16
+
17
+ getSkyblockAuction: require('./skyblock/getAuction.js'),
18
+ getSkyblockAuctions: require('./skyblock/getAuctions.js'),
19
+ getSkyblockAuctionsByPlayer: require('./skyblock/getAuctionsByPlayer.js'),
20
+ getSkyblockBazaar: require('./skyblock/getBazaar.js'),
21
+ getSkyblockBingo: require('./skyblock/getBingo.js'),
22
+ getSkyblockBingoByPlayer: require('./skyblock/getBingoByPlayer.js'),
23
+ getSkyblockEndedAuctions: require('./skyblock/getEndedAuctions.js'),
24
+ getSkyblockFireSales: require('./skyblock/getFireSales.js'),
25
+ getSkyblockGovernment: require('./skyblock/getGovernment.js'),
26
+ getSkyblockMember: require('./skyblock/getMember.js'),
27
+ getSkyblockMuseum: require('./skyblock/getMuseum.js'),
28
+ getSkyblockNews: require('./skyblock/getNews.js'),
29
+ getSkyblockProfiles: require('./skyblock/getProfiles.js')
19
30
  };
@@ -0,0 +1,19 @@
1
+ const Errors = require('../../Errors');
2
+ const toUuid = require('../../utils/toUuid');
3
+ module.exports = async function (type, query, includeItemBytes = false) {
4
+ if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
5
+ const Auction = require('../../structures/SkyBlock/Auctions/Auction');
6
+ let filter = '';
7
+ if (type === 'PROFILE') {
8
+ filter = 'profile';
9
+ } else if (type === 'PLAYER') {
10
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
11
+ filter = 'player';
12
+ } else if (type === 'AUCTION') {
13
+ filter = 'uuid';
14
+ } else throw new Error(Errors.BAD_AUCTION_FILTER);
15
+ const res = await this._makeRequest(`/skyblock/auction?${filter}=${query}`);
16
+ if (res.raw) return res;
17
+
18
+ return res.auctions.length ? res.auctions.map((a) => new Auction(a, includeItemBytes)) : [];
19
+ };
@@ -30,8 +30,12 @@ module.exports = async function (range, options = {}) {
30
30
  if (range == null || range === '*') range = [0, (await getPage(0, { noAuctions: true })).info.totalPages];
31
31
  if (!Array.isArray(range)) range = [parseInt(range), parseInt(range)];
32
32
  if (isNaN(range[0])) throw new Error(Errors.PAGE_INDEX_ERROR);
33
- if (parseInt(options.retries) !== options.retries || options.retries > 10 || options.retries < 0) throw new Error(Errors.INVALID_OPTION_VALUE);
34
- if (parseInt(options.cooldown) !== options.cooldown || options.cooldown > 3000 || options.cooldown < 0) throw new Error(Errors.INVALID_OPTION_VALUE);
33
+ if (parseInt(options.retries) !== options.retries || options.retries > 10 || options.retries < 0) {
34
+ throw new Error(Errors.INVALID_OPTION_VALUE);
35
+ }
36
+ if (parseInt(options.cooldown) !== options.cooldown || options.cooldown > 3000 || options.cooldown < 0) {
37
+ throw new Error(Errors.INVALID_OPTION_VALUE);
38
+ }
35
39
  range = range.sort();
36
40
  const result = { auctions: [] };
37
41
  const fetches = [];
@@ -3,7 +3,7 @@ const toUuid = require('../../utils/toUuid');
3
3
  module.exports = async function (query, includeItemBytes = false) {
4
4
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
5
5
  const Auction = require('../../structures/SkyBlock/Auctions/Auction');
6
- query = await toUuid(query);
6
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
7
7
  const res = await this._makeRequest(`/skyblock/auction?player=${query}`);
8
8
  if (res.raw) return res;
9
9
 
@@ -0,0 +1,8 @@
1
+ module.exports = async function () {
2
+ const BingoData = require('../../structures/SkyBlock/Static/BingoData');
3
+
4
+ const res = await this._makeRequest('/resources/skyblock/bingo');
5
+ if (res.raw) return res;
6
+
7
+ return new BingoData(res);
8
+ };
@@ -0,0 +1,14 @@
1
+ const getBingo = require('./getBingo');
2
+ const toUuid = require('../../utils/toUuid');
3
+ const Errors = require('../../Errors');
4
+ module.exports = async function (query, { fetchBingoData = false }) {
5
+ if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
6
+ const PlayerBingo = require('../../structures/SkyBlock/PlayerBingo');
7
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
8
+ const res = await this._makeRequest(`/skyblock/uuid?player=${query}`);
9
+ if (res.raw) return res;
10
+ let bingoData = null;
11
+ if (fetchBingoData) bingoData = await getBingo.call(this);
12
+
13
+ return new PlayerBingo(data, bingoData);
14
+ };
@@ -0,0 +1,7 @@
1
+ module.exports = async function () {
2
+ const FireSale = require('../../structures/SkyBlock/Static/FireSale');
3
+ const res = await this._makeRequest('/skyblock/firesales');
4
+ if (res.raw) return res;
5
+
6
+ return res.sales.length ? res.sales.map((a) => new FireSale(a)) : [];
7
+ };
@@ -0,0 +1,8 @@
1
+ module.exports = async function () {
2
+ const GovernmentData = require('../../structures/SkyBlock/Static/Government.js');
3
+
4
+ const res = await this._makeRequest('/resources/skyblock/election');
5
+ if (res.raw) return res;
6
+
7
+ return new GovernmentData(res);
8
+ };
@@ -1,15 +1,14 @@
1
1
  const Errors = require('../../Errors');
2
2
  const toUuid = require('../../utils/toUuid');
3
3
  const getPlayer = require('../getPlayer');
4
- module.exports = async function (query, options = { fetchPlayer: false }) {
4
+ module.exports = async function (query, options = { fetchPlayer: false, getMuseum: false }) {
5
5
  const SkyblockMember = require('../../structures/SkyBlock/SkyblockMember');
6
+ const getSkyblockMuseum = require('../skyblock/getMuseum');
6
7
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
7
- query = await toUuid(query);
8
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
8
9
  const res = await this._makeRequest(`/skyblock/profiles?uuid=${query}`);
9
10
  if (res.raw) return res;
10
- if (!res.profiles || !res.profiles.length) {
11
- return new Map();
12
- }
11
+ if (!res.profiles || !res.profiles.length) throw new Error(Errors.NO_SKYBLOCK_PROFILES);
13
12
  const player = options.fetchPlayer ? await getPlayer.call(this, query, options) : null;
14
13
  const memberByProfileName = new Map();
15
14
  for (const profile of res.profiles) {
@@ -18,9 +17,14 @@ module.exports = async function (query, options = { fetchPlayer: false }) {
18
17
  profile.cute_name,
19
18
  new SkyblockMember({
20
19
  uuid: query,
20
+ profileId: profile.profile_id,
21
21
  profileName: profile.cute_name,
22
22
  gameMode: profile.game_mode || null,
23
- m: profile.members[query]
23
+ m: profile.members[query],
24
+ banking: profile.banking,
25
+ communityUpgrades: profile.community_upgrades,
26
+ museum: options.getMuseum ? await getSkyblockMuseum.call(this, query, profile.profile_id) : null,
27
+ selected: profile.selected
24
28
  })
25
29
  );
26
30
  }
@@ -0,0 +1,14 @@
1
+ const Errors = require('../../Errors');
2
+ const toUuid = require('../../utils/toUuid');
3
+ module.exports = async function (query, profileId) {
4
+ const SkyblockMuseum = require('../../structures/SkyBlock/SkyblockMuseum');
5
+ if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
6
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
7
+ const res = await this._makeRequest(`/skyblock/museum?uuid=${query}&profile=${profileId}`);
8
+ if (res.raw) return res;
9
+ return new SkyblockMuseum({
10
+ uuid: query,
11
+ m: res,
12
+ profileId: profileId
13
+ });
14
+ };
@@ -1,17 +1,14 @@
1
1
  const Errors = require('../../Errors');
2
2
  const toUuid = require('../../utils/toUuid');
3
3
  const getPlayer = require('../getPlayer');
4
- module.exports = async function (query, options = { fetchPlayer: false }) {
4
+ module.exports = async function (query, options = { fetchPlayer: false, getMuseum: false }) {
5
5
  const SkyblockProfile = require('../../structures/SkyBlock/SkyblockProfile');
6
+ const getSkyblockMuseum = require('../skyblock/getMuseum');
6
7
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
7
- query = await toUuid(query);
8
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
8
9
  const res = await this._makeRequest(`/skyblock/profiles?uuid=${query}`);
9
10
  if (res.raw) return res;
10
-
11
- if (!res.profiles || !res.profiles.length) {
12
- return [];
13
- }
14
-
11
+ if (!res.profiles || !res.profiles.length) throw new Error(Errors.NO_SKYBLOCK_PROFILES);
15
12
  const players = new Map();
16
13
  if (options.fetchPlayer) {
17
14
  const uniqueUuids = [...new Set(res.profiles.map((profile) => Object.keys(profile.members)).flat())];
@@ -32,11 +29,16 @@ module.exports = async function (query, options = { fetchPlayer: false }) {
32
29
  }
33
30
 
34
31
  profiles.push({
35
- profile_id: res.profiles[i].profile_id,
36
- profile_name: res.profiles[i].cute_name,
37
- members: res.profiles[i].members,
38
- me: query,
39
- selected: res.profiles[i].selected
32
+ uuid: query,
33
+ profileId: res.profiles[i].profile_id,
34
+ profileName: res.profiles[i].cute_name,
35
+ gameMode: res.profiles[i].game_mode || null,
36
+ m: res.profiles[i].members[query],
37
+ banking: res.profiles[i].banking,
38
+ communityUpgrades: res.profiles[i].community_upgrades,
39
+ museum: options.getMuseum ? await getSkyblockMuseum.call(this, query, res.profiles[i].profile_id) : null,
40
+ selected: res.profiles[i].selected,
41
+ members: res.profiles[i].members
40
42
  });
41
43
  }
42
44