Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

API Settings

Ethan Harvey edited this page Jun 23, 2021 · 13 revisions

API Settings

This system can either be pretty simple or pretty complex, depending on what you want to do with it. The codes for common stats are listed below, and a short guide on making more complex systems is below.

Common Stats {unfinished}

Network

  • Network Level: (Math.sqrt(data.player.networkExp + 15312.5) - 125/Math.sqrt(2))/(25*Math.sqrt(2))
  • Rank (A big one! Thanks to _plh for helping with this): f('let rank = ""; if (data.player.prefix) { rank = data.player.prefix.replace(/§4|§c|§6|§e|§2|§a|§b|§3|§1|§9|§d|§5|§f|§7|§8|§0|§r|§l|§o|§n|§m|§k|[|]/g, \"\"); } else if (data.player.rank) { if(data.player.rank === \"YOUTUBER\"){ rank = \"YOUTUBE\"; }else{ rank = data.player.rank; } } else if (data.player.monthlyPackageRank && data.player.monthlyPackageRank != \"NONE\") { rank = \"MVP++\"; } else if (data.player.newPackageRank) { rank = data.player.newPackageRank.replace(\"_PLUS\", \"+\"); } else { rank = \"Default\"; } return rank;', data)

Bedwars

  • Winstreak: data.player.stats.Bedwars.winstreak
  • Stars: data.player.achievements.bedwars_level
  • Overall FKDR: r0("player.stats.Bedwars.final_kills_bedwars", data) / r1n0("player.stats.Bedwars.final_deaths_bedwars", data)
  • 4v4v4v4 FKDR: r0("player.stats.Bedwars.four_four_final_kills_bedwars", data) / r1n0("player.stats.Bedwars.four_four_final_deaths_bedwars", data)

Duels

  • Sumo Winstreak: data.player.stats.Duels.current_sumo_winstreak
  • Sumo W/L: r0("player.stats.Duels.sumo_duel_wins", data) / r1n0("player.stats.Duels.sumo_duel_losses", data)
  • UHC Winstreak: data.player.stats.Duels.current_uhc_winstreak
  • UHC W/L: r0("player.stats.Duels.uhc_duel_wins", data) / r1n0("player.stats.Duels.uhc_duel_losses", data)

Skywars

  • Level: data.player.stats.SkyWars.levelFormatted.replace(/\D/g, "")

{VERY UNFINISHED} Figuring Out Codes

  • Stats Displayed

    • Passed the variable "data," a Javascript object of the Hypixel API response. You can use any Javascript math here.
    • The data object also includes data.internal, which has:
      • data.internal.name : String, the player name
      • data.internal.isNick : Bool, is player nicked
      • data.internal.blacklist : Array, your blacklist
      • data.internal.whitelist : Array, your whitelist
      • data.internal.seenPlayers : Array, players seen this session
    • Any custom servers have data stored in data.c.YOURSERVERNAME
  • Color Conditions

    • Passed data, same as above
    • If you want to change the default color, just pass the lowest condition as true
  • Sorting

    • Can sort by any numeric value
    • Can be reversed

These all have access to what I call "rfuncs." You can find these at the bottom of the process data worker. Rfuncs are an easy way to safely access certain data, knowing that the hypixel API sometimes will return undefined for strange values. "Object" for all of these is just the data object. See above for examples.

  • r(string, object) : resolves a datavalue. Returns "undefined" if undefined. Basically useless except for avoiding console errors.
  • r0(string, object) : resolves value, and if it's undefined, returns 0. Useful for "kills/wins" term in KD and WR.
  • r1(string, object) : resolves value, and if it's undefined, returns 1.
  • r1n0(string, object) : resolves value, and if it's undefined, it returns 1. If it's defined but equal to zero, it returns 1. Useful for "deaths/losses" term in KD and WR, as it sidesteps any divide-by-zero issues.
  • rd0(string, object) : resolves value, and if its equal to 0, return undefined. This is useful in player reports, as it can make the whole row undefined if there are no reported players in the game. (This then hides the row in the overlay until someone has a report, so it stands out more)

For the string, pass the data key, omitting the top-level object variable name. Pass the object as the second value.

(e.g., r1n0("player.stats.Bedwars.final_deaths_bedwars", data))

There's also f(string, object), which is just a wrapper for Function('\"use strict\"; let data = arguments[0]; /* Your code here */')(data). You can use it like f('if(true){ return "true!" };', data).

Clone this wiki locally