Skip to content

Commit

Permalink
Garden Command
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Oct 25, 2024
1 parent 26cb9c7 commit 796239f
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 2 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 };
4 changes: 3 additions & 1 deletion 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 Down Expand Up @@ -59,6 +60,7 @@ async function getLatestProfile(uuid, options = { museum: false }) {
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),
},
};
};
40 changes: 40 additions & 0 deletions src/minecraft/commands/gardenCommand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { getLatestProfile } = require("../../../API/functions/getLatestProfile.js");
const { formatUsername } = require("../../contracts/helperFunctions.js");
const minecraftCommand = require("../../contracts/minecraftCommand.js");
const getGarden = require("../../../API/stats/garden.js");

class GardenCommand extends minecraftCommand {
constructor(minecraft) {
super(minecraft);

this.name = "garden";
this.aliases = [];
this.description = "Skyblock Garden Stats of specified user.";
this.options = [
{
name: "username",
description: "Minecraft username",
required: false,
},
];
}

async onCommand(username, message) {
try {
// CREDITS: by @Kathund (https://github.com/Kathund)
username = this.getArgs(message)[0] || username;

const data = await getLatestProfile(username, { garden: true });
username = formatUsername(username, data.profileData?.game_mode);
const garden = getGarden(data.garden);

this.send(
`/gc ${username}'s garden ${garden.level.level} | Crop Milestones: Wheat: ${garden.cropMilesstone.wheat.level} | Carrot: ${garden.cropMilesstone.carrot.level} | Cane: ${garden.cropMilesstone.sugarCane.level} | Potato: ${garden.cropMilesstone.potato.level} | Wart: ${garden.cropMilesstone.netherWart.level} | Pumpkin: ${garden.cropMilesstone.pumpkin.level} | Melon: ${garden.cropMilesstone.melon.level} | Mushroom: ${garden.cropMilesstone.mushroom.level} | Cocoa: ${garden.cropMilesstone.cocoaBeans.level} | Cactus: ${garden.cropMilesstone.cactus.level}`,
);
} catch (error) {
this.send(`/gc [ERROR] ${error}`);
}
}
}

module.exports = GardenCommand;
2 changes: 1 addition & 1 deletion src/minecraft/commands/jacobCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class JacobCommand extends minecraftCommand {
super(minecraft);

this.name = "jacob";
this.aliases = ["jacobs", "garden", "jacobcontest", "contest"];
this.aliases = ["jacobs", "jacobcontest", "contest"];
this.description = "Jacob's Contest Stats of specified user.";
this.options = [];
}
Expand Down

0 comments on commit 796239f

Please sign in to comment.