From e72c42345ef32fe9f3eeaf92844c0b77f175fac6 Mon Sep 17 00:00:00 2001 From: Ninjune Date: Tue, 8 Nov 2022 13:30:41 -0600 Subject: 1.5.4 Fixed bugs (changelog in discord) --- util/apiNew.js | 23 +++++++++++++++++++++++ util/constants.js | 10 +++++----- util/updater.js | 39 ++++++++++++++++++++++++++++----------- 3 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 util/apiNew.js (limited to 'util') diff --git a/util/apiNew.js b/util/apiNew.js new file mode 100644 index 0000000..dd03c5f --- /dev/null +++ b/util/apiNew.js @@ -0,0 +1,23 @@ +import constants from "../util/constants" +import axios from "../../axios" +const PREFIX = constants.PREFIX + +register("chat", (key) => { + axios.get(`https://api.hypixel.net/key?key=${key}`) + .then(res => { + if(res.data.success == true) + { + constants.data.api_key = key + constants.data.save() + ChatLib.chat(`${PREFIX}&aSuccsessfully set api key!`) + } + else + ChatLib.chat(`${PREFIX}&eKey is not valid!`) + }) + .catch(err => { + ChatLib.chat(`${PREFIX}&eKey is not valid!`) + }) + ChatLib.chat(ChatLib.getCenteredText(`${PREFIX}&aApi Key Successfully Set!`)) +}).setCriteria(/Your new API key is (.+)/) + +export default "" \ No newline at end of file diff --git a/util/constants.js b/util/constants.js index d7377fd..c421304 100644 --- a/util/constants.js +++ b/util/constants.js @@ -1,16 +1,15 @@ 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 + "first_time": true }, ".cw_data.json"); -export default +export default { PREFIX: "&2[CW] ", VERSION: (JSON.parse(FileLib.read("Coleweight", "metadata.json"))).version, @@ -24,5 +23,6 @@ export default throneValues: [], spiralValues: [], coleweightHr: 0, - cwValuesSum: 0 + cwValuesSum: 0, + beta: false } \ No newline at end of file diff --git a/util/updater.js b/util/updater.js index edc20f8..64fbe1b 100644 --- a/util/updater.js +++ b/util/updater.js @@ -4,19 +4,36 @@ PREFIX = constants.PREFIX VERSION = constants.VERSION register("worldLoad", () => { - axios.get(`https://raw.githubusercontent.com/Ninjune/coleweight/main/metadata.json`) + axios.get(`https://chattriggers.com/api/modules/1367`) .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("") - }) - .catch(err => { - ChatLib.chat(err) + if(res.data.releases[0].releaseVersion != VERSION && constants.beta == false) + { + ChatLib.chat(`${PREFIX}&eYou are using an unsupported version of Coleweight!`) + new TextComponent(`${PREFIX}&eClick &3here&e to update!`) + .setClickAction("run_command") + .setClickValue(`/ct load`) + .chat() + ChatLib.chat("") + } + else + { + axios.get(`https://raw.githubusercontent.com/Ninjune/coleweight/main/metadata.json`) + .then(res => { + if(res.data.version == VERSION || constants.beta == true) 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) + }) + } }) + }) export default "" \ No newline at end of file -- cgit