diff --git a/changelog.json b/changelog.json index 9a8a792d..2c5133e4 100644 --- a/changelog.json +++ b/changelog.json @@ -2,7 +2,7 @@ "- Added ignorelist (renamed blacklist)", "- Added spamlist", "- Added pest warp (`/pesttp`)", - "- TODO: Added /va nw", + "- Added /va nw", "- Changed blacklist to auto kick", "- Changed warplist to dianalist", "- Changed file pathing", diff --git a/features/economy/Networth.js b/features/economy/Networth.js new file mode 100644 index 00000000..603fa2d1 --- /dev/null +++ b/features/economy/Networth.js @@ -0,0 +1,69 @@ +import request from "../../../requestV2"; +import { AQUA, DARK_AQUA, DARK_RED, GRAY, LOGO, RED, YELLOW } from "../../utils/constants"; +import { decode } from "../../utils/functions"; + + +/** + * + */ +export function getNetworth(username, fruit) { + // Get UUID of entered username + request({ + url: `https://api.mojang.com/users/profiles/minecraft/${username}`, + json: true + }).then((res) => { + // Request profile data through hypixel API + request({ + url: `https://api.hypixel.net/v2/skyblock/profiles?key=4e927d63a1c34f71b56428b2320cbf95&uuid=${res.id}`, + json: true + }).then((response) => { + // Ask for desired profile + const profiles = response.profiles; + if (fruit === undefined) { + ChatLib.chat(`${LOGO + DARK_AQUA}Please select desired profile:`); + + for (let i = 0; i < profiles.length; i++) { + fruit = profiles[i].cute_name; + new Message(` ${GRAY + (i + 1)}. `, new TextComponent(AQUA + fruit) + .setClickAction("run_command") + .setClickValue(`/va nw ${username} ${fruit}`) + .setHoverValue(`${YELLOW}Click to calculate networth for ${fruit} profile.`) + ).chat(); + } + return; + } + + // Otherwise calculate networth for inputted profile + const profile = profiles.find(prof => prof.cute_name.toLowerCase() === fruit.toLowerCase()); + if (profile === undefined) { + ChatLib.chat(`${LOGO + RED + fruit}profile was not found!`) + return; + } + const data = profile.members[res.id].inventory; + ChatLib.chat(`\n${LOGO + RED}Calculating networth for ${username} on ${profile.cute_name}...`); + + // inv_contents value: + const invData = decode(data.inv_contents.data); + + /* + inv_contents + ender_chest_contents + backpack_icons + bag_contents + inv_armor + equipment_contents + personal_vault_contents + wardrobe_equipped_slot + backpack_contents + sacks_counts + wardrobe_contents + */ + }).catch((err) => { + // If there is an error, display the error message in the Minecraft chat. + ChatLib.chat(`${LOGO + DARK_RED + err.cause ?? err}`); + }); + }).catch((err) => { + // If there is an error, display the error message in the Minecraft chat. + ChatLib.chat(`${LOGO + RED + err.cause ?? err}`); + }); +} \ No newline at end of file diff --git a/index.js b/index.js index d9cb04c8..1b65e3c5 100644 --- a/index.js +++ b/index.js @@ -95,6 +95,7 @@ import { getSplits } from "./features/kuudra/KuudraSplits"; import "./features/rift/DDR"; import "./features/rift/VampireSlayer"; import { riftWaypointEdit, soulEdit } from "./features/rift/RiftWaypoints"; +import { getNetworth } from "./features/economy/Networth"; // Launch Tests @@ -263,9 +264,14 @@ register ("command", (...args) => { if (party.size !== 0) ChatLib.chat(`- ${AQUA + BOLD}Members: ${WHITE + party.join(' ')}`); ChatLib.chat(`- ${AQUA + BOLD}Garden: ${WHITE + getTime(getNextVisitor())}`); break; + // Networth + case "networth": + case "nw": + getNetworth(args[1] || Player.getName(), args[2]); + break; // Bestiary Stuff - case "be": case "bestiary": + case "be": getBestiary(args); break; // Attribute Pricing diff --git a/utils/settings.js b/utils/settings.js index 504f3f11..3645ea72 100644 --- a/utils/settings.js +++ b/utils/settings.js @@ -38,7 +38,7 @@ ${DARK_RED + BOLD}CAUTION: Some features are technically chat macros, so use at // Economy Category this.setCategoryDescription("Economy", `${HEADER} -${ITALIC}Related Commands: /va `); +${ITALIC}Related Commands: /va `); // Combat Category this.setCategoryDescription("Combat",