Skip to content

Commit

Permalink
Merge branch 'main' into Unverified-Role
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Dec 28, 2024
2 parents 256bce1 + dcbca75 commit 77abee1
Show file tree
Hide file tree
Showing 27 changed files with 481 additions and 210 deletions.
72 changes: 72 additions & 0 deletions API/constants/xp_tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ module.exports = {
social: 25,
dungeoneering: 50,
hotm: 10,
gardenXp: 15,
wheat: 46,
carrot: 46,
potato: 46,
melon: 46,
pumpkin: 46,
sugarCane: 46,
cocoaBeans: 46,
cactus: 46,
mushroom: 46,
netherWart: 46,
},
normal: [
50, 125, 200, 300, 500, 750, 1000, 1500, 2000, 3500, 5000, 7500, 10000, 15000, 20000, 30000, 50000, 75000, 100000,
Expand Down Expand Up @@ -44,4 +55,65 @@ module.exports = {
blaze: [10, 30, 250, 1500, 5000, 20000, 100000, 400000, 1000000],
vampire: [20, 75, 240, 840, 2400],
},
gardenXp: [0, 70, 70, 140, 240, 600, 1500, 2000, 2500, 3000, 10000, 10000, 10000, 10000, 10000],
wheat: [
30, 50, 80, 170, 330, 670, 1330, 2500, 3500, 5000, 6500, 8000, 10000, 20000, 35000, 50000, 75000, 100000, 175000,
250000, 350000, 500000, 750000, 1000000, 1300000, 1600000, 2000000, 2300000, 2600000, 3000000, 3000000, 3000000,
3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000,
3000000,
],
carrot: [
100, 150, 250, 500, 1500, 2500, 5000, 7500, 10000, 15000, 20000, 25000, 40000, 70000, 100000, 200000, 250000,
250000, 500000, 750000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000,
10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000,
10000000, 10000000, 10000000, 10000000, 10000000,
],
potato: [
100, 150, 250, 500, 1500, 2500, 5000, 7500, 10000, 15000, 20000, 25000, 40000, 70000, 100000, 200000, 250000,
250000, 500000, 750000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000,
10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000,
10000000, 10000000, 10000000, 10000000, 10000000,
],
melon: [
150, 250, 400, 850, 1650, 3350, 6650, 12500, 17500, 25000, 32500, 40000, 50000, 100000, 175000, 250000, 375000,
500000, 875000, 1250000, 1750000, 2500000, 3750000, 5000000, 6500000, 8000000, 10000000, 11500000, 13000000,
15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000, 15000000,
15000000, 15000000, 15000000, 15000000, 15000000, 15000000,
],
pumpkin: [
30, 50, 80, 170, 330, 670, 1330, 2500, 3500, 5000, 6500, 8000, 10000, 20000, 35000, 50000, 75000, 100000, 175000,
250000, 350000, 500000, 750000, 1000000, 1300000, 1600000, 2000000, 2300000, 2600000, 3000000, 3000000, 3000000,
3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000,
3000000,
],
sugarCane: [
60, 100, 160, 340, 660, 1340, 2660, 5000, 7000, 10000, 13000, 16000, 20000, 40000, 70000, 100000, 150000, 200000,
350000, 500000, 700000, 1000000, 1500000, 2000000, 2600000, 3200000, 4000000, 4600000, 5200000, 6000000, 6000000,
6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000,
6000000, 6000000,
],
cocoaBeans: [
90, 150, 250, 500, 1000, 2000, 4000, 7500, 10000, 15000, 20000, 25000, 30000, 50000, 100000, 150000, 200000, 300000,
500000, 750000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 9000000,
9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000,
9000000, 9000000,
],
cactus: [
60, 100, 160, 340, 660, 1340, 2660, 5000, 7000, 10000, 13000, 16000, 20000, 40000, 70000, 100000, 150000, 200000,
350000, 500000, 700000, 1000000, 1500000, 2000000, 2600000, 3200000, 4000000, 4600000, 5200000, 6000000, 6000000,
6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000, 6000000,
6000000, 6000000,
],
mushroom: [
30, 50, 80, 170, 330, 670, 1330, 2500, 3500, 5000, 6500, 8000, 10000, 20000, 35000, 50000, 75000, 100000, 175000,
250000, 350000, 500000, 750000, 1000000, 1300000, 1600000, 2000000, 2300000, 2600000, 3000000, 3000000, 3000000,
3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000, 3000000,
3000000,
],
netherWart: [
90, 150, 250, 500, 1000, 2000, 4000, 7500, 10000, 15000, 20000, 25000, 30000, 50000, 100000, 150000, 200000, 300000,
500000, 750000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 9000000,
9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000, 9000000,
9000000, 9000000,
],
};
21 changes: 21 additions & 0 deletions API/functions/getGarden.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable no-throw-literal */
const config = require("../../config.json");
const axios = require("axios");

