aboutsummaryrefslogtreecommitdiff
path: root/util/updater.js
diff options
context:
space:
mode:
Diffstat (limited to 'util/updater.js')
-rw-r--r--util/updater.js36
1 files changed, 16 insertions, 20 deletions
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)
- })
- }
})
})