hypixel-api-reborn 11.2.0 → 11.3.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 (101) hide show
  1. package/README.md +1 -1
  2. package/eslint.config.mjs +71 -0
  3. package/package.json +14 -20
  4. package/src/API/getAchievements.js +1 -0
  5. package/src/API/getBoosters.js +1 -0
  6. package/src/API/getChallenges.js +1 -0
  7. package/src/API/getGameCounts.js +1 -0
  8. package/src/API/getGuild.js +4 -3
  9. package/src/API/getGuildAchievements.js +1 -0
  10. package/src/API/getLeaderboards.js +1 -1
  11. package/src/API/getPlayer.js +1 -0
  12. package/src/API/getQuests.js +1 -0
  13. package/src/API/getRecentGames.js +5 -9
  14. package/src/API/getServerInfo.js +40 -37
  15. package/src/API/getStatus.js +1 -0
  16. package/src/API/getWatchdogStats.js +1 -0
  17. package/src/API/housing/getActiveHouses.js +7 -0
  18. package/src/API/housing/getHouse.js +9 -0
  19. package/src/API/housing/getPlayerHouses.js +11 -0
  20. package/src/API/index.js +6 -1
  21. package/src/API/skyblock/getAuction.js +8 -6
  22. package/src/API/skyblock/getAuctions.js +15 -12
  23. package/src/API/skyblock/getAuctionsByPlayer.js +1 -1
  24. package/src/API/skyblock/getBazaar.js +1 -3
  25. package/src/API/skyblock/getBingo.js +1 -2
  26. package/src/API/skyblock/getBingoByPlayer.js +3 -3
  27. package/src/API/skyblock/getEndedAuctions.js +1 -0
  28. package/src/API/skyblock/getFireSales.js +1 -1
  29. package/src/API/skyblock/getGarden.js +7 -0
  30. package/src/API/skyblock/getGovernment.js +1 -2
  31. package/src/API/skyblock/getMember.js +5 -2
  32. package/src/API/skyblock/getMuseum.js +1 -0
  33. package/src/API/skyblock/getNews.js +1 -0
  34. package/src/API/skyblock/getProfiles.js +5 -2
  35. package/src/Client.js +88 -16
  36. package/src/Private/rateLimit.js +7 -11
  37. package/src/Private/requests.js +12 -13
  38. package/src/Private/updater.js +2 -3
  39. package/src/Private/uuidCache.js +1 -2
  40. package/src/Private/validate.js +19 -19
  41. package/src/index.js +5 -0
  42. package/src/structures/APIIncident.js +1 -2
  43. package/src/structures/APIStatus.js +0 -1
  44. package/src/structures/Boosters/Booster.js +9 -8
  45. package/src/structures/Game.js +1 -1
  46. package/src/structures/Guild/Guild.js +19 -36
  47. package/src/structures/Guild/GuildMember.js +2 -2
  48. package/src/structures/House.js +54 -0
  49. package/src/structures/MiniGames/Arcade.js +798 -312
  50. package/src/structures/MiniGames/ArenaBrawl.js +98 -32
  51. package/src/structures/MiniGames/BedWars.js +197 -194
  52. package/src/structures/MiniGames/BlitzSurvivalGames.js +381 -129
  53. package/src/structures/MiniGames/BuildBattle.js +19 -8
  54. package/src/structures/MiniGames/CopsAndCrims.js +253 -25
  55. package/src/structures/MiniGames/Duels.js +905 -664
  56. package/src/structures/MiniGames/MegaWalls.js +390 -51
  57. package/src/structures/MiniGames/MurderMystery.js +151 -30
  58. package/src/structures/MiniGames/Paintball.js +31 -11
  59. package/src/structures/MiniGames/Pit.js +4 -5
  60. package/src/structures/MiniGames/Quakecraft.js +113 -50
  61. package/src/structures/MiniGames/SkyWars.js +528 -372
  62. package/src/structures/MiniGames/SmashHeroes.js +201 -73
  63. package/src/structures/MiniGames/SpeedUHC.js +77 -24
  64. package/src/structures/MiniGames/TNTGames.js +242 -73
  65. package/src/structures/MiniGames/TurboKartRacers.js +55 -115
  66. package/src/structures/MiniGames/UHC.js +144 -132
  67. package/src/structures/MiniGames/VampireZ.js +70 -37
  68. package/src/structures/MiniGames/Warlords.js +126 -1
  69. package/src/structures/MiniGames/WoolWars.js +60 -9
  70. package/src/structures/Pet.js +1 -1
  71. package/src/structures/Player.js +43 -128
  72. package/src/structures/PlayerCosmetics.js +5 -4
  73. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +2 -1
  74. package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -1
  75. package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
  76. package/src/structures/SkyBlock/PlayerBingo.js +7 -14
  77. package/src/structures/SkyBlock/SkyblockGarden.js +146 -0
  78. package/src/structures/SkyBlock/SkyblockInventoryItem.js +4 -28
  79. package/src/structures/SkyBlock/SkyblockMember.js +90 -228
  80. package/src/structures/SkyBlock/SkyblockPet.js +3 -4
  81. package/src/structures/SkyBlock/Static/Bingo.js +10 -11
  82. package/src/structures/SkyBlock/Static/BingoData.js +1 -1
  83. package/src/structures/Static/Achievement.js +16 -15
  84. package/src/structures/Static/AchievementTier.js +2 -2
  85. package/src/structures/Static/Quest.js +2 -2
  86. package/src/utils/Constants.js +522 -520
  87. package/src/utils/{guildExp.js → Guild.js} +42 -12
  88. package/src/utils/Player.js +112 -0
  89. package/src/utils/SkyblockUtils.js +482 -192
  90. package/src/utils/arrayTools.js +1 -1
  91. package/src/utils/divide.js +1 -1
  92. package/src/utils/index.js +2 -1
  93. package/src/utils/isGuildID.js +1 -1
  94. package/src/utils/oscillation.js +4 -2
  95. package/src/utils/removeSnakeCase.js +11 -7
  96. package/src/utils/rgbToHexColor.js +1 -1
  97. package/src/utils/romanize.js +3 -3
  98. package/src/utils/toUuid.js +4 -4
  99. package/src/utils/varInt.js +2 -2
  100. package/typings/index.d.ts +1186 -967
  101. package/src/utils/toIGN.js +0 -24
