diff options
author | Ninjune <enderknight537@gmail.com> | 2022-12-07 21:36:53 -0600 |
---|---|---|
committer | Ninjune <enderknight537@gmail.com> | 2022-12-07 21:36:53 -0600 |
commit | 1ffc0a89be42fcde95a04a87cc00dbc347b27ece (patch) | |
tree | 87ef5251d1fc2a32d495daa8f6a94e173c701f8e | |
parent | 8ad19e54f6c3f44a84dd2565d910c207ffc5bc52 (diff) | |
download | coleweight-1ffc0a89be42fcde95a04a87cc00dbc347b27ece.tar.gz coleweight-1ffc0a89be42fcde95a04a87cc00dbc347b27ece.tar.bz2 coleweight-1ffc0a89be42fcde95a04a87cc00dbc347b27ece.zip |
v1.7.0v1.7.0
-rw-r--r-- | chat/grieferTrack.js | 2 | ||||
-rw-r--r-- | commandManager.js | 105 | ||||
-rw-r--r-- | commands/calculate/calcSpeed.js | 47 | ||||
-rw-r--r-- | commands/calculate/calculate.js | 36 | ||||
-rw-r--r-- | commands/calculate/hotmCalc.js | 55 | ||||
-rw-r--r-- | commands/calculate/tick.js (renamed from commands/tick.js) | 10 | ||||
-rw-r--r-- | commands/credits.js | 7 | ||||
-rw-r--r-- | commands/help.js | 10 | ||||
-rw-r--r-- | commands/spiral.js | 2 | ||||
-rw-r--r-- | commands/throne.js | 2 | ||||
-rw-r--r-- | data/collections.json | 87 | ||||
-rw-r--r-- | data/hotm.json | 151 | ||||
-rw-r--r-- | index.js | 1 | ||||
-rw-r--r-- | metadata.json | 2 | ||||
-rw-r--r-- | render/collectionGui.js | 64 | ||||
-rw-r--r-- | render/cwGui.js | 2 | ||||
-rw-r--r-- | render/downtimeGui.js | 14 | ||||
-rw-r--r-- | render/gemstoneMiningStats.js | 66 | ||||
-rw-r--r-- | render/tabList.js | 39 | ||||
-rw-r--r-- | settings.js | 56 | ||||
-rw-r--r-- | util/constants.js | 15 | ||||
-rw-r--r-- | util/helperFunctions.js | 231 |
22 files changed, 894 insertions, 110 deletions
diff --git a/chat/grieferTrack.js b/chat/grieferTrack.js index 5ac186f..f4ae0e4 100644 --- a/chat/grieferTrack.js +++ b/chat/grieferTrack.js @@ -58,4 +58,6 @@ register("gameLoad", () => { ChatLib.chat(err) }) }) + + export default ""
\ No newline at end of file diff --git a/commandManager.js b/commandManager.js index 62623f8..c6c3e55 100644 --- a/commandManager.js +++ b/commandManager.js @@ -2,7 +2,8 @@ import { openTimerGui } from "./render/timerGui.js" import { openPowderGui } from "./render/powertrackerGui" import { openCoordsGui } from "./render/coordsGui.js" import { openDowntimeGui } from "./render/downtimeGui.js" -import { openCwGui, reload } from "./render/cwGui" +import { openCwGui, reloadColeweight } from "./render/cwGui" +import { openCollectionGui, reloadCollection, trackCollection } from "./render/collectionGui" import { help } from "./commands/help" import { setkey } from "./commands/setkey" import { spiral } from "./commands/spiral" @@ -13,27 +14,29 @@ import { update } from "./commands/update" import { fetchDiscord } from "./commands/fetchDiscord" import { findColeweight } from "./commands/findColeweight" import { claim } from "./commands/claim" -import { tick } from "./commands/tick" import { time } from "./commands/time" import { info } from "./commands/info" +import { credits } from "./commands/credits" import Settings from "./settings" import constants from "./util/constants" import { clearLobbies } from "./commands/markingLobbies" import { divans } from "./commands/divans.js" +import { calculate } from "./commands/calculate/calculate.js" -register("command", (arg, arg2, arg3) => { - if (arg == undefined) {findColeweight(arg); return} - switch(arg.toLowerCase()) +register("command", (...args) => { + console.log(args[0]) + if (args[0] == undefined) {findColeweight(args[0]); return} + switch(args[0].toString().toLowerCase()) { case "setkey": - setkey(arg2) + setkey(args[1]) break case "help": help() break case "move": - if (arg2 == undefined) {ChatLib.chat(`${constants.PREFIX}&cNot enough arguments.`); return} - switch(arg2.toLowerCase()) + if (args[1] == undefined) {ChatLib.chat(`${constants.PREFIX}&cNot enough arguments.`); return} + switch(args[1].toLowerCase()) { case "coleweight": openCwGui() @@ -48,21 +51,34 @@ register("command", (arg, arg2, arg3) => { case "downtime": openDowntimeGui() break + case "collection": + openCollectionGui() + break default: ChatLib.chat(`${constants.PREFIX}&cNo such gui as '${arg2}'.`) } break case "throne": - throne(arg2) + throne(args[1]) break case "spiral": - spiral(arg2) + spiral(args[1]) break case "reload": - reload() + switch(args[1].toLowerCase()) + { + case "coleweight": + reloadColeweight() + break + case "collection": + reloadCollection() + break + default: + ChatLib.chat(`${constants.PREFIX}&cNo such gui as '${args[1]}'.`) + } break case "leaderboard": - leaderboard(arg2, arg3) + leaderboard(args[1], args[2]) break case "update": update() @@ -72,14 +88,11 @@ register("command", (arg, arg2, arg3) => { Settings.openGUI() break case "claim": - claim(arg2) + claim(args[1]) break case "powdertrackersync": updateDisplay() break - case "tick": - tick(arg2, arg3) - break case "time": time() break @@ -90,37 +103,71 @@ register("command", (arg, arg2, arg3) => { clearLobbies() break case "yog": - yog(arg2) + yog(args[1]) break case "divans": case "divan": - divans(arg2) + divans(args[1]) break case "coord": case "coords": openCoordsGui() break + case "credits": + credits() + break + case "track": + trackCollection(args[1]) + break + case "calc": + case "calculate": + calculate(args.slice(1)) + break default: - findColeweight(arg) + findColeweight(args[0]) } }).setTabCompletions((args) => { let output = [], + calculateOptions = ["tick", "ms2toprofessional", "hotmcalc", "calchotm"], commands = ["setkey", "help", "move", "toggle", "throne", "spiral", "reload", "leaderboard", - "settings", "claim", "tick", "time", "info", "clearlobbies", "yog", "divan", "coords"] + "settings", "claim", "time", "info", "clearlobbies", "yog", "divan", "coords", "credits", "track", "calculate"] if(args[0].length == 0 || args[0] == undefined) - output = commands + return output = commands + + if(args[0] == "calc" || args[0] == "calculate") + { + if(args[1] == undefined) output = calculateOptions + + else + { + calculateOptions.forEach(calculateOption => { + for(let char = 0; char < args[1].length; char++) + { + if(calculateOption[char] != args[1][char]) + break + else if(char == args[1].length - 1) + output.push(calculateOption) + } + }) + } + } else { - for(let i = 0; i < commands.length; i++) + + if(args[0] == undefined) output = commands + + else { - for(let j = 0; j < args[0].length; j++) - { - if(commands[i][j] != args[0][j]) - break - else if(j == args[0].length - 1) - output.push(commands[i]) - } + commands.forEach(command => { + for(let char = 0; char < args[0].length; char++) + { + if(command[char] != args[0][char]) + break + else if(char == args[0].length - 1) + output.push(command) + } + }) } } return output diff --git a/commands/calculate/calcSpeed.js b/commands/calculate/calcSpeed.js new file mode 100644 index 0000000..1b2eae6 --- /dev/null +++ b/commands/calculate/calcSpeed.js @@ -0,0 +1,47 @@ +import constants from "../../util/constants" +import { parseNotatedInput } from "../../util/helperFunctions" +const PREFIX = constants.PREFIX + + +export function calcSpeed(powder) +{ + let speedLevels = 1, + professionalLevels = 1 + + if(powder == undefined || parseNotatedInput(powder) == "NI") return ChatLib.chat(constants.CALCULATEERRORMESSAGE) + powder = parseNotatedInput(powder) + + while(powder > msPowder(speedLevels) + profPowder(professionalLevels)) + { + if(ms2SpeedPerPowder(speedLevels + 1) > professionalSpeedPerPowder(professionalLevels + 1) && speedLevels < 50) + { + powder -= msPowder(speedLevels++) + } + else if (professionalLevels < 140) + { + powder -= profPowder(professionalLevels++) + } + else break + } + return ChatLib.chat(`&bGet &6&l${speedLevels} &bmining speed levels and &6&l${professionalLevels} &bprofessional levels.`) +} + +function ms2SpeedPerPowder(miningSpeedLevel) // 40 speed per level +{ + return 40/msPowder(miningSpeedLevel) +} + +function professionalSpeedPerPowder(professionalLevel) // 5 speed per level +{ + return 5/profPowder(professionalLevel) +} + +function msPowder(miningSpeedLevel) +{ + return Math.floor(Math.pow(miningSpeedLevel+1, 3.2)) +} + +function profPowder(professionalLevel) +{ + return Math.floor(Math.pow(professionalLevel+1, 2.3)) +}
\ No newline at end of file diff --git a/commands/calculate/calculate.js b/commands/calculate/calculate.js new file mode 100644 index 0000000..cc4a006 --- /dev/null +++ b/commands/calculate/calculate.js @@ -0,0 +1,36 @@ +import constants from "../../util/constants" +import { hotmCalc } from "./hotmCalc" +import { calcSpeed } from "./calcSpeed" +import { tick } from "./tick" +import { helpCommand } from "../help" +const PREFIX = constants.PREFIX + + +export function calculate(args) +{ + switch(args[0].toLowerCase()) + { + case "hotm": + case "hotmcalc": + case "calchotm": + hotmCalc(args[1], args[2], args[3]) + break + case "tick": + tick(args[1], args[2]) + break + case "calcspeed": + case "speed": + calcSpeed(args[1]) + break + case "help": + ChatLib.chat("&b--------------[ &a&l/cw calculate &b]--------------") + helpCommand("calculate tick", "Calculates tick data.", "(mining speed) (('r','jade', etc) || breaking power of block))") + helpCommand("calculate speed", "Calculates the ratio of mining speed 2 to professional with a certain amount of powder.", "(powder)") + helpCommand("calculate hotm", "Calculates powder between two levels of a certain perk.", "(perk) (minlevel) [maxlevel]") + ChatLib.chat("&b------------------------------------------") + return + default: + return ChatLib.chat(constants.CALCULATEERRORMESSAGE) + } +} + diff --git a/commands/calculate/hotmCalc.js b/commands/calculate/hotmCalc.js new file mode 100644 index 0000000..415e7f4 --- /dev/null +++ b/commands/calculate/hotmCalc.js @@ -0,0 +1,55 @@ +import constants from "../../util/constants" +import { addCommas } from "../../util/helperFunctions" +const PREFIX = constants.PREFIX + + +export function hotmCalc(hotmName, minLevel, maxLevel) +{ + if(maxLevel == undefined) + { + maxLevel = minLevel + minLevel = 1 + } + + if(minLevel != parseInt(minLevel) || maxLevel != parseInt(maxLevel)) return ChatLib.chat(constants.CALCULATEERRORMESSAGE) + + minLevel = parseInt(minLevel) + maxLevel = parseInt(maxLevel) + let hotmObjectToFind = findHotmObject(hotmName) + if(hotmObjectToFind == undefined) return ChatLib.chat(`${PREFIX}&cDid not find HOTM perk with name '${hotmName}'!`) + + maxLevel = (maxLevel < hotmObjectToFind.maxLevel ? maxLevel : hotmObjectToFind.maxLevel) + + let powderSum = findCost(hotmObjectToFind.costFormula, minLevel, maxLevel), + reward = findReward(hotmObjectToFind.rewardFormula, minLevel, maxLevel) + + ChatLib.chat("") + ChatLib.chat(`&6${hotmObjectToFind.nameStringed} ${minLevel} - ${maxLevel} &bwill cost &6&l${addCommas(Math.round(powderSum))} &6${hotmObjectToFind.powderType[0].toUpperCase() + hotmObjectToFind.powderType.slice(1)} &bpowder.`) + ChatLib.chat(`&6${hotmObjectToFind.nameStringed} ${minLevel} - ${maxLevel} &bwill give &6&l${addCommas(Math.round(reward * 100) / 100)} &bof whatever reward is listed.`) + ChatLib.chat("") +} + +export function findHotmObject(hotmName) +{ + let hotmData = JSON.parse(FileLib.read("Coleweight", "data/hotm.json")).data + + for(let i = 0; i < hotmData.length; i++) + { + if(hotmData[i].names.includes(hotmName)) + return hotmData[i] + } +} + +export function findCost(costFormula, minLevel, maxLevel) +{ + let powderSum = 0 + + for(let currentLevel = minLevel; currentLevel < maxLevel; currentLevel++) // finds cost + powderSum += eval(costFormula.replace("currentLevel", currentLevel)) + return powderSum +} + +export function findReward(rewardFormula, minLevel, maxLevel) +{ + return eval(rewardFormula.replace("Level", 1+maxLevel-minLevel)) +}
\ No newline at end of file diff --git a/commands/tick.js b/commands/calculate/tick.js index 7af81e2..5969710 100644 --- a/commands/tick.js +++ b/commands/calculate/tick.js @@ -1,12 +1,14 @@ -import constants from "../util/constants" +import constants from "../../util/constants" const PREFIX = constants.PREFIX export function tick(speed, block) { - if(speed == undefined || parseInt(speed) != speed) - return `${PREFIX}&cMining speed must be an integer!` + if(speed == undefined || parseInt(speed) != speed) + return ChatLib.chat(`${PREFIX}&cMining speed must be an integer!`) + if(block == undefined) + return ChatLib.chat(constants.CALCULATEERRORMESSAGE) let strength = findStrength(block) - if(strength < 1) return `${PREFIX}&cBlock must be a gemstone or positive breaking power! (or starting letter of gemstone)` + if(strength < 1) return ChatLib.chat(`${PREFIX}&cBlock must be a gemstone or positive breaking power! (or starting letter of gemstone)`) let currentBlockTick = strength*30/speed, currentShardTick = (strength-200)*30/speed, nextBlockSpeed, nextShardSpeed diff --git a/commands/credits.js b/commands/credits.js new file mode 100644 index 0000000..af4aa28 --- /dev/null +++ b/commands/credits.js @@ -0,0 +1,7 @@ +import constants from "../util/constants" +const PREFIX = constants.PREFIX + +export function credits() +{ + ChatLib.chat(`${PREFIX}&bCW was made by Ninjune#0670 (NinOnCubed).`) +}
\ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 05c5a04..8e06b51 100644 --- a/commands/help.js +++ b/commands/help.js @@ -7,14 +7,15 @@ export function help() helpCommand("", "Gets Coleweight of specified user", "(username)") helpCommand("help", "This menu.", "") helpCommand("time", "Prints time on timer (timer gui doesn't have to be visible).", "") - helpCommand("tick", "Shows tick data.", "(mining speed) (('r','jade', etc) || breaking power of block))") + helpCommand("calculate", "Calculates things. '/cw calculate help' for more info.", "") helpCommand("leaderboard", "Shows leaderboard.", "(min) [max]") helpCommand("info", "Prints coleweight info.", "") ChatLib.chat(ChatLib.getCenteredText("&a&lSettings")) helpCommand("settings", "Opens settings.", "") helpCommand("claim", "Claims a chollows sapphire structure in a lobby.", "(throne || spiral)") - helpCommand("setkey", "Sets API key (can also use /api new)-", "(key)") + helpCommand("setkey", "Sets API key (can also use /api new)", "(key)") helpCommand("reload", "Reloads the gui.", "") + helpCommand("track", "Sets tracked collection for collection tracker.", "(collection)") ChatLib.chat(ChatLib.getCenteredText("&a&lWaypoints")) helpCommand("coords", "Opens coords gui.", "") helpCommand("throne", "Guide for setting up waypoints for throne.", "[toggle]") @@ -27,8 +28,7 @@ export function help() } // Made by Almighty Stylla <3 -function helpCommand(command, desc, usage) +export function helpCommand(command, desc, usage) { ChatLib.chat(new TextComponent(`&a${PREFIX} /cw ${command} => &b${desc}`).setHoverValue(`${"/cw " + command + " " + usage}`)) -} - +}
\ No newline at end of file diff --git a/commands/spiral.js b/commands/spiral.js index 6574f18..f9f00aa 100644 --- a/commands/spiral.js +++ b/commands/spiral.js @@ -45,7 +45,7 @@ export function spiral(arg2) } register("renderWorld", () => { - waypointRender(spiralWaypoints, true) + waypointRender(spiralWaypoints, true, true) }) register("worldLoad", () => { diff --git a/commands/throne.js b/commands/throne.js index 517c93d..c3a2e1c 100644 --- a/commands/throne.js +++ b/commands/throne.js @@ -41,7 +41,7 @@ export function throne(arg2) register("renderWorld", () => { - waypointRender(throneWaypoints, true) + waypointRender(throneWaypoints, true, true) }) diff --git a/data/collections.json b/data/collections.json new file mode 100644 index 0000000..e61a942 --- /dev/null +++ b/data/collections.json @@ -0,0 +1,87 @@ +{ + "gemstone": + { + "collectionToTrack": "GEMSTONE_COLLECTION", + "collectionStringed": "Gemstone" + }, + "mithril": + { + "collectionToTrack": "MITHRIL_ORE", + "collectionStringed": "Mithril" + }, + "gold": + { + "collectionToTrack": "GOLD_INGOT", + "collectionStringed": "Gold" + }, + "obsidian": + { + "collectionToTrack": "OBSIDIAN", + "collectionStringed": "Obsidian" + }, + "netherrack": + { + "collectionToTrack": "NETHERRACK", + "collectionStringed": "Netherrack" + }, + "diamond": + { + "collectionToTrack": "DIAMOND", + "collectionStringed": "Diamond" + }, + "ice": + { + "collectionToTrack": "ICE", + "collectionStringed": "Ice" + }, + "redstone": + { + "collectionToTrack": "REDSTONE", + "collectionStringed": "Redstone" + }, + "lapis": + { + "collectionToTrack": "INK_SACK:4", + "collectionStringed": "Lapis" + }, + "coal": + { + "collectionToTrack": "COAL", + "collectionStringed": "Coal" + }, + "emerald": + { + "collectionToTrack": "EMERALD", + "collectionStringed": "Emerald" + }, + "endstone": + { + "collectionToTrack": "ENDER_STONE", + "collectionStringed": "Endstone" + }, + "glowstone": + { + "collectionToTrack": "GLOWSTONE_DUST", + "collectionStringed": "Glowstone" + }, + "iron": + { + "collectionToTrack": "IRON_INGOT", + "collectionStringed": "Iron" + }, + "mycelium": + { + "collectionToTrack": "MYCEL", + "collectionStringed": "Mycelium" + }, + "quartz": + { + "collectionToTrack": "QUARTZ", + "collectionStringed": "Endstone" + }, + "cobblestone": + { + "collectionToTrack": "COBBLESTONE", + "collectionStringed": "Cobblestone" + } +}
\ No newline at end of file diff --git a/data/hotm.json b/data/hotm.json new file mode 100644 index 0000000..6eda953 --- /dev/null +++ b/data/hotm.json @@ -0,0 +1,151 @@ +{"data": [ + { + "costFormula": "Math.pow((currentLevel+1), 3)", + "rewardFormula": "Level*20", + "nameStringed": "Mining Speed", + "names": ["miningspeed", "speed", "ms"], + "maxLevel": 50, + "powderType": "mithril" + }, + { + "costFormula": "Math.pow((currentLevel+1), 3.05)", + "rewardFormula": "Level*5", + "nameStringed": "Mining Fortune", + "names": ["miningfortune", "fortune", "mf"], + "maxLevel": 50, + "powderType": "mithril" + + }, + { + "costFormula": "Math.pow((currentLevel+1), 4)", + "rewardFormula": "10+(Level*0.5)", + "nameStringed": "Quick Forge", + "names": ["quickforge", "forge"], + "maxLevel": 20, + "powderType": "mithril" + }, + { + "costFormula": "200+((currentLevel-1)*18)", + "rewardFormula": "(200+((Level-1)*18))*2", + "nameStringed": "Titanium Insanium", + "names": ["titaniuminsanium", "titanium", "tita"], + "maxLevel": 50, + "powderType": "mithril" + }, + { + "costFormula": "200+((currentLevel-1)*18)", + "rewardFormula": "(200+((Level-1)*18))*2", + "nameStringed": "Titanium Insanium", + "names": ["dailypowder"], + "maxLevel": 100, + "powderType": "mithril" + }, + { + "costFormula": "Math.pow((currentLevel+1), 3.07)", + "rewardFormula": "5+Level", + "nameStringed": "Luck Of The Cave", + "names": ["luckofthecave", "caveluck", "luck"], + "maxLevel": 45, + "powderType": "mithril" + }, + { + "costFormula": "Math.pow((currentLevel+1), 3.4)", + "rewardFormula": "20+((Level-1)*6)", + "nameStringed": "Crystallized", + "names": ["crystallized"], + "maxLevel": 30, + "powderType": "mithril" + }, + { + "costFormula": "Math.pow((currentLevel+1), 2.6)", + "rewardFormula": "10+(Level*0.4)", + "nameStringed": "Efficient Miner", + "names": ["efficientminer", "efficient"], + "maxLevel": 100, + "powderType": "mithril" + }, + { + "costFormula": "currentLevel*70", + "rewardFormula": "0.2+(Level*0.01)", + "nameStringed": "Orbiter", + "names": ["orbiter", "orbit"], + "maxLevel": 80, + "powderType": "mithril" + }, + { + "costFormula": "Math.pow((currentLevel+1), 2.3)", + "rewardFormula": "5+(Level*0.1)", + "nameStringed": "Seasoned Mineman", + "names": ["seasonedmineman", "mineman"], + "maxLevel": 100, + "powderType": "mithril" + }, + { + "1": { "cost": "0", "reward": "+1 Pickaxe Ability Level;+1 Token of the Mountain", "powderType": "mithril"}, + "2": { "cost": "50000", "reward": "+1 Forge Slot", "powderType": "mithril" }, + "3": { "cost": "75000", "reward": "+1 Commission Slot" }, + "4": { "cost": "100000", "reward": "+1 base ᠅ Mithril Powder when mining Mithril", "powderType": "mithril" }, + "5": { "cost": "125000", "reward": "+1 Token of the Mountain", "powderType": "mithril" }, + "6": { "cost": "500000", "reward": "+1 base ᠅ Gemstone Powder when mining Gemstones", "powderType": "gemstone" }, + "7": { "cost": "750000", "reward": "+1 Token of the Mountain", "powderType": "gemstone"}, + "nameStringed": "Peak of the Mountain", + "names": ["peakofthemountain", "peak", "potm"], + "maxLevel": 7 + }, + { + "costFormula": "Math.pow((currentLevel+1), 2.2)", + "rewardFormula": "50+((Level-1)*5", + "nameStringed": "Mole", + "names": ["mole"], + "maxLevel": 190, + "powderType": "gemstone" + }, + { + "costFormula": "Math.pow((currentLevel+1), 2.3)", + "rewardFormula": "50+(Level*5)", + "nameStringed": "Professional", + "names": ["professional", "prof"], + "maxLevel": 140, + "powderType": "gemstone" + }, + { + "costFormula": "Math.pow((currentLevel+1), 3.07)", + "rewardFormula": "5+((Level-1)*0.5)", + "nameStringed": "Lonesome Miner", + "names": ["lonesomeminer", "lonesome"], + "maxLevel": 45, + "powderType": "gemstone" + }, + { + "costFormula": "Math.pow((currentLevel+1), 4)", + "rewardFormula": "20+(4*(Level-1))", + "nameStringed": "Great Explorer", + "names": ["greatexplorer", "explorer"], + "maxLevel": 20, + "powderType": "gemstone" + }, + { + "costFormula": "Math.pow((currentLevel+1), 3.2)", + "rewardFormula": "Level*0.01", + "nameStringed": "Powder Buff", + "names": ["powderbuff", "powder"], + "maxLevel": 50, + "powderType": "gemstone" + }, + { + "costFormula": "Math.pow((currentLevel+1), 3.2)", + "rewardFormula": "Level*40", + "nameStringed": "Mining Speed II", + "names": ["miningspeedii", "miningspeed2", "speed2", "ms2"], + "maxLevel": 50, + "powderType": "gemstone" + }, + { + "costFormula": "Math.pow((currentLevel+1), 3.2)", + "rewardFormula": "Level*5", + "nameStringed": "Mining Fortune II", + "names": ["miningfortuneii", "miningfortune2", "fortune2", "mf2"], + "maxLevel": 50, + "powderType": "gemstone" + } +]}
\ No newline at end of file @@ -1,5 +1,6 @@ import './render/naturals' import './render/tabList' +import './render/gemstoneMiningStats' import './commands/yog' import './chat/apiNew' import './chat/message' diff --git a/metadata.json b/metadata.json index 034e1f8..c36134f 100644 --- a/metadata.json +++ b/metadata.json @@ -3,6 +3,6 @@ "creator": "Ninjune", "entry": "index.js", "description": "Mining utilities.", - "version": "1.6.11", + "version": "1.7.0", "requires": ["axios", "PogData", "Vigilance", "Elementa"] }
\ No newline at end of file diff --git a/render/collectionGui.js b/render/collectionGui.js index 8197b11..4e6deee 100644 --- a/render/collectionGui.js +++ b/render/collectionGui.js @@ -1,43 +1,53 @@ -/*import constants from "../util/constants" +import constants from "../util/constants" +import settings from "../settings" +import { trackerGui } from "../util/helperFunctions" const PREFIX = constants.PREFIX +const collectionMoveGui = new Gui() +const collectionGui = new trackerGui("", "Collection Not set! /cw track", settings.collectionNotation) -let collectionGui = new Gui(), - collection = "" export function trackCollection(arg) { - switch(arg) - { - case "obby": - case "obsidian": - collection = "OBSIDIAN" - break - default: - ChatLib.chat(`${PREFIX}&eThat is not a valid collection! (or is not supported)`) - } + collectionGui.resetVars() + let collections = JSON.parse(FileLib.read("Coleweight", "data/collections.json")) + if(arg == "obby") arg = "obsidian" + if(arg == "cobble") arg = "cobblestone" + if(collections[arg.toLowerCase()] == undefined) return ChatLib.chat(`${PREFIX}&eThat is not a valid collection! (or is not supported)`) + collectionGui.trackedItem = collections[arg].collectionToTrack + collectionGui.itemStringed = collections[arg].collectionStringed + + ChatLib.chat(`${PREFIX}&bSet collection to ${collectionGui.itemStringed}!`) +} + +export function openCollectionGui() +{ + collectionGui.moveGui() } -export function moveCollection() +export function reloadCollection() { - collectionGui.open() + collectionGui.resetVars() } register("dragged", (dx, dy, x, y) => { - if (!collectionGui.isOpen()) return - constants.data.collectionX = x - constants.data.collectionY = y - constants.data.save() + if (!collectionGui.collectionMoveGui.isOpen()) return + constants.collectiondata.x = x + constants.collectiondata.y = y + constants.collectiondata.save() }) register("renderOverlay", () => { - if (cwGui.isOpen()) + collectionGui.renderGui(constants.collectiondata.x, constants.collectiondata.y, settings.collectionNotation, settings.collectionTracker) +}) + +register("step", () => { + let date_ob = new Date(), + seconds = date_ob.getSeconds() + + if(collectionGui.trackingItem == true) + collectionGui.uptimeSeconds += 1 + if(seconds == 0 || seconds == 15 || seconds == 30 || seconds == 45) { - let txt = "Please set your api key with /cw setkey (key)!" - if (constants.data.api_key != undefined) - txt = "Click anywhere to move!" - Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2) - Renderer.drawStringWithShadow(`&aCollection: &b0\n&aCW/hr: &b0\n&aUptime: &b0m\n&aColeweight Gained: &b0`, constants.data.collectionX, constants.data.collectionY) + collectionGui.calcApi(["members", Player.getUUID().replace(/-/g, ""), "collection"], Player.getUUID()) } - if(collection == "") return - coleweight > 1000 ?collectionMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`: coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}` -})*/
\ No newline at end of file +}).setFps(1)
\ No newline at end of file diff --git a/render/cwGui.js b/render/cwGui.js index 5af6773..0695e1c 100644 --- a/render/cwGui.js +++ b/render/cwGui.js @@ -21,7 +21,7 @@ export function openCwGui() } -export function reload() +export function reloadColeweight() { upTimeTrack = false stepsSinceLast = 0 diff --git a/render/downtimeGui.js b/render/downtimeGui.js index 538c590..e11c376 100644 --- a/render/downtimeGui.js +++ b/render/downtimeGui.js @@ -21,9 +21,9 @@ export function openDowntimeGui() register("dragged", (dx, dy, x, y) => { if (!downtimeMoveGui.isOpen()) return - constants.downtimedata.x = x - constants.downtimedata.y = y - constants.downtimedata.save() + constants.collectiondata.x = x + constants.collectiondata.y = y + constants.collectiondata.save() }) register('actionbar', (xp) => { @@ -57,16 +57,16 @@ register("renderOverlay", () => { let txt = "Drag to move." Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2) downtimeGui.guiObject = {leftValues: ["Downtime", "Overall Downtime", "Average Downtime", "Uptime"], rightValues: [0, 0, 0, 0]} - downtimeGui.x = constants.downtimedata.x - downtimeGui.y = constants.downtimedata.y + downtimeGui.x = constants.collectiondata.x + downtimeGui.y = constants.collectiondata.y downtimeGui.renderGui() return } if (downtimeCount == 0 || !trackingDowntime || !settings.downtimeTracker) return let avgDowntime = Math.ceil((overallDowntime/downtimeCount)*100) / 100 downtimeGui.guiObject = {leftValues: ["Downtime", "Overall Downtime", "Average Downtime", "Uptime"], rightValues: [downtime, overallDowntime, avgDowntime, uptime]} - downtimeGui.x = constants.downtimedata.x - downtimeGui.y = constants.downtimedata.y + downtimeGui.x = constants.collectiondata.x + downtimeGui.y = constants.collectiondata.y downtimeGui.renderGui() }) diff --git a/render/gemstoneMiningStats.js b/render/gemstoneMiningStats.js new file mode 100644 index 0000000..a44937c --- /dev/null +++ b/render/gemstoneMiningStats.js @@ -0,0 +1,66 @@ +import settings from "../settings" +import constants from "../util/constants" +const NBTTagString = Java.type("net.minecraft.nbt.NBTTagString") + + +register("itemTooltip", (lore, item) => { // this is so bad 💀 + if(item.getLore()[0] != "§o§aYour SkyBlock Profile§r" || !settings.gemstoneMiningStats) return + const list = new NBTTagList(item.getNBT().getCompoundTag("tag").getCompoundTag("display").getTagMap().get("Lore")) + + for(let index = 0; index < list.getTagCount(); index++) + { + let element = list.getStringTagAt(index) + if(element !== ` §6⸕ Mining Speed §f${element.replace(" §6⸕ Mining Speed §f", "").replace("§", "")}` || constants.data.professional == 0) + continue + let miningSpeed = element.replace(" §6⸕ Mining Speed §f", "").replace("§", ""), + professionalSpeed = parseInt(miningSpeed.toString().replace(",", "")) + Math.floor(50+(constants.data.professional*5)), + miningSpeedText = `${element} §6(§b${professionalSpeed}§6)` + + list.set(index, new NBTTagString(miningSpeedText)) + } + + for(let i = 0; i < list.getTagCount(); i++) + { + let element = list.getStringTagAt(i) + if(element !== ` §6☘ Mining Fortune §f${element.replace(" §6☘ Mining Fortune §f", "").replace("§", "")}` || constants.data.jungle_amulet == false) + continue + let miningFortune = element.replace(" §6☘ Mining Fortune §f", "").replace("§", ""), + replacedFortune = parseInt(miningFortune.toString().replace(",", "")) + 10, + miningFortuneText = `${element} §6(§b${replacedFortune}§6)` + + list.set(i, new NBTTagString(miningFortuneText)) + } +}) + + +register("itemTooltip", (lore, item) => { + if(item.getLore()[0] != "§o§aProfessional§r") return + constants.data.professional = parseInt(item.getLore()[1].replace("§5§o§7Level ", "")) + constants.data.save() +}) + + +register('step', () => { + let inventoryName = Player?.getOpenedInventory()?.getName()?.toString() + if(inventoryName == undefined) return + if(inventoryName.includes("Acessory Bag ")) { + for (i = 0; i < Player.getOpenedInventory().size; i++) { + let extraAttributes = Player.getOpenedInventory().getStackInSlot(i)?.getNBT()?.getCompoundTag("tag")?.getCompoundTag("ExtraAttributes") + if (extraAttributes.getString('id') == "JUNGLE_AMULET") + { + constants.data.jungle_amulet = true + constants.data.save() + } + } + } +}).setFps(2) + + +/* +let checked = false +register("itemTooltip", (lore, item) => { + if(!settings.debug || checked) return + console.log(item.getLore()) + checked = true +}) +*/
\ No newline at end of file diff --git a/render/tabList.js b/render/tabList.js index fcf971e..aa16445 100644 --- a/render/tabList.js +++ b/render/tabList.js @@ -1,26 +1,29 @@ -/*import axios from "../../axios" // implement when im not an idiot +/*import axios from "../../axios" // ♒ import settings from "../settings" import constants from "../util/constants" const PREFIX = constants.PREFIX - +const ChatComponentText = Java.type("net.minecraft.util.ChatComponentText") register("worldLoad", () => { - const NetHandlerPlayClient = Client.getConnection(), - PlayerMap = NetHandlerPlayClient.func_175106_d() // getPlayerInfoMap + const NetHandlerPlayClient = Client.getMinecraft().func_147114_u(), + PlayerMap = NetHandlerPlayClient.func_175106_d() let tag = "" - axios.get(`https://ninjune.dev/api/mminers`) - .then((res) => { - PlayerMap.filter(player => !player.func_178845_a().name.startsWith("!")).forEach((player) => { - res.data.macroers.forEach((macroer) => { - if(player == macroer) tag ="[M] " - }) - res.data.griefers.forEach((griefer) => { - if(player == griefer) tag ="[G] " - }) - - player.func_178859_a(new net.minecraft.util.IChatComponentText("Player")) - }) + //axios.get(`https://ninjune.dev/api/mminers`) + //.then((res) => { + PlayerMap.filter(player => player.func_178853_c() > 0 && !player.func_178845_a().name.startsWith("!")).forEach((PlayerMP, index) => { + let player = PlayerMP.func_178845_a().name // getGameProfile + console.dir(PlayerMP) + PlayerMP.func_178859_a(new ChatComponentText("Hello World")) // setDisplayName; takes an IChatComponent; doesn't do anything. + PlayerMP.func_178850_i().func_96662_c("Hello World") // getPlayerTeam; setNameSuffix; doesn't do anything }) - .catch((e) => {console.log(e)}) -})*/
\ No newline at end of file + //.catch((e) => {console.log(e)}) + //}) +}) +/*res.data.macroers.forEach((macroer) => { + if(player == macroer) tag ="[M] " +}) +res.data.griefers.forEach((griefer) => { + if(player == griefer) tag ="[G] " +}) +*/
\ No newline at end of file diff --git a/settings.js b/settings.js index 3a5e1c7..b8a6959 100644 --- a/settings.js +++ b/settings.js @@ -54,6 +54,22 @@ class Settings { claiming = true; @SwitchProperty({ + name: "Gemstone mining stats", + description: "Shows gemstone mining speed/fortune on player profile. (includes professional and jungle amulet)", + subcategory: "Random Features", + category: "General" + }) + gemstoneMiningStats = true; + + @SwitchProperty({ + name: "Debug", + description: "Toggles debug mode.", + subcategory: "Random Features", + category: "General" + }) + debug = false; + + @SwitchProperty({ name: "Downtime tracker", description: "Tracks downtime.", subcategory: "Downtime", @@ -73,12 +89,31 @@ class Settings { } @SwitchProperty({ - name: "Debug", - description: "Toggles debug mode.", - subcategory: "Random Features", + name: "Collection tracker", + description: "Tracks collections ('/cw trackcollection (collection)' to set).", + subcategory: "Collection", category: "General" }) - debug = false; + collectionTracker = false; + + @SwitchProperty({ + name: "Collection notation", + description: "Changes collection to be abbrivated like '45K' or '2M'.", + subcategory: "Collection", + category: "General" + }) + collectionNotation = true; + + @ButtonProperty({ + name: "Change collection tracker position", + description: "Move the location of the collection tracker.", + subcategory: "Collection", + category: "General", + placeholder: "Open" + }) + moveCollectionLocation() { + ChatLib.command("cw move collection", true); + } @SwitchProperty({ name: "Marked lobbies", @@ -187,6 +222,12 @@ class Settings { this.registerListener("Claiming", value => { this.claiming = value; }) + this.registerListener("Gemstone mining stats", value => { + this.gemstoneMiningStats = value; + }) + this.registerListener("Debug", value => { + this.debug = value; + }) this.registerListener("Marked lobbies", value => { this.lobbyMarking = value; }) @@ -196,8 +237,11 @@ class Settings { this.registerListener("Downtime tracker", value => { this.downtimeTracker = value; }) - this.registerListener("Debug", value => { - this.debug = value; + this.registerListener("Collection tracker", value => { + this.collectionTracker = value; + }) + this.registerListener("Collection notation", value => { + this.collectionNotation = value; }) this.registerListener("Show powdertracker", value => { this.trackerVisible = value; diff --git a/util/constants.js b/util/constants.js index 95664dd..5155132 100644 --- a/util/constants.js +++ b/util/constants.js @@ -2,6 +2,8 @@ import PogObject from "PogData" let PogData = new PogObject("Coleweight", { "api_key": "", + "professional": 0, + "jungle_amulet": true, "x": 0.5, "y": 141, "coleweight": 0, @@ -27,14 +29,23 @@ let DowntimeData = new PogObject("Coleweight", { "y": 0 }, "config/.downtime_data.json") +let CollectionData = new PogObject("Coleweight", { + "x": 0, + "y": 0 +}, "config/.collection_data.json") + +const PREFIX = "&2[CW] " export default { - PREFIX: "&2[CW] ", + PREFIX: PREFIX, + CALCULATEERRORMESSAGE: `${PREFIX}&cInvalid arguments. '/cw calculate help' for more information.`, + INVALIDARGS: `${PREFIX}&cInvalid arguments. '/cw help' for more information.`, VERSION: (JSON.parse(FileLib.read("Coleweight", "metadata.json"))).version, data: PogData, powderdata: PowderData, timerdata: TimerData, - downtimedata: DowntimeData, + collectiondata: DowntimeData, + collectiondata: CollectionData, throneValues: [], spiralValues: [], beta: false, diff --git a/util/helperFunctions.js b/util/helperFunctions.js index 7a3927d..8c51cdb 100644 --- a/util/helperFunctions.js +++ b/util/helperFunctions.js @@ -1,3 +1,7 @@ +import axios from "../../axios"; +import settings from "../settings"; +import constants from "./constants"; + export function addCommas(num) { try { return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); @@ -7,19 +11,65 @@ export function addCommas(num) { }// credit to senither for the regex, just don't care to make my own lol -export function waypointRender(waypoints, yellow=false) +export function addNotation(type, value) { + let returnVal = value; + let notList = []; + if (type === "shortScale") { + notList = [ + " Thousand", + " Million", + " Billion", + " Trillion", + " Quadrillion", + " Quintillion" + ]; + } + + if (type === "oneLetters") { + notList = [" K", " M", " B", " T"]; + } + + let checkNum = 1000; + if (type !== "none" && type !== "commas") { + let notValue = notList[notList.length - 1]; + for (let u = notList.length; u >= 1; u--) { + notValue = notList.shift() + for (let o = 3; o >= 1; o--) { + if (value >= checkNum) { + returnVal = value / (checkNum / 100) + returnVal = Math.floor(returnVal) + returnVal = (returnVal / Math.pow(10, o)) * 10 + returnVal = +returnVal.toFixed(o - 1) + notValue + } + checkNum *= 10; + } + } + } else { + returnVal = numberWithCommas(value.toFixed(0)) + } + + return returnVal +} + + +export function waypointRender(waypoints, yellow=false, numbered=false) { + let string = "" if(waypoints.length < 1) return - waypoints.forEach((waypoint) => { - if(yellow) - Tessellator.drawString(Math.floor((Math.abs(parseInt(Player.getX()) - waypoint[0]) + Math.abs(parseInt(Player.getY()) - waypoint[1]) + Math.abs(parseInt(Player.getZ()) - waypoint[2]))/3) + "m", waypoint[0], waypoint[1], waypoint[2], 0xFAFD01) + waypoints.forEach((waypoint, index) => { + string = Math.floor((Math.abs(parseInt(Player.getX()) - waypoint[0]) + Math.abs(parseInt(Player.getY()) - waypoint[1]) + Math.abs(parseInt(Player.getZ()) - waypoint[2]))/3) + "m" + if (numbered) + string = index + 1 + + if (yellow) + Tessellator.drawString(string, waypoint[0], waypoint[1], waypoint[2], 0xFAFD01) else - Tessellator.drawString(Math.floor((Math.abs(parseInt(Player.getX()) - waypoint[0]) + Math.abs(parseInt(Player.getY()) - waypoint[1]) + Math.abs(parseInt(Player.getZ()) - waypoint[2]))/3) + "m", waypoint[0], waypoint[1], waypoint[2]) + Tessellator.drawString(string, waypoint[0], waypoint[1], waypoint[2]) }) } -export class textGui // first class I've made, gonna be dog +export class textGui // guiObject format: { leftValues: [], rightValues: [] } (must have same amount of each or error). { constructor(guiObject, x, y) @@ -36,7 +86,7 @@ export class textGui // first class I've made, gonna be dog this.guiObject.leftValues.forEach((leftValue, index) => { if(leftValue == "Uptime") { - let uptime = this.guiObject.rightValues[index], + let uptime = this.guiObject.rightValues[index] ?? 0, uptimeHr = Math.floor(uptime/60/60) if(uptimeHr >= 1) @@ -45,7 +95,172 @@ export class textGui // first class I've made, gonna be dog string += `&aUptime: &b${Math.floor(uptime/60)}m ${Math.floor(uptime%60)}s\n` } else + { string += `&a${leftValue}: &b${this.guiObject.rightValues[index]}\n` + } }) - Renderer.drawStringWithShadow(string, this.x, this.y) } + Renderer.drawStringWithShadow(string, this.x, this.y) + } +} + +export class trackerGui +{ + constructor(trackedItem = "", itemStringed = "") + { + this.itemStringed = itemStringed + this.trackedItem = trackedItem + this.itemValues = [] + this.uptimeSeconds = 0 + this.trackingItem = false + this.apiCallsSinceLastChange = 0 + this.calcItemPerHour = false + this.itemValuesSum = 0 + this.itemPerHour = 0 + this.itemGui = new textGui() + this.currentItem = 0 + this.collectionMoveGui = new Gui() + } + + renderGui(x, y, notation = false, renderGui = true) // can only be called in renderOverlay + { + let leftValues = [`${this.itemStringed}`, `${this.itemStringed}/hr`, `${this.itemStringed} gained`, "Uptime"] + this.itemGui.x = x + this.itemGui.y = y + if (this.collectionMoveGui.isOpen()) + { + let txt = "Drag to move." + + Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2) + if(notation) + this.itemGui.guiObject = {leftValues: leftValues, rightValues: [addNotation("oneLetters", this.currentItem) ?? 0, addNotation("oneLetters", this.itemPerHour) ?? 0, addNotation("oneLetters", this.itemValuesSum) ?? 0, this.uptimeSeconds]} + else + this.itemGui.guiObject = {leftValues: leftValues, rightValues: [addCommas(this.currentItem) ?? 0, addCommas(this.itemPerHour) ?? 0, addCommas(this.itemValuesSum) ?? 0, this.uptimeSeconds]} + + return this.itemGui.renderGui() + } + if(!renderGui) return + if(this.itemValues[0] != undefined && this.trackingItem && this.calcItemPerHour) + { + for(let i = 0; i < this.itemValues.length; i++) + this.itemValuesSum += this.itemValues[i] + let eq = Math.ceil((this.itemValuesSum*(3600/this.uptimeSeconds)) * 100) / 100 + eq != Infinity ? this.itemPerHour = eq : this.itemPerHour = "Calculating..." + this.calcItemPerHour = false + } + + if(notation) + this.itemGui.guiObject = {leftValues: leftValues, rightValues: [addNotation("oneLetters", this.currentItem) ?? 0, addNotation("oneLetters", this.itemPerHour) ?? 0, addNotation("oneLetters", this.itemValuesSum) ?? 0, this.uptimeSeconds]} + else + this.itemGui.guiObject = {leftValues: leftValues, rightValues: [addCommas(this.currentItem) ?? 0, addCommas(this.itemPerHour) ?? 0, addCommas(this.itemValuesSum) ?? 0, this.uptimeSeconds]} + + this.itemGui.renderGui() + } + + calcApi(apiPath, tempUuid) + { + if(this.trackedItem == "" || constants.data.api_key == "") return + let profileData = "", + uuid = "" + + for(let i = 0; i < tempUuid.length; i++) + { + if(tempUuid[i] != "-") + { + uuid += tempUuid[i] + } + } + + try + { + axios.get(`https://api.hypixel.net/skyblock/profiles?key=${constants.data.api_key}&uuid=${uuid}`) + .then(res => { + for(let i=0; i < res.data.profiles.length; i+=1) + { + if(res.data.profiles[i].selected == true) + profileData = res.data.profiles[i] + } + let source = getObjectValue(profileData, apiPath)[this.trackedItem] + + if(this.currentItem == 0 || this.currentItem == undefined) + { + this.currentItem = source + } + else if ((source - this.currentItem) > 0) + { + this.itemValues.push(source - this.currentItem) + this.calcItemPerHour = true + this.trackingItem = true + this.apiCallsSinceLastChange = 0 + this.currentItem = source + } + else if (this.apiCallsSinceLastChange > 20) + { + this.uptimeSeconds = 0 + this.trackingItem = false + this.apiCallsSinceLastChange = 0 + this.itemValues = [] + } + else + { + this.apiCallsSinceLastChange += 1 + } + }) + } + catch(e) { if(settings.debug) console.log(e)} + } + resetVars() + { + this.currentItem = 0 + this.itemValues = [] + this.uptimeSeconds = 0 + this.trackingItem = false + this.apiCallsSinceLastChange = 0 + this.itemPerHour = "Calculating..." + this.itemValuesSum = 0 + } + moveGui() + { + this.collectionMoveGui.open() + } +} + + +function getObjectValue(obj, path, def) +{ + let current = obj + + for (let i = 0; i < path.length; i++) + current = current[path[i]] // could be source of issues + + return current + +} + + +export function parseNotatedInput(input) +{ + for(let index = 0; index < input.length; index++) + { + + switch(input[index]) + { + case 'k': + return 1000 * parseFloat(input.slice(0, index)) + case 'm': + return 1000000 * parseFloat(input.slice(0, index)) + } + } + if(parseFloat(input) == input) + return parseFloat(input) + else + return "NI" // not integer +} + +export function getSelectedProfile(res) +{ + for(let i=0; i < res.data.profiles.length; i+=1) + { + if(res.data.profiles[i].selected == true) + return res.data.profiles[i] + } }
\ No newline at end of file |