Skip to content

Commit

Permalink
v2.6.10 APIng
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenga8533 committed Aug 8, 2023
1 parent cc9386c commit 3517845
Show file tree
Hide file tree
Showing 29 changed files with 444 additions and 477 deletions.
Binary file removed assets/harp.ogg
Binary file not shown.
Binary file removed assets/icechime.ogg
Binary file not shown.
Binary file removed assets/pling.ogg
Binary file not shown.
Binary file removed assets/xylobone.ogg
Binary file not shown.
30 changes: 8 additions & 22 deletions changelog.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
[
"-No longer updating module on ChatTriggers after this release.",
" - FYI: Updates will be open source on GitHub but no longer \"verified\"",
" - The updates will not be automatic and you will have to download via GitHub/Discord.",
"-Added /va bestiary, attribute, calc compost, and gui",
"-Added Inquisitor counter",
"-Added item price in lore",
"-Added Kuudra coinage tracker",
"-Added Auction tracker",
"-Added mythic lava creature stuff",
"-Added powder tracker",
"-Added coin tracker",
"-Changed some settings (you may have to reactivate)",
" -Party settings",
" -Economy settings",
" -Garden settings",
" -Kuudra settings",
"-Changed remove selfie to not render an ugly frame/stuck if disabled",
"-Changed registers to only work in SkyBlock",
"-Removed Kuudra reparty :(",
"-Fixed roman numeral conversion",
"-Fixed being unable to clear lists",
"-Performed some optimizing"
"- Added TPS/FPS/Ping Display",
"- Reworked item pricing",
" - Accounts for godrolls",
" - Accurately tracks all items (ah/bz)",
" - Fixed Pet Tracking (no levels yet)",
"- Fixed mob alert not working",
"- Fixed bestiary not updating on world change",
"- Fixed Kuudra features not working sometimes (i think)"
]
75 changes: 58 additions & 17 deletions features/combat/Bestiary.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
import request from "../../../requestV2";
import settings from "../../settings";
import { BOLD, GOLD, GREEN, LOGO, RED, WHITE } from "../../utils/constants";
import { convertToTitleCase, getTime } from "../../utils/functions";
import { getTime } from "../../utils/functions";
import { getPlayerUUID } from "../../utils/player";
import { delay } from "../../utils/thread";
import { data } from "../../utils/variables";


// Variable to store the player's bestiary data, initially set to undefined.
let bestiaryApi = undefined;

