diff options
-rw-r--r-- | chat/grieferTrack.js | 50 | ||||
-rw-r--r-- | chat/message.js | 35 | ||||
-rw-r--r-- | chat/updater.js (renamed from util/updater.js) | 2 | ||||
-rw-r--r-- | commands/claim.js | 14 | ||||
-rw-r--r-- | commands/divans.js | 2 | ||||
-rw-r--r-- | commands/spiral.js | 4 | ||||
-rw-r--r-- | commands/throne.js | 7 | ||||
-rw-r--r-- | commands/yog.js | 5 | ||||
-rw-r--r-- | index.js | 148 | ||||
-rw-r--r-- | metadata.json | 2 | ||||
-rw-r--r-- | render/coordsGui.js | 18 | ||||
-rw-r--r-- | render/cwGui.js | 159 | ||||
-rw-r--r-- | render/downtimeGui.js | 31 | ||||
-rw-r--r-- | render/naturals.js | 15 | ||||
-rw-r--r-- | util/constants.js | 8 | ||||
-rw-r--r-- | util/grieferTrack.js | 47 | ||||
-rw-r--r-- | util/helperFunctions.js | 49 | ||||
-rw-r--r-- | util/waypoints.js | 7 |
18 files changed, 328 insertions, 275 deletions
diff --git a/chat/grieferTrack.js b/chat/grieferTrack.js new file mode 100644 index 0000000..468428a --- /dev/null +++ b/chat/grieferTrack.js @@ -0,0 +1,50 @@ +import axios from "../../axios" +import settings from "../settings" +import Settings from "../settings" +import constants from "../util/constants" +const PREFIX = constants.PREFIX +let players = [] // global variable moment + + +register("step", () => { + let date_ob = new Date(), + seconds = date_ob.getSeconds() + + if(seconds == 0 || seconds == 15 || seconds == 30 || seconds == 45) + checkMMiners() +}).setFps(1) + + +register("worldLoad", () => { + players = [] + checkMMiners() +}) + + +function checkMMiners() +{ + if (!Settings.trackGriefers) return + try + { + const NetHandlerPlayClient = Client.getConnection(), + PlayerMap = NetHandlerPlayClient.func_175106_d() // getPlayerInfoMap + + PlayerMap.filter(player => player.func_178853_c() > 0 && !player.func_178845_a().name.startsWith("!")).forEach((PlayerMP) => { + let player = PlayerMP.func_178845_a().name + + if(players.indexOf(player) == -1) + { + axios.get(`https://ninjune.dev/api/mminers?username=${player}`) + .then(res => { + if(res.data.found == true && res.data.type == "griefer") + ChatLib.chat(`${PREFIX}&e'${res.data.name}' is a griefer!`) + }) + players.push(player) + } + }) + } catch(err) { if(settings.debug) console.log("grieferTrack trycatch: " + err) } + + return players +} + +export default ""
\ No newline at end of file diff --git a/chat/message.js b/chat/message.js index 79b6be1..180e90b 100644 --- a/chat/message.js +++ b/chat/message.js @@ -40,6 +40,17 @@ register("chat", (level, typeOfChat, hypixelRank, username, playerMessage, event ChatLib.chat(newMessage) }).setCriteria(/^(\[\d+\] )?((?:(?:Guild|Party|Co-op) > )|(?:\[:v:\] ))?(\[\w+\+{0,2}\] )?(\w{1,16})(?: \[\w{1,6}\])?: (.*)$/g) +register("worldLoad", () => { + axios.get(`https://ninjune.dev/api/coleweight-leaderboard?length=500`) + .then(res => { + cwlbData = res.data + }) + .catch(err => { + ChatLib.chat(err) + }) +}) + + register("messageSent", (origMessage, event) => { // emotes! this was fun to make :) let commandState = 0, command = "", @@ -75,14 +86,20 @@ register("messageSent", (origMessage, event) => { // emotes! this was fun to mak ChatLib.say(`${message}`) }) -register("worldLoad", () => { - axios.get(`https://ninjune.dev/api/coleweight-leaderboard?length=500`) - .then(res => { - cwlbData = res.data - }) - .catch(err => { - ChatLib.chat(err) - }) -}) + +// first time check +register("step", () => { + if (constants.data.first_time) + { + constants.data.first_time = false + constants.data.save() + ChatLib.chat("") + new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bPlease Set Your Api Key By Doing /api new`)).chat() + new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bOr By Doing /cw setkey (key)`)).chat() + new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bView commands: /cw help`)).chat() + ChatLib.chat("") + } + if (constants.data.api_key == undefined || constants.data.api_key == "") return +}).setFps(1); export default ""
\ No newline at end of file diff --git a/util/updater.js b/chat/updater.js index ea8fa2c..c936e80 100644 --- a/util/updater.js +++ b/chat/updater.js @@ -1,5 +1,5 @@ import axios from "../../axios" -import constants from "./constants" +import constants from "../util/constants" const PREFIX = constants.PREFIX, VERSION = constants.VERSION diff --git a/commands/claim.js b/commands/claim.js index ae20924..52cb5f8 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -27,15 +27,21 @@ export function claim(structure) axios.get(`https://ninjune.dev/api/claim?type=${structure}&lobby=${constants.serverData.server}&username=${Player.getName()}&serverID=${serverId}`) .then(res => { if(res.data.success) + { ChatLib.chat(`${PREFIX}&aSuccessfully claimed ${constants.serverData.server} as your server!`) + return + } else { - ChatLib.chat(`${PREFIX}&cError: ${res.data.reason}.`) + if(res.data.code == 501) { ChatLib.chat(`${PREFIX}&cError: Not logged into the auth server. Try running the command again.`) Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) + return } + else + ChatLib.chat(`${PREFIX}&cError: ${res.data.reason}.`) } }) .catch(err => { @@ -45,7 +51,11 @@ export function claim(structure) } 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) + try + { + 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) {} }) register('worldLoad', () => { diff --git a/commands/divans.js b/commands/divans.js index b1ee97c..c5e618a 100644 --- a/commands/divans.js +++ b/commands/divans.js @@ -1,5 +1,5 @@ import constants from "../util/constants" -import { waypointRender } from "../util/waypoints" +import { waypointRender } from "../util/helperFunctions" const PREFIX = constants.PREFIX let divanWaypoints = [] diff --git a/commands/spiral.js b/commands/spiral.js index e25bbb5..6574f18 100644 --- a/commands/spiral.js +++ b/commands/spiral.js @@ -1,5 +1,5 @@ import constants from "../util/constants" -import { waypointRender } from "../util/waypoints" +import { waypointRender } from "../util/helperFunctions" const PREFIX = constants.PREFIX let spiralWaypoints = [] @@ -45,7 +45,7 @@ export function spiral(arg2) } register("renderWorld", () => { - waypointRender(spiralWaypoints) + waypointRender(spiralWaypoints, true) }) register("worldLoad", () => { diff --git a/commands/throne.js b/commands/throne.js index cab7779..517c93d 100644 --- a/commands/throne.js +++ b/commands/throne.js @@ -1,9 +1,10 @@ import constants from "../util/constants" -import { waypointRender } from "../util/waypoints" +import { waypointRender } from "../util/helperFunctions" const PREFIX = constants.PREFIX let throneWaypoints = [] + export function throne(arg2) { if(arg2 != "toggle") @@ -38,10 +39,12 @@ export function throne(arg2) } } + register("renderWorld", () => { - waypointRender(throneWaypoints) + waypointRender(throneWaypoints, true) }) + register("worldLoad", () => { throneWaypoints = [] }) diff --git a/commands/yog.js b/commands/yog.js index 9758321..1544553 100644 --- a/commands/yog.js +++ b/commands/yog.js @@ -1,4 +1,5 @@ import constants from "../util/constants" +import { waypointRender } from "../util/helperFunctions" const PREFIX = constants.PREFIX let yogWaypoints = [] @@ -51,9 +52,7 @@ export function yog(arg2) register("renderWorld", () => { if(yogWaypoints.length < 1) return - yogWaypoints.forEach((waypoint) => { - 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]) - }) + waypointRender(yogWaypoints) }) register("worldLoad", () => { @@ -5,149 +5,5 @@ import './chat/apiNew' import './chat/message' import './chat/serverdata' import './commandManager' -import './util/updater' -import './util/grieferTrack' -import axios from '../axios' -import constants from './util/constants'; -const PREFIX = constants.PREFIX - -//update every second (dogshit code) -register("step", () => { - // first time check - if (constants.data.first_time) - { - constants.data.first_time = false - constants.data.save() - ChatLib.chat("") - new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bPlease Set Your Api Key By Doing /api new`)).chat() - new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bOr By Doing /cw setkey (key)`)).chat() - new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bView commands: /cw help`)).chat() - ChatLib.chat("") - } - if (constants.data.api_key == undefined || constants.data.api_key == "") return - - // updates coleweight for gui - let date_ob = new Date(), - seconds = date_ob.getSeconds() - - if(constants.upTimeTrack == true) - constants.uptime += 1 - if(seconds == 0 || seconds == 15 || seconds == 30 || seconds == 45) - { - try - { - let tempUuid = Player.getUUID(), - profileData = "", - coleweight = 0, - uuid = "" - - for(let i = 0; i < tempUuid.length; i++) - { - if(tempUuid[i] != "-") - { - uuid = uuid + tempUuid[i] - } - } - axios.get(`https://ninjune.dev/api/cwinfo`) - .then(cwInfoRes => { - axios.get(`https://api.hypixel.net/skyblock/profiles?key=${constants.data.api_key}&uuid=${uuid}`) - .then(res => { - let eq = 0, - cwInfo = cwInfoRes.data - - for(let i=0; i < res.data.profiles.length; i+=1) - { - if(res.data.profiles[i].selected == true) - profileData = res.data.profiles[i] - } - - coleweight += Math.ceil((profileData.members[uuid][cwInfo.experience.name]/cwInfo.experience.req)*100) / 100 - - for(let i = 0; i < cwInfo.powder.length; i++) - { - let sourceToSearch = cwInfo.powder[i].name, - source = profileData.members[uuid].mining_core[sourceToSearch] - - if(source != undefined) - { - eq = Math.ceil(source/cwInfo.powder[i].req*100) / 100 - - if(i == 0) - { - let powder2 = profileData.members[uuid].mining_core['powder_spent_mithril'] - - if(powder2 != undefined) - eq = Math.ceil((source+powder2)/cwInfo.powder[i].req*100) / 100 - } - else - { - let powder2 = profileData.members[uuid].mining_core['powder_spent_gemstone'] - - if(powder2 != undefined) - eq = Math.ceil((source+powder2)/cwInfo.powder[i].req*100) / 100 - } - coleweight += eq - } - } - - for(let i = 0; i < cwInfo.collection.length; i++) - { - let sourceToSearch = cwInfo.collection[i].name, - source = profileData.members[uuid].collection[sourceToSearch] - - if(source != undefined) - { - eq = Math.ceil(source/cwInfo.collection[i].req*100) / 100 - coleweight += eq - } - } - - for(let i = 0; i < cwInfo.miscellaneous.length; i++) - { - let sourceToSearch = cwInfo.miscellaneous[i].name - if(i == 0 || i == 1) - source = profileData.members[uuid].bestiary[sourceToSearch] - else - source = profileData.members[uuid].mining_core.crystals.jade_crystal[sourceToSearch] - if (source != undefined) - { - eq = Math.ceil(source/cwInfo.miscellaneous[i].req*100) / 100 - coleweight += eq - } - } - - if(constants.baseColeweight == 0) - { - constants.baseColeweight = coleweight - } - else if((coleweight - constants.baseColeweight) > 0) - { - constants.cwValues.push(coleweight - constants.baseColeweight) - constants.calcCwPerHr = true - constants.upTimeTrack = true - constants.stepsSinceLast = 0 - constants.baseColeweight = coleweight - } - else if(constants.stepsSinceLast > 20) - { - constants.upTimeTrack = false - constants.stepsSinceLast = 0 - constants.cwValues = [] - } - else - { - constants.stepsSinceLast += 1 - } - - constants.data.coleweight = Math.ceil(coleweight*100)/100 - constants.data.save() - }) - .catch(err => {ChatLib.chat(e)}) - }) - } - catch(e) - { - ChatLib.chat(e) - } - } -}).setFps(1);
\ No newline at end of file +import './chat/updater' +import './chat/grieferTrack'
\ No newline at end of file diff --git a/metadata.json b/metadata.json index d2ac698..bf79237 100644 --- a/metadata.json +++ b/metadata.json @@ -3,6 +3,6 @@ "creator": "Ninjune", "entry": "index.js", "description": "Mining utilities.", - "version": "1.6.8", + "version": "1.6.10", "requires": ["axios", "PogData", "Vigilance", "Elementa"] }
\ No newline at end of file diff --git a/render/coordsGui.js b/render/coordsGui.js index f36ccf2..9fd5f43 100644 --- a/render/coordsGui.js +++ b/render/coordsGui.js @@ -20,18 +20,20 @@ import { } from "../../Elementa" // stylla made 2 lines of code (gamer) -const Color = Java.type("java.awt.Color") -const URL = Java.type("java.net.URL") +const Color = Java.type("java.awt.Color"), + URL = Java.type("java.net.URL"), + WIDTH = 3.5, // not actually width more like reverse of width lmao, bigger = smaller + HEIGHT = 2.877 // ^ let ScreenW = Renderer.screen.getWidth(), ScreenH = Renderer.screen.getHeight() function coordsWindow(row, column, title, command, desc, image=false, alternateText="") { const coordWindow = new UIBlock(new Color(0, 0, 0, 0.5)) // 320 960 - .setX(((ScreenW/3*(column))-ScreenW/3.5).pixels()) + .setX(((ScreenW/3*(column))-ScreenW/3.25).pixels()) .setY((ScreenH/2*(row-1)+ScreenH/10.8).pixels()) - .setWidth((ScreenW/4.5).pixels()) - .setHeight((ScreenH/3.7).pixels()) + .setWidth((ScreenW/WIDTH).pixels()) + .setHeight((ScreenH/HEIGHT).pixels()) .onMouseClick(() => { ChatLib.command(command, true) }) @@ -53,8 +55,8 @@ function coordsWindow(row, column, title, command, desc, image=false, alternateT new UIImage.ofURL(new URL(desc)) .setX(new CenterConstraint()) .setY(new AdditiveConstraint(new CenterConstraint(), (4).pixels())) - .setWidth((ScreenW/5).pixels()) - .setHeight((ScreenH/5).pixels()) + .setWidth((ScreenW/3.7).pixels()) + .setHeight((ScreenH/3.7).pixels()) .setChildOf(coordWindow) } else @@ -62,7 +64,7 @@ function coordsWindow(row, column, title, command, desc, image=false, alternateT new UIWrappedText(desc) .setX((2).pixels()) .setY((25).pixels()) - .setWidth((ScreenW/4.5).pixels()) + .setWidth((ScreenW/3.7).pixels()) .setTextScale((1).pixels()) .setColor(new ConstantColorConstraint(Color.WHITE)) .setChildOf(coordWindow) diff --git a/render/cwGui.js b/render/cwGui.js index 96c0bf6..4e0f660 100644 --- a/render/cwGui.js +++ b/render/cwGui.js @@ -1,9 +1,19 @@ import settings from "../settings"; import constants from "../util/constants"; - +import axios from "../../axios" const cwGui = new Gui() let txt = "Please set your api key with /cw setkey (key)!" +let cwValues = [], + calcCwPerHr = false, + upTimeTrack = false, + uptime = 0, + baseColeweight = 0, + stepsSinceLast = 0, + coleweightHr = 0, + cwValuesSum = 0 + + export function openCwGui() { cwGui.open() @@ -30,25 +40,148 @@ register("renderOverlay", () => { if(!settings.cwToggle || constants.data.api_key == undefined) return let coleweight = constants.data.coleweight || 0, coleweightMessage = "", - uptimeHr = Math.floor(constants.uptime/60/60) + uptimeHr = Math.floor(uptime/60/60) coleweight > 1000 ?coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`: coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}` - if(constants.cwValues[0] != undefined && constants.upTimeTrack && constants.calcCwPerHr) + if(cwValues[0] != undefined && upTimeTrack && calcCwPerHr) { - constants.cwValuesSum = 0 - for(let i = 0; i < constants.cwValues.length; i++) + cwValuesSum = 0 + for(let i = 0; i < cwValues.length; i++) { - constants.cwValuesSum += constants.cwValues[i] + cwValuesSum += cwValues[i] } - let eq = Math.ceil((constants.cwValuesSum*(3600/constants.uptime)) * 100) / 100 - eq != Infinity ? constants.coleweightHr = eq : constants.coleweightHr = "Calculating..." - constants.calcCwPerHr = false + let eq = Math.ceil((cwValuesSum*(3600/uptime)) * 100) / 100 + eq != Infinity ? coleweightHr = eq : coleweightHr = "Calculating..." + calcCwPerHr = false } - if (cwGui.isOpen() || !constants.upTimeTrack) return + if (cwGui.isOpen() || !upTimeTrack) return if(uptimeHr >= 1) - Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${constants.coleweightHr}\n&aUptime: &b${uptimeHr}h ${Math.floor(constants.uptime/60) - uptimeHr*60}m\n&aColeweight Gained: &b${Math.ceil(constants.cwValuesSum*100) / 100}`, constants.data.x, constants.data.y) + Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${coleweightHr}\n&aUptime: &b${uptimeHr}h ${Math.floor(uptime/60) - uptimeHr*60}m\n&aColeweight Gained: &b${Math.ceil(cwValuesSum*100) / 100}`, data.x, data.y) else - Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${constants.coleweightHr}\n&aUptime: &b${Math.floor(constants.uptime/60)}m ${Math.floor(constants.uptime%60)}s\n&aColeweight Gained: &b${Math.ceil(constants.cwValuesSum*100) / 100}`, constants.data.x, constants.data.y) -})
\ No newline at end of file + Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${coleweightHr}\n&aUptime: &b${Math.floor(uptime/60)}m ${Math.floor(uptime%60)}s\n&aColeweight Gained: &b${Math.ceil(cwValuesSum*100) / 100}`, data.x, data.y) +}) + + + +register("step", () => { + // updates coleweight for gui + let date_ob = new Date(), + seconds = date_ob.getSeconds() + + if(upTimeTrack == true) + uptime += 1 + if(seconds == 0 || seconds == 15 || seconds == 30 || seconds == 45) + { + try + { + let tempUuid = Player.getUUID(), + profileData = "", + coleweight = 0, + uuid = "" + + for(let i = 0; i < tempUuid.length; i++) + { + if(tempUuid[i] != "-") + { + uuid = uuid + tempUuid[i] + } + } + axios.get(`https://ninjune.dev/api/cwinfo`) + .then(cwInfoRes => { + axios.get(`https://api.hypixel.net/skyblock/profiles?key=${constants.data.api_key}&uuid=${uuid}`) + .then(res => { + let eq = 0, + cwInfo = cwInfoRes.data + + for(let i=0; i < res.data.profiles.length; i+=1) + { + if(res.data.profiles[i].selected == true) + profileData = res.data.profiles[i] + } + + coleweight += Math.ceil((profileData.members[uuid][cwInfo.experience.name]/cwInfo.experience.req)*100) / 100 + + for(let i = 0; i < cwInfo.powder.length; i++) + { + let sourceToSearch = cwInfo.powder[i].name, + source = profileData.members[uuid].mining_core[sourceToSearch] + + if(source != undefined) + { + eq = Math.ceil(source/cwInfo.powder[i].req*100) / 100 + + if(i == 0) + { + let powder2 = profileData.members[uuid].mining_core['powder_spent_mithril'] + + if(powder2 != undefined) + eq = Math.ceil((source+powder2)/cwInfo.powder[i].req*100) / 100 + } + else + { + let powder2 = profileData.members[uuid].mining_core['powder_spent_gemstone'] + + if(powder2 != undefined) + eq = Math.ceil((source+powder2)/cwInfo.powder[i].req*100) / 100 + } + coleweight += eq + } + } + + for(let i = 0; i < cwInfo.collection.length; i++) + { + let sourceToSearch = cwInfo.collection[i].name, + source = profileData.members[uuid].collection[sourceToSearch] + + if(source != undefined) + { + eq = Math.ceil(source/cwInfo.collection[i].req*100) / 100 + coleweight += eq + } + } + for(let i = 0; i < cwInfo.miscellaneous.length; i++) + { + let sourceToSearch = cwInfo.miscellaneous[i].name + if(i == 0 || i == 1) + source = profileData.members[uuid].bestiary[sourceToSearch] + else + source = profileData.members[uuid].mining_core.crystals.jade_crystal[sourceToSearch] + if (source != undefined) + { + eq = Math.ceil(source/cwInfo.miscellaneous[i].req*100) / 100 + coleweight += eq + } + } + if(baseColeweight == 0) + { + baseColeweight = coleweight + } + else if((coleweight - baseColeweight) > 0) + { + cwValues.push(coleweight - baseColeweight) + calcCwPerHr = true + upTimeTrack = true + stepsSinceLast = 0 + baseColeweight = coleweight + } + else if(stepsSinceLast > 20) + { + upTimeTrack = false + stepsSinceLast = 0 + cwValues = [] + } + else + { + stepsSinceLast += 1 + } + + data.coleweight = Math.ceil(coleweight*100)/100 + data.save() + }) + }) + } + catch(e) {} + } +}).setFps(1)
\ No newline at end of file diff --git a/render/downtimeGui.js b/render/downtimeGui.js index 149718c..538c590 100644 --- a/render/downtimeGui.js +++ b/render/downtimeGui.js @@ -1,8 +1,9 @@ import settings from "../settings" -import { createGui } from "./textGuiCreator" import constants from "../util/constants" +import { textGui } from "../util/helperFunctions" -const downtimeGui = new Gui() +const downtimeMoveGui = new Gui() +const downtimeGui = new textGui() let oldFuel = 0, timeAtLastFuel = 0, overallDowntime = 0, @@ -14,12 +15,12 @@ let oldFuel = 0, export function openDowntimeGui() { - downtimeGui.open() + downtimeMoveGui.open() } register("dragged", (dx, dy, x, y) => { - if (!downtimeGui.isOpen()) return + if (!downtimeMoveGui.isOpen()) return constants.downtimedata.x = x constants.downtimedata.y = y constants.downtimedata.save() @@ -51,24 +52,22 @@ register('actionbar', (xp) => { register("renderOverlay", () => { - if (downtimeGui.isOpen()) + if (downtimeMoveGui.isOpen()) { let txt = "Drag to move." Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2) - createGui( - {leftValues: ["Downtime", "Overall Downtime", "Average Downtime", "Uptime"], rightValues: [0, 0, 0, 0]}, - constants.downtimedata.x, - constants.downtimedata.y - ) + 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.renderGui() return } - if (downtimeCount == 0 || !trackingDowntime) return + if (downtimeCount == 0 || !trackingDowntime || !settings.downtimeTracker) return let avgDowntime = Math.ceil((overallDowntime/downtimeCount)*100) / 100 - createGui( - {leftValues: ["Downtime", "Overall Downtime", "Average Downtime", "Uptime"], rightValues: [downtime, overallDowntime, avgDowntime, uptime]}, - constants.downtimedata.x, - constants.downtimedata.y - ) + 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.renderGui() }) diff --git a/render/naturals.js b/render/naturals.js index d0443a3..595c32d 100644 --- a/render/naturals.js +++ b/render/naturals.js @@ -1,9 +1,11 @@ import axios from "../../axios" import settings from "../settings" import constants from "../util/constants" +import { waypointRender } from "../util/helperFunctions" const PREFIX = constants.PREFIX let coords = [] + register("step", () => { if(constants.serverData.map != "Crystal Hollows") return axios.get(`https://ninjune.dev/api/coords`) @@ -14,7 +16,7 @@ register("step", () => { && ((-1 * settings.naturalRange)/2 < (parseInt(Player.getY()) - coord.y)) && ((parseInt(Player.getY()) - coord.y) < settings.naturalRange/2) && ((-1 * settings.naturalRange)/2 < (parseInt(Player.getZ()) - coord.z)) && ((parseInt(Player.getZ()) - coord.z) < settings.naturalRange/2)) ).forEach(coord => { - coords.push({x: coord.x, y: coord.y, z: coord.z}) + coords.push([coord.x, coord.y, coord.z]) }) }) .catch((err) => { @@ -22,13 +24,16 @@ register("step", () => { }) }).setFps(1) + register("renderWorld", () => { if(!settings.showNaturals) return if(coords.length < 1) return - coords - .forEach((coord) => { - Tessellator.drawString(Math.floor((Math.abs(parseInt(Player.getX()) - coord.x) + Math.abs(parseInt(Player.getY()) - coord.y) + Math.abs(parseInt(Player.getZ()) - coord.z))/3) + "m", coord.x, coord.y, coord.z) - }) + waypointRender(coords) }) +register("worldUnload", () => { + coords = [] +}) + + export default ""
\ No newline at end of file diff --git a/util/constants.js b/util/constants.js index 51345fe..95664dd 100644 --- a/util/constants.js +++ b/util/constants.js @@ -35,16 +35,8 @@ export default powderdata: PowderData, timerdata: TimerData, downtimedata: DowntimeData, - cwValues: [], - calcCwPerHr: false, - upTimeTrack: false, - uptime: 0, - baseColeweight: 0, - stepsSinceLast: 0, throneValues: [], spiralValues: [], - coleweightHr: 0, - cwValuesSum: 0, beta: false, serverData: {} }
\ No newline at end of file diff --git a/util/grieferTrack.js b/util/grieferTrack.js deleted file mode 100644 index a21653b..0000000 --- a/util/grieferTrack.js +++ /dev/null @@ -1,47 +0,0 @@ -import axios from "../../axios" -import Settings from "../settings" -import constants from "./constants" -const PREFIX = constants.PREFIX -let players = [] // global variable moment - - -function checkMMiners() -{ - if (!Settings.trackGriefers) return - const NetHandlerPlayClient = Client.getConnection(), - PlayerMap = NetHandlerPlayClient.func_175106_d() // getPlayerInfoMap - - PlayerMap.filter(player => player.func_178853_c() > 0 && !player.func_178845_a().name.startsWith("!")).forEach((PlayerMP) => { - let player = PlayerMP.func_178845_a().name - - if(players.indexOf(player) == -1) - { - axios.get(`https://ninjune.dev/api/mminers?username=${player}`) - .then(res => { - if(res.data.found == true && res.data.type == "griefer") - ChatLib.chat(`${PREFIX}&e'${res.data.name}' is a griefer!`) - }) - players.push(player) - } - }) - - return players -} - - -register("step", () => { - let date_ob = new Date(), - seconds = date_ob.getSeconds() - - if(seconds == 0 || seconds == 15 || seconds == 30 || seconds == 45) - checkMMiners() -}).setFps(1) - - -register("worldLoad", () => { - players = [] - checkMMiners() -}) - - -export default ""
\ No newline at end of file diff --git a/util/helperFunctions.js b/util/helperFunctions.js index 2bea5d0..7a3927d 100644 --- a/util/helperFunctions.js +++ b/util/helperFunctions.js @@ -1,10 +1,51 @@ -/* -Created 11/11/2022 by Ninjune. -*/ export function addCommas(num) { try { return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } catch (error) { return 0; } -}// credit to senither for the regex, just don't care to make my own lol
\ No newline at end of file +}// credit to senither for the regex, just don't care to make my own lol + + +export function waypointRender(waypoints, yellow=false) +{ + 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) + 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]) + }) +} + + +export class textGui // first class I've made, gonna be dog +// guiObject format: { leftValues: [], rightValues: [] } (must have same amount of each or error). +{ + constructor(guiObject, x, y) + { + this.guiObject = guiObject + this.x = x + this.y = y + } + + + renderGui() + { + let string = "" + this.guiObject.leftValues.forEach((leftValue, index) => { + if(leftValue == "Uptime") + { + let uptime = this.guiObject.rightValues[index], + uptimeHr = Math.floor(uptime/60/60) + + if(uptimeHr >= 1) + string += `&aUptime: &b${uptimeHr}h ${Math.floor(uptime/60) - uptimeHr*60}m\n` + else + 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) } +}
\ No newline at end of file diff --git a/util/waypoints.js b/util/waypoints.js deleted file mode 100644 index eb7dad8..0000000 --- a/util/waypoints.js +++ /dev/null @@ -1,7 +0,0 @@ -export function waypointRender(waypoints) -{ - if(waypoints.length < 1) return - waypoints.forEach((waypoint) => { - 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]) - }) -}
\ No newline at end of file |