diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/constants.js | 30 | ||||
-rw-r--r-- | util/grieferTrack.js | 44 | ||||
-rw-r--r-- | util/helperFunctions.js | 10 | ||||
-rw-r--r-- | util/updater.js | 36 |
4 files changed, 93 insertions, 27 deletions
diff --git a/util/constants.js b/util/constants.js index d7377fd..16cd037 100644 --- a/util/constants.js +++ b/util/constants.js @@ -1,20 +1,34 @@ import PogObject from "PogData" let PogData = new PogObject("Coleweight", { - "api_key": undefined, + "api_key": "", "x": 0.5, "y": 141, "coleweight": 0, - "cwToggle": true, - "first_time": true, - "api_key": undefined -}, ".cw_data.json"); + "first_time": true +}, "config/.cw_data.json") -export default +let PowderData = new PogObject("Coleweight", { + "chests": 0, + "gemstonePowder": 0, + "mithrilPowder": 0, + "x": 0, + "y": 0 +}, "config/.powdertracker_data.json") + +let TimerData = new PogObject("Coleweight", { + "x": 0, + "y": 0, + "timer": 0 +}, "config/.timer_data.json") + +export default { PREFIX: "&2[CW] ", VERSION: (JSON.parse(FileLib.read("Coleweight", "metadata.json"))).version, data: PogData, + powderdata: PowderData, + timerdata: TimerData, cwValues: [], calcCwPerHr: false, upTimeTrack: false, @@ -24,5 +38,7 @@ export default throneValues: [], spiralValues: [], coleweightHr: 0, - cwValuesSum: 0 + cwValuesSum: 0, + beta: false, + serverData: {} }
\ No newline at end of file diff --git a/util/grieferTrack.js b/util/grieferTrack.js new file mode 100644 index 0000000..a468191 --- /dev/null +++ b/util/grieferTrack.js @@ -0,0 +1,44 @@ +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 + let tempPlayers = World.getAllPlayers().map((p) => p.getName()) + + tempPlayers.forEach((player, index) => { + 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 new file mode 100644 index 0000000..2bea5d0 --- /dev/null +++ b/util/helperFunctions.js @@ -0,0 +1,10 @@ +/* +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 diff --git a/util/updater.js b/util/updater.js index 43693e3..ea8fa2c 100644 --- a/util/updater.js +++ b/util/updater.js @@ -1,12 +1,25 @@ import axios from "../../axios" import constants from "./constants" -PREFIX = constants.PREFIX -VERSION = constants.VERSION + +const PREFIX = constants.PREFIX, + VERSION = constants.VERSION register("worldLoad", () => { axios.get(`https://chattriggers.com/api/modules/1367`) .then(res => { - if(res.data.releases[0].releaseVersion != VERSION) + let ctVersionArray = (res.data.releases[0].releaseVersion).split('.'), + currentVersionArray = VERSION.split('.'), + newVersion = false + + for(let i = ctVersionArray.length; i >= 0; i--) + { + if (ctVersionArray[i] > currentVersionArray[i]) + newVersion = true + else if (currentVersionArray[i] > ctVersionArray[i]) + newVersion = false + } + + if(newVersion) { ChatLib.chat(`${PREFIX}&eYou are using an unsupported version of Coleweight!`) new TextComponent(`${PREFIX}&eClick &3here&e to update!`) @@ -15,23 +28,6 @@ register("worldLoad", () => { .chat() ChatLib.chat("") } - else - { - axios.get(`https://raw.githubusercontent.com/Ninjune/coleweight/main/metadata.json`) - .then(res => { - if(res.data.version == VERSION) return - ChatLib.chat(`${PREFIX}&eYou are using an unsupported version of Coleweight!`) - new TextComponent(`${PREFIX}&eClick &3here&e to open the github releases!`) - .setClickAction("open_url") - .setClickValue(`https://github.com/Ninjune/coleweight/releases`) - .chat() - ChatLib.chat("") - return - }) - .catch(err => { - ChatLib.chat(err) - }) - } }) }) |