diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-07 15:42:00 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-07 15:42:00 +0800 |
commit | a8a5a3f8c2c0c0897006a6a68cf4fb1eba2b9f9f (patch) | |
tree | 6029ccf80aa2bbdc712b88edc1a5dcb3b5bf3110 /features/dataLoader | |
parent | ad10250efe29f45951e3b8483dbde002c0ea4b3d (diff) | |
download | SoopyV2-a8a5a3f8c2c0c0897006a6a68cf4fb1eba2b9f9f.tar.gz SoopyV2-a8a5a3f8c2c0c0897006a6a68cf4fb1eba2b9f9f.tar.bz2 SoopyV2-a8a5a3f8c2c0c0897006a6a68cf4fb1eba2b9f9f.zip |
+ remove update button patcher module (removed soopyv2 from ct website)
+ updating will be same as updatebuttonpatcher used to be, but built into soopyv2
+ new version avalible chat message
+ show other player's inquis waypoints
Diffstat (limited to 'features/dataLoader')
-rw-r--r-- | features/dataLoader/index.js | 96 |
1 files changed, 57 insertions, 39 deletions
diff --git a/features/dataLoader/index.js b/features/dataLoader/index.js index fe11e42..21bfe76 100644 --- a/features/dataLoader/index.js +++ b/features/dataLoader/index.js @@ -1,6 +1,7 @@ /// <reference types="../../../CTAutocomplete" /> /// <reference lib="es2015" /> import Feature from "../../featureClass/class"; +import socketConnection from "../../socketConnection"; import { fetch } from "../../utils/networkUtils"; class DataLoader extends Feature { @@ -8,7 +9,7 @@ class DataLoader extends Feature { super() } - onEnable(){ + onEnable() { this.initVariables() this.stats = {} @@ -26,6 +27,9 @@ class DataLoader extends Feature { this.api_loaded_event = this.createCustomEvent("apiLoad") + this.lastServer = undefined + this.lastSentServer = 0 + this.loadedApiDatas = {} this.lastApiData = { @@ -40,44 +44,44 @@ class DataLoader extends Feature { this.loadApi() } - worldLoad(){ + worldLoad() { this.area = undefined this.areaFine = undefined this.worldLoaded = true } - loadApi(){ - fetch("http://soopymc.my.to/api/v2/player_skyblock/" + Player.getUUID().replace(/-/g, "")).json(data=>{ + loadApi() { + fetch("http://soopymc.my.to/api/v2/player_skyblock/" + Player.getUUID().replace(/-/g, "")).json(data => { - if(!data.success) return + if (!data.success) return this.api_loaded_event.trigger(data, "skyblock", true, true) this.lastApiData.skyblock = data }) } - loadApiData(type, soopyServer){ - if(this.FeatureManager.features["globalSettings"] === undefined || this.FeatureManager.features["globalSettings"].class.apiKeySetting === undefined){ + loadApiData(type, soopyServer) { + if (this.FeatureManager.features["globalSettings"] === undefined || this.FeatureManager.features["globalSettings"].class.apiKeySetting === undefined) { return } let key = this.FeatureManager.features["globalSettings"].class.apiKeySetting.getValue() - if(!key) return + if (!key) return - if(this.loadedApiDatas[type] !== undefined){ - if(Date.now()-this.loadedApiDatas[type] < 5000 && !this.worldLoaded) return + if (this.loadedApiDatas[type] !== undefined) { + if (Date.now() - this.loadedApiDatas[type] < 5000 && !this.worldLoaded) return } - this.worldLoaded =false + this.worldLoaded = false this.loadedApiDatas[type] = Date.now() - if(soopyServer){ + if (soopyServer) { + + } else { + if (type === "skyblock") { + fetch("https://api.hypixel.net/skyblock/profiles?key=" + key + "&uuid=" + Player.getUUID().replace(/-/g, "")).json(data => { + if (!data.success) return - }else{ - if(type === "skyblock"){ - fetch("https://api.hypixel.net/skyblock/profiles?key=" + key + "&uuid=" + Player.getUUID().replace(/-/g, "")).json(data=>{ - if(!data.success) return - this.api_loaded_event.trigger(data, "skyblock", false, true) this.lastApiData.skyblock_raw = data }) @@ -85,66 +89,80 @@ class DataLoader extends Feature { } } - step(){ //2fps + step() { //2fps + this.isInSkyblock = Scoreboard.getTitle()?.removeFormatting().includes("SKYBLOCK") + + if (!this.isInSkyblock) { + this.stats = {} + return + } + this.stats["Area"] = undefined this.stats["Dungeon"] = undefined - if(World.isLoaded() && TabList.getNames()){ - TabList.getNames().forEach(n=>{ + if (World.isLoaded() && TabList.getNames()) { + TabList.getNames().forEach(n => { n = ChatLib.removeFormatting(n) - if(n.includes(": ")){ - if(n.includes('Secrets Found')){ - if(n.includes('%')){ + if (n.includes(": ")) { + if (n.includes('Secrets Found')) { + if (n.includes('%')) { this.stats["Secrets Found%"] = n.split(": ")[1] - }else{ + } else { this.stats["Secrets Found"] = n.split(": ")[1] } - }else{ + } else { this.stats[n.split(": ")[0].trim()] = n.split(": ")[1].trim() } } }) } - if(this.stats["Dungeon"]){ + if (this.stats["Dungeon"]) { this.stats["Area"] = this.stats["Dungeon"] this.isInDungeon = true - }else{ + } else { this.isInDungeon = false } this.dungeonFloor = undefined this.slayerXpToSpawn = undefined - Scoreboard.getLines().forEach(line=>{ + Scoreboard.getLines().forEach(line => { let name = ChatLib.removeFormatting(line.getName()).replace(/[^A-z0-9 \:\(\)\.]/g, "") - if(this.isInDungeon){ - if(name.includes("The Catacombs (")){ + if (this.isInDungeon) { + if (name.includes("The Catacombs (")) { this.dungeonFloor = name.split("(")[1].split(")")[0].toUpperCase() } } - if(ChatLib.removeFormatting(line).startsWith(" ⏣ ")){ + if (ChatLib.removeFormatting(line).startsWith(" ⏣ ")) { this.areaFine = ChatLib.removeFormatting(line).split(" ⏣ ")[1].replace(/[^A-z0-9 \:\(\)\.\-]/g, "") } - if(name.startsWith("Purse: ")){ + if (name.startsWith("Purse: ")) { this.purse = parseInt(name.split("Purse: ")[1].split(" ")[0]) } - if(name.startsWith("Bits: ")){ + if (name.startsWith("Bits: ")) { this.bits = parseInt(name.split("Bits: ")[1].split(" ")[0]) } - if(name.startsWith("Cleared: ")){ - this.dungeonPercentCleared = parseInt(name.split(" ")[1])/100 + if (name.startsWith("Cleared: ")) { + this.dungeonPercentCleared = parseInt(name.split(" ")[1]) / 100 } - if(name.endsWith("Combat XP")){ + if (name.endsWith("Combat XP")) { this.slayerXpToSpawn = ChatLib.removeFormatting(name).split("(")[1].split(")")[0].split("/").map(parseInt) } }) - this.isInSkyblock = Scoreboard.getTitle()?.removeFormatting().includes("SKYBLOCK") this.area = this.stats["Area"] + + + if (this.lastServer !== this.FeatureManager.features["dataLoader"].class.stats.Server || Date.now() - this.lastSentServer > 60000 * 5) { + this.lastServer = this.FeatureManager.features["dataLoader"].class.stats.Server; + this.lastSentServer = Date.now() + + socketConnection.setServer(this.FeatureManager.features["dataLoader"].class.stats.Server); + } } - initVariables(){ + initVariables() { this.stats = undefined this.isInDungeon = false @@ -157,7 +175,7 @@ class DataLoader extends Feature { this.isInSkyblock = undefined } - onDisable(){ + onDisable() { this.initVariables() } } |