diff --git a/docs/index.yml b/docs/index.yml index bab9a884..603b766f 100644 --- a/docs/index.yml +++ b/docs/index.yml @@ -36,5 +36,3 @@ path: getSkyblockAuctionsByPlayer.md - name: getEndedSkyblockAuctions path: getEndedSkyblockAuctions.md - - name: getRankedSkyWars - path: getRankedSkyWars.md diff --git a/docs/methods/getRankedSkyWars.md b/docs/methods/getRankedSkyWars.md deleted file mode 100644 index 192a212b..00000000 --- a/docs/methods/getRankedSkyWars.md +++ /dev/null @@ -1,45 +0,0 @@ -# getRankedSkyWars - -Allows you to get Ranked SkyWars data for current season of a player - -## Arguments - -- Player nickname or UUID -- [Method options](https://hypixel-api-reborn.github.io/#/docs/main/master/typedef/MethodOptions) (optional) - -## Example usage - -```js -const Hypixel = require('hypixel-api-reborn'); -const hypixel = new Hypixel.Client('API-KEY'); -// https://stavzdev.is-inside.me/cCMiZdoy.gif - -hypixel - .getRankedSkyWars('S0MWY') - .then((data) => { - console.log(data); - }) - .catch((e) => { - console.error(e); - // if data not found or player doesn't exist will throw an error - }); - -// async/await -const data = await hypixel.getRankedSkyWars('S0MWY').catch((e) => console.error(e)); -console.log(data); -``` - -## Example response - -```js -SkyWarsRanked { - seasonKey: '11_21', - position: 3, - rating: 1889, - date: 2021-11-01T05:00:00.000Z -} -``` - -## Links - -- [SkyWarsRanked](https://hypixel-api-reborn.github.io/#/docs/main/master/class/SkyWarsRanked) diff --git a/src/API/getPlayer.js b/src/API/getPlayer.js index 8054cadf..498c0b78 100644 --- a/src/API/getPlayer.js +++ b/src/API/getPlayer.js @@ -2,8 +2,7 @@ const Errors = require('../Errors'); const toUuid = require('../utils/toUuid'); const getGuild = require('./getGuild'); const getRecentGames = require('./getRecentGames'); -const getRankedSkyWars = require('./getRankedSkyWars'); -module.exports = async function (query, options = { guild: false, recentGames: false, currentRankedSW: false }) { +module.exports = async function (query, options = { guild: false, recentGames: false }) { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); const Player = require('../structures/Player'); query = await toUuid(query); @@ -12,16 +11,12 @@ module.exports = async function (query, options = { guild: false, recentGames: f if (query && !res.player) throw new Error(Errors.PLAYER_HAS_NEVER_LOGGED); let guild = null; let recentGames = null; - let rankedSW = null; if (options.guild) { guild = getGuild.call(this, 'player', query); } if (options.recentGames) { recentGames = getRecentGames.call(this, query); } - if (options.currentRankedSW) { - rankedSW = getRankedSkyWars.call(this, query); - } - [guild, recentGames, rankedSW] = await Promise.all([guild, recentGames, rankedSW]); - return new Player(res.player, { guild, recentGames, rankedSW }); + [guild, recentGames] = await Promise.all([guild, recentGames]); + return new Player(res.player, { guild, recentGames }); }; diff --git a/src/API/getRankedSkyWars.js b/src/API/getRankedSkyWars.js deleted file mode 100644 index d85ed1c8..00000000 --- a/src/API/getRankedSkyWars.js +++ /dev/null @@ -1,11 +0,0 @@ -const Errors = require('../Errors'); -const toUuid = require('../utils/toUuid'); -module.exports = async function (query) { - if (!query) throw new Error(Errors.NO_NICKNAME_UUID); - const SkyWarsRanked = require('../structures/MiniGames/SkyWarsRanked'); - query = await toUuid(query); - const res = await this._makeRequest(`/player/ranked/skywars?uuid=${query}`); - if (res.raw) return res; - if (!res.result) return null; - return new SkyWarsRanked(res.result); -}; diff --git a/src/API/index.js b/src/API/index.js index f528af1c..ac393a34 100644 --- a/src/API/index.js +++ b/src/API/index.js @@ -5,7 +5,6 @@ module.exports = { getGuild: require('./getGuild'), getLeaderboards: require('./getLeaderboards'), getPlayer: require('./getPlayer'), - getRankedSkyWars: require('./getRankedSkyWars'), getRecentGames: require('./getRecentGames'), getServerInfo: require('./getServerInfo'), getStatus: require('./getStatus'), diff --git a/src/Client.js b/src/Client.js index 1c8163a6..ab6d830c 100644 --- a/src/Client.js +++ b/src/Client.js @@ -337,23 +337,6 @@ class Client extends EventEmitter { * }) * .catch(console.log) */ - /** - * Allows you to get Ranked SkyWars data for current season of a player - * @method - * @name Client#getRankedSkyWars - * @param {string} query Player nickname or uuid - * @param {MethodOptions} [options={}] Options - * @return {Promise} - * @example - * hypixel.getRankedSkyWars('gypu').then((ranked) => { - * console.log(ranked.position); // 4 - * }).catch(console.log); - * @example - * // if player has no stats for current ranked season - * hypixel.getRankedSkyWars('StavZDev').then((ranked) => { - * console.log(ranked); // null - * }).catch(console.log) // throws 404 error; - */ /** * Delete x (by default all) cache entries * @param {?number} amount Amount of cache to delete @@ -397,7 +380,6 @@ const defaultCache = require('./Private/defaultCache.js'); * @property {boolean} [noCaching=false] Disable/Enable writing to cache * @property {boolean} [guild=false] Disable/Enable request for player's guild * @property {boolean} [recentGames=false] Disable/Enable request for player's recent game - * @property {boolean} [currentRankedSW=false] Disable/Enable request for player's current ranked SkyWars rating. Previous ratings will always show mindless of this option. * @prop {object} [headers={}] Extra Headers ( like User-Agent ) to add to request. Overrides the headers globally provided. */ /** diff --git a/src/index.js b/src/index.js index d04b1d75..c1bc6158 100644 --- a/src/index.js +++ b/src/index.js @@ -10,7 +10,6 @@ module.exports = { Game: require('./structures/Game.js'), Status: require('./structures/Status.js'), Color: require('./structures/Color.js'), - KeyInfo: require('./structures/KeyInfo.js'), Pet: require('./structures/Pet'), Pets: require('./structures/Pets'), PlayerCosmetics: require('./structures/PlayerCosmetics'), diff --git a/src/structures/KeyInfo.js b/src/structures/KeyInfo.js deleted file mode 100644 index 72d6d302..00000000 --- a/src/structures/KeyInfo.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * KeyInfo class - */ -class KeyInfo { - /** - * @param {object} data Key data - */ - constructor(data) { - const record = data.record; - /** - * API key - * @type {string} - */ - this.key = record.key; - /** - * Key owner UUID - * @type {string} - */ - this.owner = record.owner; - /** - * Limit per minute - * @type {number} - */ - this.limitPerMinute = record.limit || 0; - /** - * Requests in past minute - * @type {number} - */ - this.requestsInPastMin = record.queriesInPastMin || 0; - /** - * Total requests - * @type {number} - */ - this.totalRequests = record.totalQueries || 0; - /** - * Limit resets after in seconds - * @type {number} - */ - this.resetsAfter = parseInt(data._headers.get('ratelimit-reset'), 10); - } -} -module.exports = KeyInfo; diff --git a/src/structures/MiniGames/SkyWars.js b/src/structures/MiniGames/SkyWars.js index f359237b..5880bb7f 100644 --- a/src/structures/MiniGames/SkyWars.js +++ b/src/structures/MiniGames/SkyWars.js @@ -17,9 +17,8 @@ const generateStatsForMode = (data, mode) => { class SkyWars { /** * @param {object} data SkyWars data - * @param {object|null} extraRSWData Extra Ranked Skywars data, if any */ - constructor(data, extraRSWData) { + constructor(data) { /** * Coins * @type {number} @@ -114,7 +113,7 @@ class SkyWars { * Games Played ( Total ) * @type {number} */ - this.playedGames = (data.games_solo || 0) + (data.games_team || 0) + (data.games_ranked || 0) + (data.games_mega || 0) + (data.games_mega_doubles || 0) + (data.games_lab || 0); + this.playedGames = (data.games_solo || 0) + (data.games_team || 0) + (data.games_mega || 0) + (data.games_mega_doubles || 0) + (data.games_lab || 0); /** * Global Kill Death Ratio * @type {number} @@ -157,7 +156,6 @@ class SkyWars { this.shardsInMode = { solo: data.shard_solo || 0, team: data.shard_team || 0, - ranked: data.shard_ranked || 0, mega: (data.shard_mega || 0) + (data.shard_mega_doubles || 0), lab: data.shard_lab || 0 }; @@ -197,21 +195,6 @@ class SkyWars { normal: generateStatsForMode(data, 'team_normal'), insane: generateStatsForMode(data, 'team_insane') }; - /** - * Ranked Skywars Stats - * @type {SkyWarsTotalModeStats} - */ - this.ranked = { - winstreak: data.winstreak_ranked || 0, - playedGames: data.games_ranked || 0, - kills: data.kills_ranked || 0, - wins: data.wins_ranked || 0, - losses: data.losses_ranked || 0, - deaths: data.deaths_ranked || 0, - KDRatio: divide(data.kills_ranked, data.deaths_ranked), - WLRatio: divide(data.wins_ranked, data.losses_ranked), - ratings: getRankedPositions(data, extraRSWData) - }; /** * Mega Skywars Stats * @type {SkyWarsMegaStats} @@ -330,17 +313,6 @@ class SkyWars { * @property {number} KDRatio Kill Death ratio * @property {number} WLRatio Win Loss ratio */ -/** - * @typedef {Object} SkywarsRankedStats - * @extends SkywarsTotalModeStats - * @property {Map} ratings Ratings & leaderboard positions - */ -/** - * @typedef {Object} SkywarsRankData - * @property {number} rating Rating of player ( if not found, this is set to 0 ) - * @property {number} position Position of player ( if not found, this is set to 0 ) - * @property {Date} date Parsed date - */ /** * @typedef {string} PseudoDate String date, in the format of MM-YY ( YY is 20YY ) * @example `10-19` would be October 2019. @@ -420,33 +392,6 @@ function getSkyWarsLevelProgress(xp) { }; } const ratingRegex = /^SkyWars_skywars_rating_(\d{1,2})_(\d{1,2})_(position|rating)$/; -/** - * gets ratings & positions on the leaderboard - * @param {Object} data data - * @param {Object|null} extraRSWData extra data to be attached - * @returns {SkywarsRankedStats} some map - */ -function getRankedPositions(data, extraRSWData) { - const map = new Map(); - const keys = Object.keys(data) - .map((key) => key.match(ratingRegex)) - .filter((x) => x); - for (const key of keys) { - let [property, month, year, type] = key; - month = parseInt(month, 10); - year = parseInt(year, 10); - const computedKey = `${month}_${year}`; - const initDate = new Date(1000 * 60 * 60 * 5); - map.set(computedKey, { - ...map.get(computedKey), - seasonKey: computedKey, - [type]: parseInt(data[property], 10) || 0, - date: new Date(initDate.setFullYear(2000 + year, month - 1, 1)) - }); - } - if (extraRSWData) map.set(extraRSWData.seasonKey, extraRSWData); - return map; -} /** * Skywars Packages - parses every package player has diff --git a/src/structures/MiniGames/SkyWarsRanked.js b/src/structures/MiniGames/SkyWarsRanked.js deleted file mode 100644 index 918d66d6..00000000 --- a/src/structures/MiniGames/SkyWarsRanked.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * SkyWars Ranked class - */ -class SkyWarsRanked { - /** - * @param {object} data - */ - constructor(data) { - /** - * Ranked season key (e.g. 7_21 - July 2021) - * @type {string} - */ - this.seasonKey = data.key; - /** - * Current position - * @type {number} - */ - this.position = data.position; - /** - * Current rating - * @type {number} - */ - this.rating = data.score; - /** - * Season key parsed as date, should usually be current season - * @type {Date} - */ - this.date = getDateFromKey(this.seasonKey); - } -} - -/** - * Gets date from season key - * @param {string} key Season Key - * @return {Date|null} - */ -function getDateFromKey(key) { - const initDate = new Date(1000 * 60 * 60 * 5); - const [month, year] = key.split('_').map(Number); - // month needs to be 0 indexed cuz js :) - if (isNaN(month) || isNaN(year) || month > 11) return null; - return new Date(initDate.setFullYear(2000 + year, month - 1, 1)); -} - -module.exports = SkyWarsRanked; diff --git a/src/structures/Player.js b/src/structures/Player.js index c4151689..a2cfdf82 100644 --- a/src/structures/Player.js +++ b/src/structures/Player.js @@ -215,7 +215,7 @@ class Player { */ this.stats = data.stats ? { - skywars: data.stats.SkyWars ? new SkyWars(data.stats.SkyWars, extraPayload?.rankedSW || null) : null, + skywars: data.stats.SkyWars ? new SkyWars(data.stats.SkyWars) : null, bedwars: data.stats.Bedwars ? new BedWars(data.stats.Bedwars) : null, uhc: data.stats.UHC ? new UHC(data.stats.UHC) : null, speeduhc: data.stats.SpeedUHC ? new SpeedUHC(data.stats.SpeedUHC) : null, diff --git a/typings/index.d.ts b/typings/index.d.ts index 1790f2a3..53a259f9 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -194,7 +194,6 @@ export interface methodOptions { } export interface playerMethodOptions extends methodOptions { raw?: boolean; - currentRankedSW?: boolean; guild?: boolean; recentGames?: boolean; } @@ -913,11 +912,6 @@ declare module 'hypixel-api-reborn' { * @description Parses the RSS feed from status.hypixel.net */ getAPIStatus(): Promise; - /** - * @description Allows you to get Ranked SkyWars data of a player - * @param query - player nickname or uuid - */ - getRankedSkyWars(query: string, options?: methodOptions): Promise; /** * @param amount - Amount of cache entries to delete * @description Allows you to clear cache @@ -1050,13 +1044,6 @@ declare module 'hypixel-api-reborn' { speed: string; no_class: 'Enabled' | 'Disabled'; }; - class SkyWarsRanked { - constructor(data: Record); - seasonKey: string; - rating: number; - date: Date; - position: number; - } class PlayerCosmetics { constructor(data: Record); allCosmetics: string[]; @@ -1253,7 +1240,6 @@ declare module 'hypixel-api-reborn' { teamsInsane: number; soloNormal: number; soloInsaneHuntersVsBeasts: number; - rankedNormal: number; soloInsaneTntMadness: number; soloInsaneRush: number; soloInsane: number; @@ -1326,16 +1312,6 @@ declare module 'hypixel-api-reborn' { idle: { players: number }; queue: { players: number }; } - class KeyInfo { - constructor(data: Record); - key: string; - owner: string; - limitPerMinute: number; - requestsInPastMin: number; - totalRequests: number; - resetsAfter: number; - } - class Arcade { constructor(data?: Record); lastTourneyAdTimestamp: number; @@ -2448,17 +2424,6 @@ declare module 'hypixel-api-reborn' { WLRatio: number; }; }; - ranked: { - winstreak: number; - playedGames: number; - kills: number; - wins: number; - losses: number; - deaths: number; - KDRatio: number; - WLRatio: number; - ratings: Map; - }; mega: { overall: { winstreak: number;