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.
Files changed (105) hide show
  1. package/.prettierrc +13 -0
  2. package/README.md +28 -16
  3. package/package.json +60 -58
  4. package/src/API/getAPIStatus.js +8 -8
  5. package/src/API/getBoosters.js +6 -6
  6. package/src/API/getGameCounts.js +6 -6
  7. package/src/API/getGuild.js +18 -18
  8. package/src/API/getLeaderboards.js +13 -13
  9. package/src/API/getPlayer.js +22 -27
  10. package/src/API/getRecentGames.js +18 -18
  11. package/src/API/getServerInfo.js +66 -77
  12. package/src/API/getStatus.js +8 -8
  13. package/src/API/getWatchdogStats.js +6 -6
  14. package/src/API/index.js +19 -23
  15. package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -10
  16. package/src/API/skyblock/getSkyblockAuctions.js +64 -64
  17. package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -11
  18. package/src/API/skyblock/getSkyblockBazaar.js +10 -10
  19. package/src/API/skyblock/getSkyblockMember.js +28 -25
  20. package/src/API/skyblock/getSkyblockNews.js +6 -6
  21. package/src/API/skyblock/getSkyblockProfiles.js +44 -41
  22. package/src/Client.js +406 -450
  23. package/src/Errors.js +44 -39
  24. package/src/Private/defaultCache.js +77 -78
  25. package/src/Private/rateLimit.js +79 -98
  26. package/src/Private/requests.js +65 -54
  27. package/src/Private/updater.js +45 -45
  28. package/src/Private/uuidCache.js +37 -33
  29. package/src/Private/validate.js +97 -97
  30. package/src/index.js +82 -83
  31. package/src/structures/APIIncident.js +78 -78
  32. package/src/structures/APIStatus.js +47 -47
  33. package/src/structures/Boosters/Booster.js +83 -87
  34. package/src/structures/Color.js +129 -129
  35. package/src/structures/Game.js +164 -160
  36. package/src/structures/GameCounts.js +151 -151
  37. package/src/structures/Guild/Guild.js +204 -218
  38. package/src/structures/Guild/GuildMember.js +66 -66
  39. package/src/structures/Guild/GuildRank.js +48 -48
  40. package/src/structures/ItemBytes.js +33 -36
  41. package/src/structures/Leaderboard.js +31 -31
  42. package/src/structures/MiniGames/Arcade.js +567 -569
  43. package/src/structures/MiniGames/ArenaBrawl.js +52 -56
  44. package/src/structures/MiniGames/BedWars.js +423 -351
  45. package/src/structures/MiniGames/BlitzSurvivalGames.js +172 -148
  46. package/src/structures/MiniGames/BuildBattle.js +53 -53
  47. package/src/structures/MiniGames/CopsAndCrims.js +90 -90
  48. package/src/structures/MiniGames/Duels.js +694 -630
  49. package/src/structures/MiniGames/MegaWalls.js +137 -137
  50. package/src/structures/MiniGames/MurderMystery.js +93 -93
  51. package/src/structures/MiniGames/Paintball.js +67 -67
  52. package/src/structures/MiniGames/Pit.js +19 -19
  53. package/src/structures/MiniGames/Quakecraft.js +101 -101
  54. package/src/structures/MiniGames/SkyWars.js +508 -559
  55. package/src/structures/MiniGames/SmashHeroes.js +144 -151
  56. package/src/structures/MiniGames/SpeedUHC.js +115 -57
  57. package/src/structures/MiniGames/TNTGames.js +116 -116
  58. package/src/structures/MiniGames/TurboKartRacers.js +201 -176
  59. package/src/structures/MiniGames/UHC.js +164 -143
  60. package/src/structures/MiniGames/VampireZ.js +60 -60
  61. package/src/structures/MiniGames/Walls.js +52 -52
  62. package/src/structures/MiniGames/Warlords.js +62 -62
  63. package/src/structures/MiniGames/WoolWars.js +123 -0
  64. package/src/structures/Pet.js +96 -97
  65. package/src/structures/Pets.js +64 -64
  66. package/src/structures/Player.js +433 -449
  67. package/src/structures/PlayerCosmetics.js +100 -95
  68. package/src/structures/RecentGame.js +57 -57
  69. package/src/structures/ServerInfo.js +78 -78
  70. package/src/structures/SkyBlock/Auctions/Auction.js +104 -104
  71. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +54 -54
  72. package/src/structures/SkyBlock/Auctions/BaseAuction.js +45 -45
  73. package/src/structures/SkyBlock/Auctions/Bid.js +48 -48
  74. package/src/structures/SkyBlock/Auctions/PartialAuction.js +25 -25
  75. package/src/structures/SkyBlock/Bazzar/Order.js +38 -38
  76. package/src/structures/SkyBlock/Bazzar/Product.js +53 -53
  77. package/src/structures/SkyBlock/News/SkyblockNews.js +60 -68
  78. package/src/structures/SkyBlock/SkyblockInventoryItem.js +124 -130
  79. package/src/structures/SkyBlock/SkyblockMember.js +820 -687
  80. package/src/structures/SkyBlock/SkyblockPet.js +71 -71
  81. package/src/structures/SkyBlock/SkyblockProfile.js +60 -60
  82. package/src/structures/Status.js +41 -41
  83. package/src/structures/Watchdog/Stats.js +36 -36
  84. package/src/utils/Constants.js +2789 -809
  85. package/src/utils/SkyblockUtils.js +208 -164
  86. package/src/utils/arrayTools.js +4 -4
  87. package/src/utils/divide.js +5 -5
  88. package/src/utils/guildExp.js +57 -67
  89. package/src/utils/index.js +13 -13
  90. package/src/utils/isGuildID.js +3 -3
  91. package/src/utils/isUUID.js +5 -5
  92. package/src/utils/oscillation.js +15 -23
  93. package/src/utils/removeSnakeCase.js +22 -35
  94. package/src/utils/rgbToHexColor.js +8 -8
  95. package/src/utils/romanize.js +11 -13
  96. package/src/utils/toIGN.js +20 -20
  97. package/src/utils/toUuid.js +19 -19
  98. package/src/utils/varInt.js +17 -21
  99. package/typings/index.d.ts +3532 -2644
  100. package/src/API/getFriends.js +0 -14
  101. package/src/API/getKeyInfo.js +0 -10
  102. package/src/API/getRankedSkyWars.js +0 -11
  103. package/src/structures/Friend.js +0 -38
  104. package/src/structures/KeyInfo.js +0 -42
  105. package/src/structures/MiniGames/SkyWarsRanked.js +0 -45
