Skip to content

Commit

Permalink
networth day 1
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenga8533 committed Jan 2, 2024
1 parent a11b8a4 commit 66f5d65
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
2 changes: 1 addition & 1 deletion changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
69 changes: 69 additions & 0 deletions features/economy/Networth.js
Original file line number Diff line number Diff line change
@@ -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}`);
});
}
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utils/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <attribute, calc>`);
${ITALIC}Related Commands: /va <attribute, calc, nw>`);

// Combat Category
this.setCategoryDescription("Combat",
Expand Down

0 comments on commit 66f5d65

Please sign in to comment.