/**
* Makes a PULL request to get bestiary data from the player's info using the Hypixel API.
*/
let bestiaryApi = undefined;
let valid = true;
export function updateBestiary() {
// Make an API request to Hypixel API to get the player's bestiary data from their profile.
// dbf3c137-8778-4cce-8ad1-1b0193a5d3eb
request({
url: `https://api.hypixel.net/skyblock/profile?key=${settings.apiKey}&profile=${data.profileId}`,
json: true
Expand All @@ -25,13 +23,21 @@ export function updateBestiary() {
bestiaryApi = response.profile.members[getPlayerUUID()].bestiary.kills;
}).catch((error) => {
// If there is an error, display the error message in the Minecraft chat.
print(`[VolcAddons] ${error.cause}`);
if (error.cause != "Invalid API key")
delay(updateBestiary, 3000);
else if (settings.apiKey && valid) {
delay(() => ChatLib.chat(`${LOGO} ${RED}${error.cause}!`), 1000);
valid = false;
}
});
}
updateBestiary();
register("worldLoad", () => {
updateBestiary();
});

/**
* Variable and class to track mob bestiary data.
*/
const killBrackets = [
[20, 40, 60, 100, 200, 400, 800, 1400, 2000, 3000, 6000, 12000, 20000, 30000, 40000, 50000, 60000, 72000, 86000, 100000, 200000, 400000, 600000, 800000, 1000000],
[5, 10, 15, 25, 50, 100, 200, 350, 500, 750, 1500, 3000, 5000, 7500, 10000, 12500, 15000, 18000, 21500, 25000, 50000, 100000, 150000, 200000, 250000],
Expand All @@ -42,6 +48,16 @@ const killBrackets = [
[1, 2, 3, 5, 7, 9, 11, 14, 17, 20, 30, 40, 55, 75, 100, 150, 200, 275, 375, 500, 1000, 1500, 2000, 2500, 3000]
];

/**
* Represents a Mob with multiple names and levels, used for tracking kills and progression.
*
* @class Mob
* @param {Array} names - An array of names for the mob.
* @param {Array} levels - An array of levels for the mob.
* @param {number} bracket - The bracket number of the mob.
* @param {number} maxLevel - The maximum level of the mob.
* @param {number} time - The time required to kill the mob.
*/
class Mob {
constructor(names, levels, bracket, maxLevel, time) {
this.names = names;
Expand All @@ -54,20 +70,29 @@ class Mob {
this.time = time;
}

/**
* Updates the number of kills, current level, and time needed for the next kill.
*
* @memberof Mob
*/
updateKills() {
// Calculate total kills by iterating through all the names and levels
this.names.forEach(name => {
this.levels.forEach(level => {
let kills = bestiaryApi[`${name}_${level}`] || 0;
this.kills += kills;
});
});

// Determine the current level based on the kill count and bracket
for (let i = this.bracket.length - 1; i >= 0; i--) {
if (this.kills > this.bracket[i]) {
this.level = i;
break;
}
}

// Calculate the number of kills needed for the next level and the time required for it
this.next = Math.max(this.bracket[Math.min(this.level + 1, this.maxLevel - 1)] - this.kills, 0);
this.nextTime = this.next * this.time;
}
Expand Down Expand Up @@ -96,10 +121,10 @@ const bestiary = {
// The Farming Islands
"Chicken": new Mob(["farming_chicken"], [1], 1, 5, 0.5),
"Cow": new Mob(["farming_cow"], [1], 1, 5, 0.5),
"Mushroom Cow": new Mob(["mushroom_cow"], [1], 1, 5, 0.5),
"Mushroom Cow": new Mob(["mushroom_cow"], [1], 1, 5, 3),
"Pig": new Mob(["farming_pig"], [1], 1, 5, 0.5),
"Rabbit": new Mob(["farming_rabbit"], [1], 1, 5, 1),
"Sheep": new Mob(["farming_sheep"], [1], 1, 5, 1),
"Rabbit": new Mob(["farming_rabbit"], [1], 1, 5, 3),
"Sheep": new Mob(["farming_sheep"], [1], 1, 5, 3),
// Spider's Den
"Arachne": new Mob(["arachne"], [300, 500], 7, 20, 30),
"Arachne's Brood": new Mob(["arachne_brood"], [100, 200], 4, 15, 3),
Expand Down Expand Up @@ -171,7 +196,7 @@ const bestiary = {
"Yog": new Mob(["yog"], [100], 3, 15, 15),
// The Park
"Howling Spirit": new Mob(["howling_spirit"], [35], 2, 15, 2),
"Pack Spirit": new Mob(["pack_spirit"], [35], 2, 15, 2),
"Pack Spirit": new Mob(["pack_spirit"], [30], 2, 15, 2),
"Soul of the Alpha": new Mob(["soul_of_the_alpha"], [55], 4, 15, 6),
// Spooky Festival
"Crazy Witch": new Mob(["batty_witch"], [60], 2, 10, 10),
Expand Down Expand Up @@ -301,25 +326,40 @@ register("worldLoad", () => {
}, 1000);
});

/**
* Sorts and filters the bestiary based on the provided criteria and amount.
*
* @param {String} val - The criteria to sort and filter the bestiary. Possible values: "bracket" or any valid property name in the bestiary object.
* @param {number} amount - The number of entries to include in the final sorted bestiary.
*/
function sortBestiary(val, amount) {
// Filtering the bestiary based on the provided criteria and amount
const filteredBestiary = Object.entries(bestiary).filter(([key, value]) =>
val === "bracket" ? value.bracket === killBrackets[amount - 1] && value.next !== 0 : value.next !== 0
val === "bracket"
? value.bracket === killBrackets[amount - 1] && value.next !== 0
: value.next !== 0
);


// Sorting the filtered bestiary in descending order based on the provided criteria
const sortedBestiary = filteredBestiary.sort((a, b) =>
b[1][val === "bracket" ? "next" : val] - a[1][val === "bracket" ? "next" : val]
).slice(val === "bracket" ? -10 : -amount).reduce((acc, [key, value]) => {
if (value.next !== 0)
acc[key] = value;
acc[key] = value;
return acc;
}, {});


// Displaying the sorted bestiary information in chat
ChatLib.chat(`\n${LOGO} ${WHITE}${BOLD}Leftover Bestiary: `);
Object.keys(sortedBestiary).forEach((key) => {
ChatLib.chat(`${GOLD}${BOLD}${key}: ${GREEN}Needs ${RED}${sortedBestiary[key].next} ${GREEN}kills! (${RED}${getTime(sortedBestiary[key].nextTime)}${GREEN})`);
});
}

/**
* Gets the bestiary information based on the provided arguments and displays the result in chat.
*
* @param {Array} args - An array of arguments containing information about the bestiary query.
*/
export function getBestiary(args) {
switch(args[1]) {
case "kills":
Expand All @@ -340,6 +380,7 @@ export function getBestiary(args) {
if (mob === undefined)
ChatLib.chat(`${LOGO} ${RED}Please input as /va be <mobName OR bracket [1-7] OR <kill, time> [amount]>!`);
else
ChatLib.chat(`${LOGO} ${GOLD}${BOLD}${key}: ${GREEN}Needs ${RED}${mob.next} ${GREEN}kills! (${RED}${getTime(mob.nextTime)}${GREEN})`)
ChatLib.chat(`${LOGO} ${GOLD}${BOLD}${key}: ${GREEN}Needs ${RED}${mob.next} ${GREEN}kills! (${RED}${getTime(mob.nextTime)}${GREEN})`);
break;
}
}
31 changes: 24 additions & 7 deletions features/combat/EntityDetect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,39 @@ function testClass(entity) {
mob = Java.type(entity).class;
World.getAllEntitiesOfType(mob);
entityList.push(mob);
} catch(err) {}
return true;
} catch(err) {
return false;
}
}
export function updateEntityList() {
entityList = [];

data.moblist.forEach(mob => { testClass(`net.minecraft.entity.monster.Entity${convertToPascalCase(mob)}`) });
data.moblist.forEach(boss => { testClass(`net.minecraft.entity.boss.Entity${convertToPascalCase(boss)}`) });
data.moblist.forEach(passive => { testClass(`net.minecraft.entity.passive.Entity${convertToPascalCase(passive)}`) });
data.moblist.forEach(mob => {
const PascalCaseMob = convertToPascalCase(mob);
if (PascalCaseMob === "OtherPlayerMP" && testClass(`net.minecraft.client.entity.Entity${PascalCaseMob}`)) return;
else if (testClass(`net.minecraft.entity.monster.Entity${PascalCaseMob}`)) return;
else if (testClass(`net.minecraft.entity.boss.Entity${PascalCaseMob}`)) return;
else if (testClass(`net.minecraft.entity.passive.Entity${PascalCaseMob}`)) return;
});
}
updateEntityList();

register("tick", () =>{
entities = [];
entityList.forEach(entityClass => {
World.getAllEntitiesOfType(entityClass).forEach(entity => {
entities.push(entity);
});
// Match coloring
const colorMap = {
"monster": [1, 0, 0], // Red
"boss": [0, 1, 0], // Green
"passive": [0, 0, 1], // Blue
};
const color = colorMap[Object.keys(colorMap).find(type => entityClass.toString().includes(type))] || [1, 1, 1];

// Add entities
const filteredEntities = data.y == 0 ? World.getAllEntitiesOfType(entityClass) :
World.getAllEntitiesOfType(entityClass).filter(entity => Math.abs(Player.getY() - entity.getY()) < data.y);
if (filteredEntities.length === 0) return;
entities.push([[...filteredEntities], color]);
});
});
2 changes: 1 addition & 1 deletion features/crimsonIsle/VanqDetect.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function getVanquishers() { return vanquishers };
*/
registerWhen(register("chat", () => {
announceMob(settings.vanqAlert == 1, "Vanquisher", Player.getX(), Player.getY(), Player.getZ());
}).setCriteria("A Vanquisher is spawning nearby!"), () => getWorld() == "Crimson Isle" && settings.vanqAlert);
}).setCriteria("[402] ♫ [MVP+] Volcaronitee: test"), () => getWorld() == "Crimson Isle" && settings.vanqAlert);

/**
* Alerts player when another VA user posts coords.
Expand Down
134 changes: 0 additions & 134 deletions features/economy/Auction.js

This file was deleted.

0 comments on commit 3517845

Please sign in to comment.