diff options
author | Ninjune <enderknight537@gmail.com> | 2022-11-23 11:50:54 -0600 |
---|---|---|
committer | Ninjune <enderknight537@gmail.com> | 2022-11-23 11:50:54 -0600 |
commit | 9bb7bf0b2f4dbc9269b0e5fa446d8480b814fe20 (patch) | |
tree | 56837d423243990da63152d0e9c119189f1d121b | |
parent | 5e76b8b00ac668768f5295ac4b2cb7c79c71ee36 (diff) | |
download | coleweight-9bb7bf0b2f4dbc9269b0e5fa446d8480b814fe20.tar.gz coleweight-9bb7bf0b2f4dbc9269b0e5fa446d8480b814fe20.tar.bz2 coleweight-9bb7bf0b2f4dbc9269b0e5fa446d8480b814fe20.zip |
v1.6.4 forgot to push lmao
-rw-r--r-- | chat/message.js | 4 | ||||
-rw-r--r-- | commandManager.js | 22 | ||||
-rw-r--r-- | commands/claim.js | 47 | ||||
-rw-r--r-- | commands/help.js | 1 | ||||
-rw-r--r-- | commands/markingLobbies.js | 17 | ||||
-rw-r--r-- | commands/yog.js | 63 | ||||
-rw-r--r-- | index.js | 6 | ||||
-rw-r--r-- | metadata.json | 2 | ||||
-rw-r--r-- | render/bobombOverlay.js | 22 | ||||
-rw-r--r-- | render/naturals.js | 34 | ||||
-rw-r--r-- | settings.js | 69 | ||||
-rw-r--r-- | util/grieferTrack.js | 9 |
12 files changed, 237 insertions, 59 deletions
diff --git a/chat/message.js b/chat/message.js index 5a146b8..c7cfe9f 100644 --- a/chat/message.js +++ b/chat/message.js @@ -6,7 +6,7 @@ import settings from "../settings" import constants from "../util/constants" import { addCommas } from "../util/helperFunctions" const PREFIX = constants.PREFIX -let cwlbData = {}, +let cwlbData = [], newMessage, message, messagePrefix, cwlbPlayerData, onward register("chat", (level, typeOfChat, hypixelRank, username, playerMessage, event) => { // CW Rank @@ -22,10 +22,10 @@ register("chat", (level, typeOfChat, hypixelRank, username, playerMessage, event if(!onward || cwlbData == undefined) return cwlbPlayerData = cwlbData.filter(player => player.name == username)[0] if(cwlbPlayerData == undefined) return - cancel(event) newMessage = new Message() message = ChatLib.getChatMessage(event, true), messagePrefix = message + cancel(event) if(cwlbPlayerData.rank > 0 && cwlbPlayerData.rank < 501) messagePrefix = message.slice(0, message.indexOf(':')) + ` &8[&6#${addCommas(cwlbPlayerData.rank)}&8]&f: ` diff --git a/commandManager.js b/commandManager.js index 66b05e3..0985e28 100644 --- a/commandManager.js +++ b/commandManager.js @@ -1,12 +1,13 @@ import { openTimerGui } from "./render/timerGui.js" import { openPowderGui } from "./render/powertrackerGui" import { openCwGui } from "./render/cwGui" -import { help } from "./commands/help.js" -import { reload } from "./commands/reload.js" -import { setkey } from "./commands/setkey.js" -import { spiral } from "./commands/spiral.js" -import { throne } from "./commands/throne.js" -import { leaderboard } from "./commands/leaderboard.js" +import { help } from "./commands/help" +import { reload } from "./commands/reload" +import { setkey } from "./commands/setkey" +import { spiral } from "./commands/spiral" +import { throne } from "./commands/throne" +import { yog } from "./commands/yog" +import { leaderboard } from "./commands/leaderboard" import { update } from "./commands/update" import { fetchDiscord } from "./commands/fetchDiscord" import { findColeweight } from "./commands/findColeweight" @@ -16,6 +17,7 @@ import { time } from "./commands/time" import { info } from "./commands/info" import Settings from "./settings" import constants from "./util/constants" +import { clearLobbies } from "./commands/markingLobbies" register("command", (arg, arg2, arg3) => { if (arg == undefined) {findColeweight(arg); return} @@ -79,12 +81,18 @@ register("command", (arg, arg2, arg3) => { case "info": info() break + case "clearlobbies": + clearLobbies() + break + case "yog": + yog(arg2) + break default: findColeweight(arg) } }).setTabCompletions((args) => { let output = [], - commands = ["setkey", "help", "move", "toggle", "throne", "spiral", "reload", "leaderboard", "settings", "claim", "tick", "time", "info"] + commands = ["setkey", "help", "move", "toggle", "throne", "spiral", "reload", "leaderboard", "settings", "claim", "tick", "time", "info", "clearlobbies", "yog"] if(args[0].length == 0 || args[0] == undefined) output = commands diff --git a/commands/claim.js b/commands/claim.js index cb691f3..5abeda8 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -2,7 +2,7 @@ import axios from "../../axios" import settings from "../settings" import constants from "../util/constants" const PREFIX = constants.PREFIX - +const serverId = java.util.UUID.randomUUID().toString().replace("-", "") export function claim(structure) { @@ -23,33 +23,59 @@ export function claim(structure) ChatLib.chat(`${PREFIX}&cPlease enter the structure you wish to claim! (&3throne&c or &3spiral&c)`) return } - - axios.get(`https://ninjune.dev/api/claim?type=${structure}&id=${constants.serverData.server}&key=${constants.data.api_key}`) + + axios.get(`https://ninjune.dev/api/claim?type=${structure}&lobby=${constants.serverData.server}&method=auth&username=${Player.getName()}&serverID=${serverId}`) .then(res => { if(res.data.success) ChatLib.chat(`${PREFIX}&aSuccessfully claimed ${constants.serverData.server} as your server!`) else - ChatLib.chat(`${PREFIX}&cError: ${res.data.reason}`) + { + 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) + } + } }) .catch(err => { ChatLib.chat(`${PREFIX}&cError: ${err}`) }) - // key is used above to verify that the player trying to claim the lobby is the intended player, don't know a better way of doing this. + } +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) +}) register('worldLoad', () => { if(!settings.claiming) return + axios.get(`https://ninjune.dev/api/unclaim?method=auth&username=${Player.getName()}&serverID=${serverId}`) + .then(res => { + if(settings.debug && !res.data.success) + ChatLib.chat("Unclaim: " + res.data.reason) + if(res.data.code == 501) + Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) + }) + .catch(err => { + if(settings.debug) + ChatLib.chat(`${PREFIX}&cError: ${err}`) + }) + // unclaims the lobby, isn't needed but will allow another player to claim lobby after claimer leaves. setTimeout(() => { + const NetHandlerPlayClient = Client.getConnection(), + PlayerMap = NetHandlerPlayClient.func_175106_d() // getPlayerInfoMap + if(settings.debug) console.log(constants.serverData.server) axios.get(`https://ninjune.dev/api/claim?claimedlobby=${constants.serverData.server}`) .then(res => { if(res.data.claimed) { - ChatLib.chat("here") - World.getAllPlayers().forEach((player) => { + PlayerMap.filter(player => player.func_178853_c() /* getResponseTime */ > 0 && !player.func_178845_a()/* getGameProfile */.name.startsWith("!")).forEach((PlayerMP) => { + let player = PlayerMP.func_178845_a()/* getGameProfile */.name + res.data.structures.forEach((structure) => { - if (player.getName() == structure.player) + if (player == structure.player) ChatLib.chat(`${PREFIX}&cThe ${structure.structure} in ${structure.server} is claimed by ${structure.player}.`) //holy im so good at naming things, structure.structure I must be a genius. }) @@ -61,9 +87,4 @@ register('worldLoad', () => { ChatLib.chat(`${PREFIX}&cError: ${err}`) }) }, 2000) -}) - -register('worldUnload', () => { - axios.get(`https://ninjune.dev/api/unclaim?claimedlobby=${constants.serverData.server}&key=${constants.data.api_key}`) - // unclaims the lobby, isn't needed but will allow another player to claim lobby after claimer leaves. key used to verify identity of unclaimer. })
\ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 3c20b01..1157c65 100644 --- a/commands/help.js +++ b/commands/help.js @@ -15,6 +15,7 @@ export function help() ChatLib.chat(`${PREFIX}&b/cw reload => Reloads the gui.`) ChatLib.chat(`${PREFIX}&b/cw throne => Guide for setting up waypoints for throne.`) ChatLib.chat(`${PREFIX}&b/cw spiral => Guide for setting up waypoints for spiral.`) + ChatLib.chat(`${PREFIX}&b/cw yog => Guide for setting up waypoints for yogs.`) ChatLib.chat(`${PREFIX}&b/cw leaderboard => Gets leaderboard within a specific range (like 20 40)`) ChatLib.chat(`${PREFIX}&b/fetchdiscord (username) => Gets discord of username (if linked)`) ChatLib.chat("") diff --git a/commands/markingLobbies.js b/commands/markingLobbies.js new file mode 100644 index 0000000..6db976e --- /dev/null +++ b/commands/markingLobbies.js @@ -0,0 +1,17 @@ +import settings from "../settings" +import constants from "../util/constants" +const PREFIX = constants.PREFIX +let lobbies = [] + +export function clearLobbies() +{ + lobbies = [] +} + +register('chat', (server) => { + if(!settings.lobbyMarking) return + if(lobbies.indexOf(server) > 0) + ChatLib.chat(`${PREFIX}&aYou've been in this lobby!`) + else + lobbies.push(server) +}).setCriteria(/Sending to server ([A-Za-z0-9]+)\.\.\./g)
\ No newline at end of file diff --git a/commands/yog.js b/commands/yog.js new file mode 100644 index 0000000..15a3d9b --- /dev/null +++ b/commands/yog.js @@ -0,0 +1,63 @@ +import constants from "../util/constants" + +const PREFIX = constants.PREFIX +let yogWaypoints = [] + +export function yog(arg2) +{ + const WAYPOINTNAME = "Yog" + + if(arg2 != "toggle") + { + new TextComponent(`${PREFIX}&bGo to the leftmost corner of the topaz crystal facing bal close to bal then do /cw yog toggle.`) + .chat() + } + else + { + if(yogWaypoints[0] == undefined) + { + let startPos = [Player.getX(), Player.getY(), Player.getZ()], + x = startPos[0], + y = startPos[1], + z = startPos[2] + + console.log(x + " " + y + " " + z) + yogWaypoints.push([x + 10, y - 7, z - 27]) + yogWaypoints.push([x + 10, y - 7, z - 27]) + yogWaypoints.push([x + 28, y - 8, z + 15]) + yogWaypoints.push([x - 41, y - 3, z + 26]) + yogWaypoints.push([x - 32, y - 3, z + 45]) + yogWaypoints.push([x - 22, y - 3, z - 34]) + yogWaypoints.push([x + 28, y - 8, z + 36]) + yogWaypoints.push([x - 47, y - 3, z + 32]) + yogWaypoints.push([x - 43, y - 1, z + 4]) + yogWaypoints.push([x - 47, y + 2, z - 20]) + yogWaypoints.push([x + 11, y - 13, z + 40]) + yogWaypoints.push([x + 15, y - 13, z + 43]) + yogWaypoints.push([x - 44, y + 2, z - 29]) + yogWaypoints.push([x + 33, y - 4, z - 15]) + yogWaypoints.push([x - 6, y - 4, z - 34]) + yogWaypoints.push([x + 19, y - 12, z + 35]) + yogWaypoints.push([x + 16, y - 9, z - 15]) + ChatLib.chat(`${PREFIX}&b${WAYPOINTNAME} waypoints turned on!`) + } + else + { + yogWaypoints = [] + ChatLib.chat(`${PREFIX}&b${WAYPOINTNAME} waypoints turned off!`) + } + } +} + +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]) + }) +}) + +register("worldLoad", () => { + yogWaypoints = [] +}) + +export default ""
\ No newline at end of file @@ -1,8 +1,9 @@ +import './render/naturals' +import './render/tabList' +import './commands/yog' import './chat/apiNew' import './chat/message' - import './chat/serverdata' -import './render/tabList' import './commandManager' import './util/updater' import './util/grieferTrack' @@ -26,7 +27,6 @@ register("renderWorld", () => { Tessellator.drawString(i+1, constants.spiralValues[i][0], constants.spiralValues[i][1], constants.spiralValues[i][2]) } } - }) diff --git a/metadata.json b/metadata.json index 385f4d0..1031128 100644 --- a/metadata.json +++ b/metadata.json @@ -3,6 +3,6 @@ "creator": "Ninjune", "entry": "index.js", "description": "Simple Coleweight module to measure mining progression.", - "version": "1.6.2", + "version": "1.6.4", "requires": ["axios", "PogData", "Vigilance"] }
\ No newline at end of file diff --git a/render/bobombOverlay.js b/render/bobombOverlay.js deleted file mode 100644 index 02526bd..0000000 --- a/render/bobombOverlay.js +++ /dev/null @@ -1,22 +0,0 @@ -/*import RenderLib from "../../RenderLib/index.js"; -Disabled. -register('renderWorld', () => { - try{ - if(Player.getHeldItem().getItemNBT().getTag('tag').getTag('ExtraAttributes').getTag("id").toString() != `"BOB_OMB"`) return - } catch(e) {return} - - const boxR = 0.3, - boxB = 0.5, - boxG = 0, - boxAlpha = 0.3 - - let x = Math.floor(Player.getX()) + 0.5, - y = Math.floor(Player.getY()) - z = Math.floor(Player.getZ()) + 0.5 - - - - RenderLib.drawInnerEspBox(x, y - 1, z - 8, 1, 1, boxR, boxB, boxG, boxAlpha, true) - RenderLib.drawInnerEspBox(x + 1, y + 1, z - 7, 1, 1, boxR, boxB, boxG, boxAlpha, true) - RenderLib.drawInnerEspBox(x + 1, y + 1, z - 7, 1, 1, boxR, boxB, boxG, boxAlpha, true) -})*/
\ No newline at end of file diff --git a/render/naturals.js b/render/naturals.js new file mode 100644 index 0000000..77a667d --- /dev/null +++ b/render/naturals.js @@ -0,0 +1,34 @@ +import axios from "../../axios" // USE AT YOUR OWN RISK disabled by default in this version because dragoonmaster4 wants me to confirm that this isn't bannable with admins before adding. +import settings from "../settings" +import constants from "../util/constants" +const PREFIX = constants.PREFIX +let coords = [] + +register("step", () => { + if(constants.serverData.map != "Crystal Hollows" || !settings.showNaturals) return + axios.get(`https://ninjune.dev/api/coords`) + .then((res) => { + coords = [] + res.data.filter(coord => + (((-1 * settings.naturalRange)/2 < (parseInt(Player.getX()) - coord.x)) && ((parseInt(Player.getX()) - coord.x) < settings.naturalRange/2) + && ((-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}) + }) + }) + .catch((err) => { + console.log(err) + }) +}).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) + }) +}) + +export default ""
\ No newline at end of file diff --git a/settings.js b/settings.js index cc6382e..4d46638 100644 --- a/settings.js +++ b/settings.js @@ -1,10 +1,11 @@ -import { @Vigilant, @ButtonProperty, @SwitchProperty, @SelectorProperty } from 'Vigilance' +import { @Vigilant, @ButtonProperty, @SwitchProperty, @SelectorProperty, @SliderProperty } from 'Vigilance' @Vigilant("Coleweight") class Settings { @SwitchProperty({ name: "Coleweight tracker", description: "Enables the Coleweight tracker.", + subcategory: "Coleweight Tracker", category: "General" }) cwToggle = true; @@ -12,6 +13,7 @@ class Settings { @ButtonProperty({ name: "Change Coleweight tracker position", description: "Move the location of the coleweight tracker.", + subcategory: "Coleweight Tracker", category: "General", placeholder: "Open" }) @@ -22,6 +24,7 @@ class Settings { @SwitchProperty({ name: "Rank chat", description: "Enables the Coleweight rank message after a name in chat.", + subcategory: "Ranked Chat", category: "General" }) rankChat = true; @@ -29,6 +32,7 @@ class Settings { @SwitchProperty({ name: "Rank everywhere", description: "Enables showing Coleweight rank everywhere. (instead of just in crystal hollows)", + subcategory: "Ranked Chat", category: "General" }) rankEverywhere = false; @@ -36,6 +40,7 @@ class Settings { @SwitchProperty({ name: "Track griefers", description: "Check lobbies for griefers (on join and when new players join.)", + subcategory: "Random Features", category: "General" }) trackGriefers = true; @@ -43,13 +48,42 @@ class Settings { @SwitchProperty({ name: "Claiming", description: "Enables lobby claiming (/claim).", + subcategory: "Random Features", category: "General" }) claiming = true; @SwitchProperty({ + name: "Debug", + description: "Toggles debug mode.", + subcategory: "Random Features", + category: "General" + }) + debug = false; + + @SwitchProperty({ + name: "Marked lobbies", + description: "Enables lobby marking (automatic).", + category: "General", + subcategory: "Marking" + }) + lobbyMarking = false; + + @ButtonProperty({ + name: "Clear lobbies", + description: "Clears marked lobbies.", + category: "General", + subcategory: "Marking", + placeholder: "Clear" + }) + clearLobbies() { + ChatLib.command("cw clearlobbies", true); + } + + @SwitchProperty({ name: "Timer", description: "Toggles visibility of CHollows timer", + subcategory: "Timer", category: "General" }) timerVisible = false; @@ -57,6 +91,7 @@ class Settings { @ButtonProperty({ name: "Change timer position", description: "Move the location of the timer.", + subcategory: "Timer", category: "General", placeholder: "Open" }) @@ -65,13 +100,6 @@ class Settings { } @SwitchProperty({ - name: "Debug", - description: "Toggles debug mode.", - category: "General" - }) - debug = false; - - @SwitchProperty({ name: "Show powdertracker", description: "If the tracker overlay should be visible.", category: "Powdertracker" @@ -110,6 +138,22 @@ class Settings { ChatLib.command("cw move powdertracker", true); } + @SwitchProperty({ + name: "Show naturals", + description: "If natural veins should show.", + category: "Naturals" + }) + showNaturals = false + + @SliderProperty({ + name: "Natural range", + description: "Range that naturals will show up in", + category: "Naturals", + min: 16, + max: 64 + }) + naturalRange = 32 + constructor() { this.initialize(this); this.registerListener("Rank chat", value => { @@ -124,6 +168,9 @@ class Settings { this.registerListener("Claiming", value => { this.claiming = value; }) + this.registerListener("Marked lobbies", value => { + this.lobbyMarking = value; + }) this.registerListener("Timer", value => { this.timerVisible = value; }) @@ -142,6 +189,12 @@ class Settings { this.registerListener("Alignment", value => { this.trackerAlignment = value; }) + this.registerListener("Show naturals", value => { + this.showNaturals = value; + }) + this.registerListener("Natural range", value => { + this.naturalRange = value; + }) } } diff --git a/util/grieferTrack.js b/util/grieferTrack.js index a468191..a21653b 100644 --- a/util/grieferTrack.js +++ b/util/grieferTrack.js @@ -8,9 +8,12 @@ let players = [] // global variable moment function checkMMiners() { if (!Settings.trackGriefers) return - let tempPlayers = World.getAllPlayers().map((p) => p.getName()) - - tempPlayers.forEach((player, index) => { + 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}`) |