async function getGarden(profileID, uuid) {
try {
const { data } = await axios.get(
`https://api.hypixel.net/v2/skyblock/garden?key=${config.minecraft.API.hypixelAPIkey}&profile=${profileID}`,
);

if (data === undefined || data.success === false) {
throw "Request to Hypixel API failed. Please try again!";
}

return { garden: data.garden };
} catch (e) {
throw new Error(e);
}
}

module.exports = { getGarden };
14 changes: 5 additions & 9 deletions API/functions/getLatestProfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* eslint-disable no-throw-literal */
const { getUUID } = require("../../src/contracts/API/mowojangAPI.js");
const { getMuseum } = require("./getMuseum.js");
const { getGarden } = require("./getGarden.js");
const { isUuid } = require("../utils/uuid.js");
const config = require("../../config.json");
const axios = require("axios");

const cache = new Map();

async function getLatestProfile(uuid, options = { museum: false }) {
async function getLatestProfile(uuid, options = { museum: false, garden: false }) {
if (!isUuid(uuid)) {
uuid = await getUUID(uuid).catch((error) => {
throw error;
Expand All @@ -22,21 +23,16 @@ async function getLatestProfile(uuid, options = { museum: false }) {
}
}

const [{ data: playerRes }, { data: profileRes }] = await Promise.all([
axios.get(`https://api.hypixel.net/v2/player?key=${config.minecraft.API.hypixelAPIkey}&uuid=${uuid}`),
const [{ data: profileRes }] = await Promise.all([
axios.get(`https://api.hypixel.net/v2/skyblock/profiles?key=${config.minecraft.API.hypixelAPIkey}&uuid=${uuid}`),
]).catch((error) => {
throw error?.response?.data?.cause ?? "Request to Hypixel API failed. Please try again!";
});

if (playerRes.success === false || profileRes.success === false) {
if (profileRes.success === false) {
throw "Request to Hypixel API failed. Please try again!";
}

if (playerRes.player == null) {
throw "Player not found. It looks like this player has never joined the Hypixel.";
}

if (profileRes.profiles == null || profileRes.profiles.length == 0) {
throw "Player has no SkyBlock profiles.";
}
Expand All @@ -56,9 +52,9 @@ async function getLatestProfile(uuid, options = { museum: false }) {
profiles: profileRes.profiles,
profile: profile,
profileData: profileData,
playerRes: playerRes.player,
uuid: uuid,
...(options.museum ? await getMuseum(profileData.profile_id, uuid) : {}),
...(options.garden ? await getGarden(profileData.profile_id) : {}),
};

cache.set(uuid, output);
Expand Down
19 changes: 19 additions & 0 deletions API/stats/garden.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const calcSkill = require("../constants/skills.js");

module.exports = (profile) => {
return {
level: calcSkill("gardenXp", profile?.garden_experience || 0),
cropMilesstone: {
wheat: calcSkill("wheat", profile?.resources_collected?.WHEAT || 0),
carrot: calcSkill("carrot", profile?.resources_collected?.CARROT_ITEM || 0),
sugarCane: calcSkill("sugarCane", profile?.resources_collected?.SUGAR_CANE || 0),
potato: calcSkill("potato", profile?.resources_collected?.POTATO_ITEM || 0),
netherWart: calcSkill("netherWart", profile?.resources_collected?.NETHER_STALK || 0),
pumpkin: calcSkill("pumpkin", profile?.resources_collected?.PUMPKIN || 0),
melon: calcSkill("melon", profile?.resources_collected?.MELON || 0),
mushroom: calcSkill("mushroom", profile?.resources_collected?.MUSHROOM_COLLECTION || 0),
cocoaBeans: calcSkill("cocoaBeans", profile?.resources_collected?.["INK_SACK:3"] || 0),
cactus: calcSkill("cactus", profile?.resources_collected?.CACTUS || 0),
},
};
};
20 changes: 1 addition & 19 deletions API/stats/hotm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,8 @@ const miningConst = require("../constants/mining.js");
const calcSkill = require("../constants/skills.js");
const moment = require("moment");

module.exports = (player, profile) => {
module.exports = (profile) => {
try {
const commissions = {
total: player?.achievements?.skyblock_hard_working_miner ?? 0,
milestone: 0,
};

// CREDITS: https://github.com/SkyCryptWebsite/SkyCrypt/blob/b9842bea6f1494fa2d2fd005b64f57d84646c188/src/stats/mining.js#L129
if (profile.objectives?.tutorial !== undefined) {
for (const key of profile.objectives.tutorial) {
if (key.startsWith("commission_milestone_reward_mining_xp_tier_") === false) {
continue;
}

const tier = parseInt(key.slice(43));
commissions.milestone = Math.max(commissions.milestone, tier);
}
}

const forgeItems = [];
if (profile.forge?.forge_processes?.forge_1) {
const forge = Object.values(profile.forge.forge_processes.forge_1);
Expand Down Expand Up @@ -80,7 +63,6 @@ module.exports = (player, profile) => {
},
level: calcSkill("hotm", profile?.mining_core?.experience || 0),
ability: titleCase(profile?.mining_core?.selected_pickaxe_ability || "none", true),
commissions: commissions,
forge: forgeItems,
};
} catch (error) {
Expand Down
1 change: 0 additions & 1 deletion data/linked.json

This file was deleted.

12 changes: 8 additions & 4 deletions src/Application.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const MinecraftManager = require("./minecraft/MinecraftManager.js");
const { existsSync, mkdirSync, writeFileSync } = require("fs");
const DiscordManager = require("./discord/DiscordManager.js");
const webManager = require("./web/WebsiteManager.js");
// eslint-disable-next-line no-unused-vars
const Configuration = require("./Configuration.js");
// eslint-disable-next-line no-unused-vars
const Updater = require("./Updater.js");

class Application {
constructor() {
require("./Configuration.js");
require("./Updater.js");
if (!existsSync("./data/")) mkdirSync("./data/", { recursive: true });
if (!existsSync("./data/linked.json")) writeFileSync("./data/linked.json", JSON.stringify({}));
}

async register() {
this.discord = new DiscordManager(this);
this.minecraft = new MinecraftManager(this);
Expand Down
9 changes: 7 additions & 2 deletions src/discord/commands/blacklistCommand.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const HypixelDiscordChatBridgeError = require("../../contracts/errorHandler.js");
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const { SuccessEmbed } = require("../../contracts/embedHandler.js");

module.exports = {
Expand All @@ -24,24 +25,28 @@ module.exports = {
],
},
{
name: "name",
name: "username",
description: "Minecraft Username",
type: 3,
required: true,
},
],

execute: async (interaction) => {
const name = interaction.options.getString("name");
const name = interaction.options.getString("username");
const arg = interaction.options.getString("arg").toLowerCase();

bot.chat("/lobby megawalls");
await delay(250);
if (arg == "add") {
bot.chat(`/ignore add ${name}`);
} else if (arg == "remove") {
bot.chat(`/ignore remove ${name}`);
} else {
throw new HypixelDiscordChatBridgeError("Invalid Usage: `/ignore [add/remove] [name]`.");
}
await delay(250);
bot.chat("/limbo");

const embed = new SuccessEmbed(
`Successfully ${arg == "add" ? "added" : "removed"} \`${name}\` ${arg == "add" ? "to" : "from"} the blacklist.`,
Expand Down
4 changes: 2 additions & 2 deletions src/discord/commands/demoteCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ module.exports = {
requiresBot: true,
options: [
{
name: "name",
name: "username",
description: "Minecraft Username",
type: 3,
required: true,
},
],

execute: async (interaction) => {
const name = interaction.options.getString("name");
const name = interaction.options.getString("username");
bot.chat(`/g demote ${name}`);

const embed = new SuccessEmbed(`Successfully demoted \`${name}\` by one guild rank.`);
Expand Down
2 changes: 1 addition & 1 deletion src/discord/commands/forceVerifyCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
required: true,
},
{
name: "name",
name: "username",
description: "Minecraft Username",
type: 3,
required: true,
Expand Down
Loading

0 comments on commit 77abee1

Please sign in to comment.