@@ -0,0 +1,123 @@
1
+ const { divide } = require('../../utils');
2
+
3
+ /**
4
+ * Wool Wars Class
5
+ */
6
+ class WoolWars {
7
+ /**
8
+ * Constructor
9
+ * @param {Record<string,unknown>} data Data from API
10
+ */
11
+ constructor(data) {
12
+ /**
13
+ * Sheep layers, similar to prestige
14
+ * @type {number}
15
+ */
16
+ this.layers = data.progression?.available_layers || 0;
17
+ /**
18
+ * Wool Wars XP
19
+ * @type {number}
20
+ */
21
+ this.xp = data.progression?.experience || 0;
22
+ /**
23
+ * Wool Wars Decimal Level
24
+ * @type {number}
25
+ */
26
+ this.exactLevel = WoolWars.convertXPToLevel(this.xp);
27
+ /**
28
+ * Wool wars level (as shown in game)
29
+ * @type {number}
30
+ */
31
+ this.level = Math.floor(this.exactLevel);
32
+ /**
33
+ * Coins
34
+ * @type {number}
35
+ */
36
+ this.coins = data.coins || 0;
37
+ /**
38
+ * Selected class, or NONE if field isn't present in API for some reason
39
+ * @type {'ASSAULT'|'TANK'|'GOLEM'|'SWORDSMAN'|'ENGINEER'|'ARCHER'|'NONE'}
40
+ */
41
+ this.selectedClass = data.wool_wars?.selected_class || 'NONE';
42
+ this.stats = {
43
+ overall: WoolWars.generateStatsFor(data.wool_wars?.stats, ''),
44
+ assault: WoolWars.generateStatsFor(data.wool_wars?.stats, 'assault'),
45
+ tank: WoolWars.generateStatsFor(data.wool_wars?.stats, 'tank'),
46
+ golem: WoolWars.generateStatsFor(data.wool_wars?.stats, 'golem'),
47
+ swordsman: WoolWars.generateStatsFor(data.wool_wars?.stats, 'swordsman'),
48
+ engineer: WoolWars.generateStatsFor(data.wool_wars?.stats, 'engineer'),
49
+ archer: WoolWars.generateStatsFor(data.wool_wars?.stats, 'archer')
50
+ };
51
+ // Misc fields ig
52
+ /**
53
+ * Owned Cosmetics
54
+ * @type {string[]}
55
+ */
56
+ this.ownedCosmetics = data.packages || [];
57
+ /**
58
+ * Private Games config
59
+ * @type {PrivateGamesConfig}
60
+ */
61
+ this.privateGamesConfig = data.privategames || {};
62
+ }
63
+ /**
64
+ * Converts XP to Level
65
+ * @param {number} exp xp
66
+ * @return {number}
67
+ */
68
+ static convertXPToLevel(exp) {
69
+ const minimalExp = [0, 1e3, 3e3, 6e3, 1e4, 15e3]; // NB: progression is 1k, 2k, 3k, 4k, 5k
70
+ const baseLevel = minimalExp.length;
71
+ const baseExp = minimalExp[minimalExp.length - 1];
72
+ const expToLevel100 = 49e4;
73
+ if (exp < baseExp) return minimalExp.findIndex((x) => exp < x);
74
+ const theoreticalLevel = (exp - baseExp) / 5e3 + baseLevel;
75
+ if (theoreticalLevel > 100) return 100 + this.convertXPToLevel(exp - expToLevel100);
76
+ return theoreticalLevel;
77
+ }
78
+ /**
79
+ * Generates stats per class/overall
80
+ * @param {Record<string, unknwon>} data data
81
+ * @param {string} [_class=''] Class
82
+ * @return {WoolWarsStats}
83
+ */
84
+ static generateStatsFor(data, _class) {
85
+ // N.B i called it _class instead of class because reserved keyword
86
+ const workingData = (_class ? data?.['classes'][_class] : data) || {};
87
+ return {
88
+ roundWins: workingData.wins || 0,
89
+ gamesPlayed: workingData.games_played || 0,
90
+ woolsPlaced: workingData.wool_placed || 0,
91
+ blocksBroken: workingData.blocks_broken || 0,
92
+ placeBreakRatio: divide(workingData.wool_placed, workingData.blocks_broken),
93
+ kills: workingData.kills || 0,
94
+ deaths: workingData.deaths || 0,
95
+ KDRatio: divide(workingData.kills, workingData.deaths),
96
+ assists: workingData.assists || 0,
97
+ powerups: workingData.powerups_gotten || 0
98
+ };
99
+ }
100
+ }
101
+ /**
102
+ * @typedef {Object} PrivateGamesConfig NB. There could be more fields
103
+ * @property {boolean} one_hit_one_kill One hit one kill
104
+ * @property {'Enabled'|'Disabled'} rainbow_wool Rainbow wool
105
+ * @property {string} health_buff Health Buff
106
+ * @property {string} game_speed Game speed
107
+ * @property {string} speed Player speed
108
+ * @property {'Enabled'|'Disabled'} no_class No class
109
+ */
110
+ /**
111
+ * @typedef {Object} WoolWarsStats
112
+ * @property {number} roundWins round wins
113
+ * @property {number} gamesPlayed games played
114
+ * @property {number} woolsPlaced wools placed
115
+ * @property {number} blocksBroken blocks broken
116
+ * @property {number} placeBreakRatio broken blocks to placed wool ratio
117
+ * @property {number} kills kills
118
+ * @property {number} deaths deaths
119
+ * @property {number} KDRatio KDR
120
+ * @property {number} assists assists (not included in KDR)
121
+ * @property {number} powerups number of powerups picked up
122
+ */
123
+ module.exports = WoolWars;
@@ -1,97 +1,96 @@
1
- const Utils = require('../utils');
2
- /**
3
- * Pet Class
4
- */
5
- class Pet {
6
- /**
7
- * @param {string} name Name of pet
8
- * @param {object} data data
9
- */
10
- constructor (name, data) {
11
- /**
12
- * Is Pet Favorite
13
- * @type {boolean}
14
- */
15
- this.isFavorite = data.vanityFavorites ? Boolean(data.vanityFavorites.includes(name.toUpperCase())) : false;
16
- name = name.replace('pet_', '');
17
- /**
18
- * Official Name of the pet
19
- * @type {string}
20
- */
21
- this.name = Utils.removeSnakeCase.recursive(name) || null;
22
- /**
23
- * Is Active Pet
24
- * @type {boolean}
25
- */
26
- this.active = data.currentPet === name.toUpperCase();
27
- const stats = data.petStats && data.petStats[name.toUpperCase()];
28
- /**
29
- * Stats of the pet, if any
30
- * @type {object}
31
- */
32
- this.stats = {};
33
- if (!stats) return; // don't parse stats because there is none.
34
- /**
35
- * Hunger value ( 100 is highest )
36
- * @type {number|null}
37
- */
38
- this.stats.hunger = stats.HUNGER ? stats.HUNGER.value : null;
39
- /**
40
- * Last time the pet was fed ( timestamp )
41
- * @type {number|null}
42
- */
43
- this.stats.lastFed = stats.HUNGER ? stats.HUNGER.timestamp : null;
44
- /**
45
- * Last time the pet was fed ( Date )
46
- * @type {Date|null}
47
- */
48
- this.stats.lastFedAt = this.stats.lastFed ? new Date(this.stats.lastFed) : null;
49
- /**
50
- * Thirst value ( 100 is highest )
51
- * @type {number|null}
52
- */
53
- this.stats.thirst = stats.THIRST ? stats.THIRST.value : null;
54
- /**
55
- * Last time the pet drank ( timestamp )
56
- * @type {number|null}
57
- */
58
- this.stats.lastDrank = stats.THIRST ? stats.THIRST.timestamp : null;
59
- /**
60
- * Last time the pet drank ( Date )
61
- * @type {Date|null}
62
- */
63
- this.stats.lastDrankAt = this.stats.lastDrank ? new Date(this.stats.lastDrank) : null;
64
- /**
65
- * Exercise/Entertainment value ( 100 is highest )
66
- * @type {number|null}
67
- */
68
- this.stats.exercise = stats.EXERCISE ? stats.EXERCISE.value : null;
69
- /**
70
- * Last time the pet was exercised ( timestamp )
71
- * @type {number|null}
72
- */
73
- this.stats.lastExercised = stats.EXERCISE ? stats.EXERCISE.timestamp : null;
74
- /**
75
- * Last time the pet exercised ( Date )
76
- * @type {Date|null}
77
- */
78
- this.stats.lastExercisedAt = this.stats.lastExercised ? new Date(this.stats.lastExerciced) : null;
79
- /**
80
- * Raw Nickname, if any
81
- * @type {string|null}
82
- */
83
- this.rawNickname = stats.name || null;
84
- /**
85
- * Nickname in plain text, if any
86
- * @type {string|null}
87
- */
88
- this.nickname = stats.name ? stats.name.replace(/§([0-9]|[a-f])|§/gm, '') : null;
89
- /**
90
- * Pet experience
91
- * @type {number}
92
- */
93
- this.experience = stats.experience || 0;
94
- }
95
- }
96
-
97
- module.exports = Pet;
1
+ const Utils = require('../utils');
2
+ /**
3
+ * Pet Class
4
+ */
5
+ class Pet {
6
+ /**
7
+ * @param {string} name Name of pet
8
+ * @param {object} data data
9
+ */
10
+ constructor(name, data) {
11
+ /**
12
+ * Is Pet Favorite
13
+ * @type {boolean}
14
+ */
15
+ this.isFavorite = data.vanityFavorites ? Boolean(data.vanityFavorites.includes(name.toUpperCase())) : false;
16
+ name = name.replace('pet_', '');
17
+ /**
18
+ * Official Name of the pet
19
+ * @type {string}
20
+ */
21
+ this.name = Utils.removeSnakeCase.recursive(name) || null;
22
+ /**
23
+ * Is Active Pet
24
+ * @type {boolean}
25
+ */
26
+ this.active = data.currentPet === name.toUpperCase();
27
+ const stats = data.petStats && data.petStats[name.toUpperCase()];
28
+ /**
29
+ * Stats of the pet, if any
30
+ * @type {object}
31
+ */
32
+ if (!stats) return; // don't parse stats because there is none.
33
+ /**
34
+ * Hunger value ( 100 is highest )
35
+ * @type {?number}
36
+ */
37
+ this.hunger = stats.HUNGER ? stats.HUNGER.value : null;
38
+ /**
39
+ * Last time the pet was fed ( timestamp )
40
+ * @type {?number}
41
+ */
42
+ this.lastFed = stats.HUNGER ? stats.HUNGER.timestamp : null;
43
+ /**
44
+ * Last time the pet was fed ( Date )
45
+ * @type {?Date}
46
+ */
47
+ this.lastFedAt = this.lastFed ? new Date(this.lastFed) : null;
48
+ /**
49
+ * Thirst value ( 100 is highest )
50
+ * @type {?number}
51
+ */
52
+ this.thirst = stats.THIRST ? stats.THIRST.value : null;
53
+ /**
54
+ * Last time the pet drank ( timestamp )
55
+ * @type {?number}
56
+ */
57
+ this.lastDrank = stats.THIRST ? stats.THIRST.timestamp : null;
58
+ /**
59
+ * Last time the pet drank ( Date )
60
+ * @type {?Date}
61
+ */
62
+ this.lastDrankAt = this.lastDrank ? new Date(this.lastDrank) : null;
63
+ /**
64
+ * Exercise/Entertainment value ( 100 is highest )
65
+ * @type {?number}
66
+ */
67
+ this.exercise = stats.EXERCISE ? stats.EXERCISE.value : null;
68
+ /**
69
+ * Last time the pet was exercised ( timestamp )
70
+ * @type {?number}
71
+ */
72
+ this.lastExercised = stats.EXERCISE ? stats.EXERCISE.timestamp : null;
73
+ /**
74
+ * Last time the pet exercised ( Date )
75
+ * @type {?Date}
76
+ */
77
+ this.lastExercisedAt = this.lastExercised ? new Date(this.lastExerciced) : null;
78
+ /**
79
+ * Raw Nickname, if any
80
+ * @type {?string}
81
+ */
82
+ this.rawNickname = stats.name || null;
83
+ /**
84
+ * Nickname in plain text, if any
85
+ * @type {?string}
86
+ */
87
+ this.nickname = stats.name ? stats.name.replace(/§([0-9]|[a-f])|§/gm, '') : null;
88
+ /**
89
+ * Pet experience
90
+ * @type {number}
91
+ */
92
+ this.experience = stats.experience || 0;
93
+ }
94
+ }
95
+
96
+ module.exports = Pet;
@@ -1,64 +1,64 @@
1
- const Pet = require('./Pet');
2
- /**
3
- * Pets class
4
- */
5
- class Pets {
6
- /**
7
- * @param {string[]} pets Array of pets
8
- * @param {object} data data
9
- */
10
- constructor (pets, data) {
11
- /**
12
- * Array of pets
13
- * @type {Pet[]}
14
- */
15
- this.pets = pets.map((x) => new Pet(x, data));
16
- /**
17
- * Last Pet Journey ( as timestamp )
18
- * @type {number|null}
19
- */
20
- this.lastJourneyTimestamp = data.petJourneyTimestamp || null;
21
- /**
22
- * Last Pet Journey ( as Date )
23
- * @type {Date|null}
24
- */
25
- this.lastJourneyAt = this.lastJourneyTimestamp ? new Date(this.lastJourneyTimestamp) : null;
26
- /**
27
- * Pet food/drink/toys
28
- * @type {PetConsumables}
29
- */
30
- this.petConsumables = data.petConsumables;
31
- }
32
- }
33
- /**
34
- * @typedef {Object} PetConsumables
35
- * @property {number} BAKED_POTATO Food
36
- * @property {number} COOKIE Food
37
- * @property {number} FEATHER Toy
38
- * @property {number} HAY_BLOCK Food
39
- * @property {number} SLIME_BALL Toy
40
- * @property {number} COOKED_BEEF Food
41
- * @property {number} RED_ROSE Food
42
- * @property {number} WATER_BUCKET Drinks
43
- * @property {number} MELON Food
44
- * @property {number} STICK Toy
45
- * @property {number} WOOD_SWORD Toy ( but not irl )
46
- * @property {number} MILK_BUCKET Drinks
47
- * @property {number} GOLD_RECORD Food
48
- * @property {number} LEASH Toy
49
- * @property {number} LAVA_BUCKET Drinks
50
- * @property {number} BONE Food
51
- * @property {number} MAGMA_CREAM Food
52
- * @property {number} WHEAT Food
53
- * @property {number} MUSHROOM_SOUP Food
54
- * @property {number} BREAD Food
55
- * @property {number} PUMPKIN_PIE Food
56
- * @property {number} APPLE Food
57
- * @property {number} CARROT_ITEM Carrots
58
- * @property {number} RAW_FISH Food
59
- * @property {number} PORK Food
60
- * @property {number} CAKE Food
61
- * @property {number} ROTTEN_FLESH Food
62
- */
63
-
64
- module.exports = Pets;
1
+ const Pet = require('./Pet');
2
+ /**
3
+ * Pets class
4
+ */
5
+ class Pets {
6
+ /**
7
+ * @param {string[]} pets Array of pets
8
+ * @param {object} data data
9
+ */
10
+ constructor(pets, data) {
11
+ /**
12
+ * Array of pets
13
+ * @type {Pet[]}
14
+ */
15
+ this.pets = pets.map((x) => new Pet(x, data));
16
+ /**
17
+ * Last Pet Journey ( as timestamp )
18
+ * @type {number|null}
19
+ */
20
+ this.lastJourneyTimestamp = data.petJourneyTimestamp || null;
21
+ /**
22
+ * Last Pet Journey ( as Date )
23
+ * @type {Date|null}
24
+ */
25
+ this.lastJourneyAt = this.lastJourneyTimestamp ? new Date(this.lastJourneyTimestamp) : null;
26
+ /**
27
+ * Pet food/drink/toys
28
+ * @type {PetConsumables}
29
+ */
30
+ this.petConsumables = data.petConsumables;
31
+ }
32
+ }
33
+ /**
34
+ * @typedef {Object} PetConsumables
35
+ * @property {number} BAKED_POTATO Food
36
+ * @property {number} COOKIE Food
37
+ * @property {number} FEATHER Toy
38
+ * @property {number} HAY_BLOCK Food
39
+ * @property {number} SLIME_BALL Toy
40
+ * @property {number} COOKED_BEEF Food
41
+ * @property {number} RED_ROSE Food
42
+ * @property {number} WATER_BUCKET Drinks
43
+ * @property {number} MELON Food
44
+ * @property {number} STICK Toy
45
+ * @property {number} WOOD_SWORD Toy ( but not irl )
46
+ * @property {number} MILK_BUCKET Drinks
47
+ * @property {number} GOLD_RECORD Food
48
+ * @property {number} LEASH Toy
49
+ * @property {number} LAVA_BUCKET Drinks
50
+ * @property {number} BONE Food
51
+ * @property {number} MAGMA_CREAM Food
52
+ * @property {number} WHEAT Food
53
+ * @property {number} MUSHROOM_SOUP Food
54
+ * @property {number} BREAD Food
55
+ * @property {number} PUMPKIN_PIE Food
56
+ * @property {number} APPLE Food
57
+ * @property {number} CARROT_ITEM Carrots
58
+ * @property {number} RAW_FISH Food
59
+ * @property {number} PORK Food
60
+ * @property {number} CAKE Food
61
+ * @property {number} ROTTEN_FLESH Food
62
+ */
63
+
64
+ module.exports = Pets;