@@ -1,8 +1,21 @@
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
- const { getGuildLevel, parseHistory } = require('../../utils/guildExp');
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
  */
@@ -16,6 +29,8 @@ class Guild {
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
@@ -105,7 +120,7 @@ class Guild {
105
120
  * Whether this guild is listed in the Guild Finder
106
121
  * @type {boolean}
107
122
  */
108
- this.publiclyListed = !!data.publiclyListed;
123
+ this.publiclyListed = Boolean(data.publiclyListed);
109
124
  /**
110
125
  * Timestamp guild chat will be unmuted at.
111
126
  * @type {number|null}
@@ -115,7 +130,7 @@ class Guild {
115
130
  * Timestamp guild chat will be unmuted at as Date.
116
131
  * @type {Date|null}
117
132
  */
118
- this.chatMuteUntil = new Date(data.chatMute) ?? null;
133
+ this.chatMuteUntil = data.chatMute ? new Date(data.chatMute) : null;
119
134
  /**
120
135
  * Timestamp guild chat will be unmuted at.
121
136
  * @type {Array<{ Pattern: string, Color: string }>}
@@ -169,40 +184,8 @@ class Guild {
169
184
  * @type {GuildMember}
170
185
  */
171
186
  get guildMaster() {
172
- return this.members.find((member) => member.rank === 'Guild Master' || member.rank === 'GUILDMASTER');
187
+ return this.members.find((member) => 'Guild Master' === member.rank || 'GUILDMASTER' === member.rank);
173
188
  }
174
189
  }
175
- // eslint-disable-next-line require-jsdoc
176
- function members(data) {
177
- return data.members.length ? data.members.map((m) => new GuildMember(m)) : [];
178
- }
179
- // eslint-disable-next-line require-jsdoc
180
- function ranks(data) {
181
- return data.ranks && data.ranks.length
182
- ? data.ranks.map((r) => new GuildRank(r)).sort((a, b) => a.priority - b.priority)
183
- : [];
184
- }
185
- // eslint-disable-next-line require-jsdoc
186
- function totalWeeklyGexp(data) {
187
- return members(data)
188
- .map((m) => m.weeklyExperience)
189
- .reduce((acc, cur) => acc + cur);
190
- }
191
- // eslint-disable-next-line require-jsdoc
192
- function calculateExpHistory(data) {
193
- const finalObj = {};
194
- for (const day of Object.keys(data.members[0].expHistory)) {
195
- let gexp = 0;
196
- for (const member of data.members) {
197
- gexp += member.expHistory[day] || 0;
198
- }
199
- finalObj[day] = expLimit(gexp);
200
- }
201
- return parseHistory(finalObj);
202
- }
203
- // eslint-disable-next-line require-jsdoc
204
- function expLimit(exp) {
205
- return exp > 2e5 ? (exp > 7e5 ? 2.5e5 + Math.round(exp * 0.03) : 2e5 + Math.round((exp - 2e5) / 10)) : exp;
206
- }
207
190
 
208
191
  module.exports = Guild;
@@ -1,4 +1,4 @@
1
- const { parseHistory } = require('../../utils/guildExp');
1
+ const { parseHistory } = require('../../utils/Guild');
2
2
  /**
3
3
  * GuildMember class
4
4
  */
@@ -42,7 +42,7 @@ class GuildMember {
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] === 'number';
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>}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * House class
3
+ */
4
+ class House {
5
+ /**
6
+ * @param {object} data data
7
+ */
8
+ constructor(data) {
9
+ /**
10
+ * Name of the house
11
+ * @type {string}
12
+ */
13
+ this.name = data.name || '';
14
+ /**
15
+ * UUID of the house
16
+ * @type {string}
17
+ */
18
+ this.uuid = data.uuid || '';
19
+ /**
20
+ * UUID of the house owner
21
+ * @type {string}
22
+ */
23
+ this.owner = data.owner || '';
24
+ /**
25
+ * Timestamp when the house was created
26
+ * @type {number}
27
+ */
28
+ this.createdAtTimestamp = data.createdAt || 0;
29
+ /**
30
+ * Date when the house was created
31
+ * @type {Date|null}
32
+ */
33
+ this.createdAt = new Date(this.createdAtTimestamp);
34
+ /**
35
+ * Number of players currently at the house
36
+ * @type {number}
37
+ */
38
+ this.players = data.players || 0;
39
+ /**
40
+ * Number of cookies the house has
41
+ * @type {number}
42
+ */
43
+ this.cookies = data.cookies?.current || 0;
44
+ }
45
+ /**
46
+ * House Nmae
47
+ * @return {string}
48
+ */
49
+ toString() {
50
+ return this.name;
51
+ }
52
+ }
53
+
54
+ module.exports = House;