diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/calculate/calculate.js | 7 | ||||
-rw-r--r-- | commands/calculate/hotmCalc.js | 63 | ||||
-rw-r--r-- | commands/calculate/tick.js | 80 | ||||
-rw-r--r-- | commands/claim.js | 5 | ||||
-rw-r--r-- | commands/coords/automatons.js | 53 | ||||
-rw-r--r-- | commands/coords/divans.js (renamed from commands/divans.js) | 4 | ||||
-rw-r--r-- | commands/coords/spiral.js (renamed from commands/spiral.js) | 4 | ||||
-rw-r--r-- | commands/coords/throne.js (renamed from commands/throne.js) | 4 | ||||
-rw-r--r-- | commands/coords/yog.js (renamed from commands/yog.js) | 4 | ||||
-rw-r--r-- | commands/drawLine.js | 42 | ||||
-rw-r--r-- | commands/findColeweight.js | 4 | ||||
-rw-r--r-- | commands/help.js | 5 | ||||
-rw-r--r-- | commands/info.js | 29 | ||||
-rw-r--r-- | commands/setkey.js | 2 |
14 files changed, 230 insertions, 76 deletions
diff --git a/commands/calculate/calculate.js b/commands/calculate/calculate.js index cc4a006..8ed05bf 100644 --- a/commands/calculate/calculate.js +++ b/commands/calculate/calculate.js @@ -1,7 +1,7 @@ import constants from "../../util/constants" import { hotmCalc } from "./hotmCalc" import { calcSpeed } from "./calcSpeed" -import { tick } from "./tick" +import { tickCommand } from "./tick" import { helpCommand } from "../help" const PREFIX = constants.PREFIX @@ -16,14 +16,15 @@ export function calculate(args) hotmCalc(args[1], args[2], args[3]) break case "tick": - tick(args[1], args[2]) + tickCommand(args[1], args[2]) break case "calcspeed": case "speed": calcSpeed(args[1]) break case "help": - ChatLib.chat("&b--------------[ &a&l/cw calculate &b]--------------") + ChatLib.chat("&b--------------[ &a&l/cw calculate &b]------------") + ChatLib.chat("&7(Hover over command to see usage.)") 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]") diff --git a/commands/calculate/hotmCalc.js b/commands/calculate/hotmCalc.js index 415e7f4..7fa947c 100644 --- a/commands/calculate/hotmCalc.js +++ b/commands/calculate/hotmCalc.js @@ -5,28 +5,46 @@ const PREFIX = constants.PREFIX export function hotmCalc(hotmName, minLevel, maxLevel) { - if(maxLevel == undefined) + if(hotmName == undefined) { - maxLevel = minLevel - minLevel = 1 + let hotmData = JSON.parse(FileLib.read("Coleweight", "data/hotm.json")).data + + ChatLib.chat(`/cw calc hotm (hotmName listed below) (minLevel) [maxLevel]`) + for(let i = 0; i < hotmData.length; i++) + { + ChatLib.chat(hotmData[i].names[0]) + } + return } + new Thread(() => { + if(maxLevel == undefined) + { + maxLevel = minLevel + minLevel = 1 + } + + if(minLevel != parseInt(minLevel) || maxLevel != parseInt(maxLevel)) return ChatLib.chat(constants.CALCULATEERRORMESSAGE) - 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}'!`) - 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, + reward = findReward(hotmObjectToFind.rewardFormula, minLevel, maxLevel) - maxLevel = (maxLevel < hotmObjectToFind.maxLevel ? maxLevel : hotmObjectToFind.maxLevel) + if(hotmObjectToFind.names[0] == "fortunate") + powderSum = findCost(undefined, minLevel, maxLevel, true) + else + powderSum = findCost(hotmObjectToFind.costFormula, minLevel, 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("") + + 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("") + }).start() } export function findHotmObject(hotmName) @@ -35,17 +53,22 @@ export function findHotmObject(hotmName) for(let i = 0; i < hotmData.length; i++) { - if(hotmData[i].names.includes(hotmName)) + if(hotmData[i].names.includes(hotmName.toLowerCase())) return hotmData[i] } } -export function findCost(costFormula, minLevel, maxLevel) +export function findCost(costFormula, minLevel, maxLevel, fortunate = false) { let powderSum = 0 - for(let currentLevel = minLevel; currentLevel < maxLevel; currentLevel++) // finds cost - powderSum += eval(costFormula.replace("currentLevel", currentLevel)) + if(fortunate) + powderSum = Math.pow(maxLevel+1, 3.05) + else + { + for(let currentLevel = minLevel; currentLevel <= maxLevel; currentLevel++) // finds cost + powderSum += eval(costFormula.replace("currentLevel", currentLevel)) + } return powderSum } diff --git a/commands/calculate/tick.js b/commands/calculate/tick.js index 5969710..674aa91 100644 --- a/commands/calculate/tick.js +++ b/commands/calculate/tick.js @@ -1,50 +1,86 @@ import constants from "../../util/constants" const PREFIX = constants.PREFIX -export function tick(speed, block) +export function tickCommand(speed, block) { 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 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 + const ticks = findTick(speed, block) + if(ticks.err) return ChatLib.chat(`${PREFIX}&cBlock must be a gemstone or positive breaking power! (or starting letter of gemstone)`) + - if(currentBlockTick < Math.floor(currentBlockTick) + 0.5) - nextBlockSpeed = strength*30/(Math.floor(currentBlockTick)-0.5) + ChatLib.chat(`\n&bCurrently mining blocks in &6&l${Math.round(ticks.currentBlockTick)} ticks` + + `\n&bCurrently mining shards in &6&l${Math.round(ticks.currentShardTick)} ticks` + + `\n&bNext block tick will be at: &6&l${Math.round(ticks.nextBlockSpeed)} mining speed` + + `\n&bNext shard tick will be at: &6&l${Math.round(ticks.nextShardSpeed)} mining speed` + + `\n&bYou need &6&l${Math.round(ticks.nextBlockSpeed - speed)} mining speed&b to get the next block tick.` + + `\n&bYou need &6&l${Math.round(ticks.nextShardSpeed - speed)} mining speed&b to get the next shard tick.\n`) +} + + +export function findTick(speed, block) +{ + let ticks = {err: false}, + strength = findStrength(block), + tickStrength = strength-200 + + ticks.currentBlockTick = strength*30/speed + ticks.currentShardTick = tickStrength*30/speed + + if(ticks.currentBlockTick < 4.5) + { + if(ticks.currentBlockTick > 0.5) + ticks.currentBlockTick = 4 + } + + if(ticks.currentShardTick < 4.5) + { + if(ticks.currentShardTick > 0.5) + ticks.currentShardTick = 4 + } + + if(strength < 1) return ticks.err = true + + + if(ticks.currentBlockTick < Math.floor(ticks.currentBlockTick) + 0.5) + ticks.nextBlockSpeed = strength*30/(Math.floor(ticks.currentBlockTick)-0.5) else - nextBlockSpeed = strength*30/(Math.floor(currentBlockTick)+0.5) + ticks.nextBlockSpeed = strength*30/(Math.floor(ticks.currentBlockTick)+0.5) - if(currentShardTick < Math.floor(currentShardTick) + 0.5) - nextShardSpeed = strength*30/(Math.floor(currentShardTick)-0.5) + if(ticks.currentShardTick < Math.floor(ticks.currentShardTick) + 0.5) + ticks.nextShardSpeed = strength*30/(Math.floor(ticks.currentShardTick)-0.5) else - nextShardSpeed = strength*30/(Math.floor(currentShardTick)+0.5) + ticks.nextShardSpeed = strength*30/(Math.floor(ticks.currentShardTick)+0.5) - ChatLib.chat(`\n&bCurrently mining blocks in &6&l${Math.round(currentBlockTick)} ticks` + - `\n&bCurrently mining shards in &6&l${Math.round(currentShardTick)} ticks` + - `\n&bNext block tick will be at: &6&l${Math.round(nextBlockSpeed)} mining speed` + - `\n&bNext shard tick will be at: &6&l${Math.round(nextShardSpeed)} mining speed` + - `\n&bYou need &6&l${Math.round(nextBlockSpeed - speed)} mining speed&b to get the next block tick.` + - `\n&bYou need &6&l${Math.round(nextShardSpeed - speed)} mining speed&b to get the next shard tick.\n`) + return ticks } function findStrength(block) { let strength = -1 - if(block == parseInt(block)) + if(block == parseInt(block) && block > 5) // change if add block to tick speed blocks in settings strength = block else { - switch(block.toLowerCase()) + switch(block.toString().toLowerCase()) { + case "0": + case "green_mithril": + strength = 800 + break + case "1": + case "blue_mithril": + strength = 1500 + break + case "2": case "ruby": case "r": strength = 2500 break + case "3": case "j": case "jade": case "a": @@ -54,11 +90,15 @@ function findStrength(block) case "sapphire": strength = 3200 break + case "4": case "t": case "topaz": case "o": case "opal": strength = 4000 + case "5": + case "jasper": + strength = 5000 } } diff --git a/commands/claim.js b/commands/claim.js index e3f9a0d..a8c51c6 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -59,16 +59,12 @@ register('gameLoad', (event) => { Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) } catch(e) {} - // what if a player claims after gameload? idk man, making requests every worldload is hurting my server. - // this feature is barely used anyway. getClaimed() }) register('worldLoad', () => { if(!settings.claiming) return - if(claimedServers == undefined) - getClaimed() setTimeout(() => { const NetHandlerPlayClient = Client.getConnection(), PlayerMap = NetHandlerPlayClient.func_175106_d() // getPlayerInfoMap @@ -112,6 +108,7 @@ function getClaimed() Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) return } + claimedServers = [] res.data.forEach(server => { claimedServers.push(server) }) diff --git a/commands/coords/automatons.js b/commands/coords/automatons.js new file mode 100644 index 0000000..4114eec --- /dev/null +++ b/commands/coords/automatons.js @@ -0,0 +1,53 @@ +import constants from "../../util/constants" +import { waypointRender } from "../../util/helperFunctions" + +const PREFIX = constants.PREFIX +let waypoints = [] + +export function automatons(arg) +{ + const WAYPOINTNAME = "Automatons" + + if(arg != "toggle") + { + new TextComponent(`${PREFIX}&bStand in the pot in &3this&b picture and do /cw ${WAYPOINTNAME} toggle`) + .setClickAction("open_url") + .setClickValue("https://media.discordapp.net/attachments/1049475464667856926/1052749218055475210/image.png") + .chat() + } + else + { + if(waypoints[0] == undefined) + { + let startPos = [Player.getX(), Player.getY(), Player.getZ()], + x = startPos[0], + y = startPos[1], + z = startPos[2] + + let coordsRows = FileLib.read("Coleweight", "data/automatons.txt").split("\r\n") + coordsRows.forEach(unsplitRow => { + let row = unsplitRow.split(" ") + + waypoints.push([x + parseInt(row[0]), y + parseInt(row[1]), z + parseInt(row[2])]) + }) + + ChatLib.chat(`${PREFIX}&b${WAYPOINTNAME} waypoints turned on!`) + } + else + { + waypoints = [] + ChatLib.chat(`${PREFIX}&b${WAYPOINTNAME} waypoints turned off!`) + } + } +} + +register("renderWorld", () => { + waypointRender(waypoints) +}) + + +register("worldLoad", () => { + waypoints = [] +}) + +export default ""
\ No newline at end of file diff --git a/commands/divans.js b/commands/coords/divans.js index c5e618a..98b56dd 100644 --- a/commands/divans.js +++ b/commands/coords/divans.js @@ -1,5 +1,5 @@ -import constants from "../util/constants" -import { waypointRender } from "../util/helperFunctions" +import constants from "../../util/constants" +import { waypointRender } from "../../util/helperFunctions" const PREFIX = constants.PREFIX let divanWaypoints = [] diff --git a/commands/spiral.js b/commands/coords/spiral.js index f9f00aa..7092aa9 100644 --- a/commands/spiral.js +++ b/commands/coords/spiral.js @@ -1,5 +1,5 @@ -import constants from "../util/constants" -import { waypointRender } from "../util/helperFunctions" +import constants from "../../util/constants" +import { waypointRender } from "../../util/helperFunctions" const PREFIX = constants.PREFIX let spiralWaypoints = [] diff --git a/commands/throne.js b/commands/coords/throne.js index c3a2e1c..6e1e104 100644 --- a/commands/throne.js +++ b/commands/coords/throne.js @@ -1,5 +1,5 @@ -import constants from "../util/constants" -import { waypointRender } from "../util/helperFunctions" +import constants from "../../util/constants" +import { waypointRender } from "../../util/helperFunctions" const PREFIX = constants.PREFIX let throneWaypoints = [] diff --git a/commands/yog.js b/commands/coords/yog.js index 1544553..e02b4a2 100644 --- a/commands/yog.js +++ b/commands/coords/yog.js @@ -1,5 +1,5 @@ -import constants from "../util/constants" -import { waypointRender } from "../util/helperFunctions" +import constants from "../../util/constants" +import { waypointRender } from "../../util/helperFunctions" const PREFIX = constants.PREFIX let yogWaypoints = [] diff --git a/commands/drawLine.js b/commands/drawLine.js new file mode 100644 index 0000000..7fd9742 --- /dev/null +++ b/commands/drawLine.js @@ -0,0 +1,42 @@ +import constants from "../util/constants" +import { trace } from "../util/renderUtil" +const PREFIX = constants.PREFIX + +let x = 0, + y = 0, + z = 0 + +export function drawLine(args) +{ + switch(args.length - 1) + { + case 0: + case 1: + x = 0 + y = 0 + z = 0 + ChatLib.chat(`${PREFIX}&bStopped drawing line.`) + return + case 2: + x = args[1] + y = Player.getY() + 1 + z = args[2] + break + case 3: + x = args[1] + y = args[2] + z = args[3] + break + default: + ChatLib.chat(constants.INVALIDARGS) + return + } + ChatLib.chat(`${PREFIX}&bNow drawing line to &a${x} ${Math.round(y)} ${z}`) +} + + +register("renderWorld", () => { + if(x == 0 && y == 0 && z == 0) return + + trace(x, y, z, 0, 0, 1, 0.86) +})
\ No newline at end of file diff --git a/commands/findColeweight.js b/commands/findColeweight.js index d3fa38a..ace0ec6 100644 --- a/commands/findColeweight.js +++ b/commands/findColeweight.js @@ -13,9 +13,9 @@ export function findColeweight(arg) axios.get(`https://ninjune.dev/api/coleweight?username=${username}`) .then(res => { let coleweightMessage = new TextComponent(`${PREFIX}&b${res.data.rank}. ${res.data.name}&b's Coleweight: ${res.data.coleweight} (Top &l${res.data.percentile}&b%)`) - .setHoverValue(`&fExperience&f: &a${res.data.exp}\n&fPowder&f: &a${res.data.pow}\n&fCollection&f: &a${res.data.col}\n&fMiscellaneous&f: &a${res.data.bes + res.data.nuc}`) + .setHoverValue(`&fExperience&f: &a${Math.round(res.data.experience.total*100) / 100}\n&fPowder&f: &a${Math.round(res.data.powder.total*100) / 100}\n&fCollection&f: &a${Math.round(res.data.experience.total*100) / 100}\n&fMiscellaneous&f: &a${Math.round(res.data.miscellaneous.total*100) / 100}`) ChatLib.chat(coleweightMessage) - }) + }) .catch(err => { ChatLib.chat(`${PREFIX}&eError. (api may be down)`) }) diff --git a/commands/help.js b/commands/help.js index 8e06b51..f46cc2c 100644 --- a/commands/help.js +++ b/commands/help.js @@ -3,6 +3,7 @@ const PREFIX = "◆" export function help() { ChatLib.chat("&b--------------[ &a&lColeweight &b]--------------") + ChatLib.chat("&7(Hover over command to see usage.)") ChatLib.chat(ChatLib.getCenteredText("&a&lInfo")) helpCommand("", "Gets Coleweight of specified user", "(username)") helpCommand("help", "This menu.", "") @@ -23,11 +24,11 @@ export function help() helpCommand("yog", "Shows instructions for yog waypoints.", "[toggle]") helpCommand("divans", "Guide for setting up waypoints for Mines of Divan treasures.", "[toggle]") ChatLib.chat(ChatLib.getCenteredText("&a&lMiscellaneous")) + helpCommand("drawline", "Draws a line to coords. (y defaults to the player's y)", "(x) [y] (z)") ChatLib.chat(`&a${PREFIX} /fetchdiscord (username) => &bGets discord of username (if linked)`) - ChatLib.chat("&b------------------------------------------") + ChatLib.chat("&b--------------------------------------------") } -// Made by Almighty Stylla <3 export function helpCommand(command, desc, usage) { ChatLib.chat(new TextComponent(`&a${PREFIX} /cw ${command} => &b${desc}`).setHoverValue(`${"/cw " + command + " " + usage}`)) diff --git a/commands/info.js b/commands/info.js index 3967863..ed427f8 100644 --- a/commands/info.js +++ b/commands/info.js @@ -1,23 +1,20 @@ -import axios from "../../axios" import constants from "../util/constants" +import { addCommas } from "../util/helperFunctions" const PREFIX = constants.PREFIX export function info() { - axios.get(`https://ninjune.dev/api/cwinfo`) - .then((res) => { - let values = res.data, - powder = values.powder, - collection = values.collection, - miscellaneous = values.miscellaneous - - ChatLib.chat(`${PREFIX}&bEach of the following are equivalent to one unit of ColeWeight` + - `\n\n&4&lExperience \n&b${values.experience.req} mining exp` + - `\n\n&4&lPowder \n&b${powder[0].req} &bmithril powder\n&b${powder[1].req} gemstone powder` + // in theory I should have just added formatted names to the api - `\n\n&4&lCollections \n&b${collection[0].req} &bmithril\n&b${collection[1].req} gemstone\n&b${collection[2].req} gold\n&b${collection[3].req}netherrack\n&b${collection[4].req} diamond\n&b${collection[5].req} ice\n&b${collection[6].req} redstone\n&b${collection[7].req} lapis\n&b${collection[8].req} sulphur\n&b${collection[9].req} coal\n&b${collection[10].req} emerald\n&b${collection[11].req} endstone\n&b${collection[12].req} glowstone\n&b${collection[13].req} gravel\n&b${collection[14].req} iron\n&b${collection[15].req} mycelium\n&b${collection[16].req} quartz\n&b${collection[17].req} obsidian\n&b${collection[18].req} red sand\n&b${collection[19].req} sand\n&b${collection[20].req} cobblestone\n&b${collection[21].req} hardstone` + - `\n\n&4&lMiscellaneous \n&b${miscellaneous[0].req} scatha kills\n&b${miscellaneous[1].req} worm kills\n&b${miscellaneous[2].req} nucleus runs`) - }) - .catch((e) => { - return `${PREFIX}&cThere was an error. (api may be down)` + let cwinfo = constants.CWINFO, + values = {"experience" : "", "powder": "", "collection": "", "miscellaneous": ""} + + cwinfo.forEach(info => { + values[info.category] += `&b${addCommas(info.cost)} ${info.nameStringed}\n` }) + + ChatLib.chat( + `${PREFIX}&bEach of the following are equivalent to one unit of ColeWeight` + + "\n&4&lExperience\n" + values.experience + + "\n&4&lPowder\n" + values.powder + + "\n&4&lCollections\n" + values.collection + + "\n&4&lMiscellaneous\n" + values.miscellaneous) }
\ No newline at end of file diff --git a/commands/setkey.js b/commands/setkey.js index 530bf28..f4dba64 100644 --- a/commands/setkey.js +++ b/commands/setkey.js @@ -17,6 +17,6 @@ export function setkey(arg2) ChatLib.chat(`${PREFIX}&eKey is not valid!`) }) .catch(err => { - ChatLib.chat(`${PREFIX}&eKey is not valid!`) + ChatLib.chat(`${PREFIX}&eKey is not valid! if this is a mistake report: ${err}`) }) }
\ No newline at end of file |