Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead endpoints #431

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@
- name: getSkyblockAuctionsByPlayer
path: getSkyblockAuctionsByPlayer.md
- name: getEndedSkyblockAuctions
path: getEndedSkyblockAuctions.md
- name: getRankedSkyWars
path: getRankedSkyWars.md
path: getEndedSkyblockAuctions.md
34 changes: 0 additions & 34 deletions docs/methods/getRankedSkyWars.md

This file was deleted.

11 changes: 3 additions & 8 deletions src/API/getPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 });
};
11 changes: 0 additions & 11 deletions src/API/getRankedSkyWars.js

This file was deleted.

1 change: 0 additions & 1 deletion src/API/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
18 changes: 0 additions & 18 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,23 +336,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<SkyWarsRanked>}
* @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
Expand Down Expand Up @@ -396,7 +379,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.
*/
/**
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
42 changes: 0 additions & 42 deletions src/structures/KeyInfo.js

This file was deleted.

57 changes: 2 additions & 55 deletions src/structures/MiniGames/SkyWars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -109,7 +108,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}
Expand Down Expand Up @@ -152,7 +151,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
};
Expand Down Expand Up @@ -192,21 +190,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}
Expand Down Expand Up @@ -325,17 +308,6 @@ class SkyWars {
* @property {number} KDRatio Kill Death ratio
* @property {number} WLRatio Win Loss ratio
*/
/**
* @typedef {Object} SkywarsRankedStats
* @extends SkywarsTotalModeStats
* @property {Map<PseudoDate,SkywarsRankData>} 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.
Expand Down Expand Up @@ -415,31 +387,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
Expand Down
45 changes: 0 additions & 45 deletions src/structures/MiniGames/SkyWarsRanked.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/structures/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Player {
* @type {PlayerStats}
*/
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),
Expand Down
Loading