diff options
Diffstat (limited to 'features')
-rw-r--r-- | features/changeLogGUI/index.js | 17 | ||||
-rw-r--r-- | features/cosmetics/index.js | 7 | ||||
-rw-r--r-- | features/dataLoader/index.js | 20 | ||||
-rw-r--r-- | features/events/index.js | 14 | ||||
-rw-r--r-- | features/globalSettings/index.js | 139 | ||||
-rw-r--r-- | features/hud/index.js | 10 | ||||
-rw-r--r-- | features/networthGUI/index.js | 183 | ||||
-rw-r--r-- | features/senitherGui/index.js | 97 | ||||
-rw-r--r-- | features/spamHider/index.js | 72 | ||||
-rw-r--r-- | features/streamsGUI/index.js | 37 | ||||
-rw-r--r-- | features/suggestionsGui/index.js | 225 |
11 files changed, 398 insertions, 423 deletions
diff --git a/features/changeLogGUI/index.js b/features/changeLogGUI/index.js index 1a75825..0d60b72 100644 --- a/features/changeLogGUI/index.js +++ b/features/changeLogGUI/index.js @@ -10,6 +10,7 @@ import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"; import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent"; import ProgressBar from "../../../guimanager/GuiElement/ProgressBar" import SoopyRenderEvent from "../../../guimanager/EventListener/SoopyRenderEvent" +import { fetch } from "../../utils/networkUtils"; const File = Java.type("java.io.File") const URL = Java.type("java.net.URL"); const PrintStream = Java.type("java.io.PrintStream"); @@ -125,19 +126,19 @@ class ChangelogPage extends GuiPage { } loadChangeLog(){ - let data = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/changelog.json")) + fetch("http://soopymc.my.to/api/soopyv2/changelog.json").json(data=>{ - this.changelogData = data.changelog.reverse() + this.changelogData = data.changelog.reverse() + + this.downloadableVersion = data.downloadableVersion + + this.updateText() + }) - this.downloadableVersion = data.downloadableVersion } onOpen(){ - new Thread(()=>{ - this.loadChangeLog() - - this.updateText() - }).start() + this.loadChangeLog() } // showConfirmUpdatePage(){ diff --git a/features/cosmetics/index.js b/features/cosmetics/index.js index ec8a094..98a848e 100644 --- a/features/cosmetics/index.js +++ b/features/cosmetics/index.js @@ -5,6 +5,7 @@ import DragonWings from "./cosmetic/dragon/dragonWings" import Toggle from "../settings/settingThings/toggle" import { f } from "../../../mappings/mappings"; import FakeRequireToggle from "../settings/settingThings/FakeRequireToggle"; +import { fetch } from "../../utils/networkUtils"; class Cosmetics extends Feature { constructor() { @@ -83,9 +84,7 @@ class Cosmetics extends Feature { } loadCosmeticsData(){ - try{ - let data = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/cosmetics.json")) - + fetch("http://soopymc.my.to/api/soopyv2/cosmetics.json").json(data=>{ this.cosmeticsData = data this.playerHasACosmeticA = !!data[Player.getUUID().toString().replace(/-/g,"")] if(this.playerHasACosmeticA && !this.postRenderEntityTrigger){ @@ -102,7 +101,7 @@ class Cosmetics extends Feature { } this.scanForNewCosmetics() - }catch(e){} + }) } setUserCosmeticsInformation(uuid, cosmetics){ diff --git a/features/dataLoader/index.js b/features/dataLoader/index.js index 7bf2bf9..f320ea6 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 { fetch } from "../../utils/networkUtils"; class DataLoader extends Feature { constructor() { @@ -39,19 +40,18 @@ class DataLoader extends Feature { } loadApi(){ - try{ - let data = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/v2/player_skyblock/" + Player.getUUID().replace(/-/g, ""))) + fetch("http://soopymc.my.to/api/v2/player_skyblock/" + Player.getUUID().replace(/-/g, "")).json(data=>{ if(!data.success) return this.api_loaded_event.trigger(data, "skyblock", true, true) this.lastApiData.skyblock = data - }catch(e){} + }) } loadApiData(type, soopyServer){ - while(this.FeatureManager.features["globalSettings"] === undefined || this.FeatureManager.features["globalSettings"].class.apiKeySetting === undefined){ - Thread.sleep(100) + 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 @@ -66,18 +66,12 @@ class DataLoader extends Feature { }else{ if(type === "skyblock"){ - try{ - // console.log("loading") - let data = JSON.parse(FileLib.getUrlContent("https://api.hypixel.net/skyblock/profiles?key=" + key + "&uuid=" + Player.getUUID().replace(/-/g, ""))) - + 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 - }catch(e){ - console.log("Hypixel api request failed:") - console.log(JSON.stringify(e, undefined, 2)) - } + }) } } } diff --git a/features/events/index.js b/features/events/index.js index 912e566..96a3de0 100644 --- a/features/events/index.js +++ b/features/events/index.js @@ -175,12 +175,16 @@ class Events extends Feature { step_5s(){ if(this.showingWaypoints){ if(this.burrialWaypointsPath.getValue() || this.burrialWaypointsNearest.getValue()){ - new Thread(()=>{ + new Thread(()=>{ //TODO: make 5head thing to re-use threads this.updateBurrialPath() }).start() } } this.sortBurrialLocations() + + if(this.nextUpdateApprox === -2){ + this.loadApi() + } } worldLoad(){ @@ -194,13 +198,7 @@ class Events extends Feature { } loadApi(){ - new Thread(()=>{ - while(this.nextUpdateApprox === -2){ - this.FeatureManager.features["dataLoader"].class.loadApiData("skyblock", false) - - Thread.sleep(5000) - } - }).start() + this.FeatureManager.features["dataLoader"].class.loadApiData("skyblock", false) } apiLoad(data, dataType, isSoopyServer, isLatest){ diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index f98bab6..47ed125 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -12,6 +12,7 @@ import logger from "../../logger"; import soopyV2Server from "../../socketConnection"; import { numberWithCommas } from "../../utils/numberUtils"; import { firstLetterCapital } from "../../utils/stringUtils"; +import { fetch } from "../../utils/networkUtils"; const Files = Java.type("java.nio.file.Files") const Paths = Java.type("java.nio.file.Paths") const JavaString = Java.type("java.lang.String") @@ -65,14 +66,10 @@ class Hud extends Feature { this.registerCommand("soopyweight", (user=Player.getName())=>{ - new Thread(()=>{ - this.soopyWeight(user) - }).start() + this.soopyWeight(user) }) this.registerCommand("sweight", (user=Player.getName())=>{ - new Thread(()=>{ - this.soopyWeight(user) - }).start() + this.soopyWeight(user) }) } @@ -80,70 +77,72 @@ class Hud extends Feature { ChatLib.chat(this.FeatureManager.messagePrefix + "Finding senither weight for " + user) - let userData = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/v2/player/"+user)) - - if(!userData.success){ - ChatLib.chat(this.FeatureManager.messagePrefix + "&cError loading data: " + userData.error.description) - return - } - - let sbData = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/v2/player_skyblock/"+userData.data.uuid)) - - if(!sbData.success){ - ChatLib.chat(this.FeatureManager.messagePrefix + "&cError loading data: " + sbData.error.description) - return - } - - ChatLib.chat("&c" + ChatLib.getChatBreak("-")) - ChatLib.chat(userData.data.stats.nameWithPrefix + "'s senither weight (best profile):") - ChatLib.chat("&aTotal: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.total))) - new Message(new TextComponent("&aSkills: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill.total))) - .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill).map(skill=>{ - if(skill === "total"){ - return null - } - return "&a"+firstLetterCapital(skill)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill[skill].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill[skill].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill[skill].overflow)) + ")" - }).filter(a=>a).join("\n"))).chat() - new Message(new TextComponent("&aSlayer: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer.total))) - .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer).map(slayer=>{ - if(slayer === "total"){ - return null - } - return "&a"+firstLetterCapital(slayer)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer[slayer].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer[slayer].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer[slayer].overflow)) + ")" - }).filter(a=>a).join("\n"))).chat() - new Message(new TextComponent("&aDungeon: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons.total))) - .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons).map(dungeons=>{ - if(dungeons === "total"){ - return null + fetch("http://soopymc.my.to/api/v2/player/"+user).json(userData=>{ + if(!userData.success){ + ChatLib.chat(this.FeatureManager.messagePrefix + "&cError loading data: " + userData.error.description) + return } - return "&a"+firstLetterCapital(dungeons)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons[dungeons].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons[dungeons].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons[dungeons].overflow)) + ")" - }).filter(a=>a).join("\n"))).chat() - if(sbData.data.stats.bestProfileId !== sbData.data.stats.currentProfileId){ - ChatLib.chat(userData.data.stats.nameWithPrefix + "'s senither weight (current profile):") - ChatLib.chat("&aTotal: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.total))) - new Message(new TextComponent("&aSkills: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill.total))) - .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill).map(skill=>{ - if(skill === "total"){ - return null - } - return "&a"+firstLetterCapital(skill)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill[skill].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill[skill].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill[skill].overflow)) + ")" - }).filter(a=>a).join("\n"))).chat() - new Message(new TextComponent("&aSlayer: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer.total))) - .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer).map(slayer=>{ - if(slayer === "total"){ - return null + + fetch("http://soopymc.my.to/api/v2/player_skyblock/"+userData.data.uuid).json(sbData=>{ + + if(!sbData.success){ + ChatLib.chat(this.FeatureManager.messagePrefix + "&cError loading data: " + sbData.error.description) + return } - return "&a"+firstLetterCapital(slayer)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer[slayer].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer[slayer].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer[slayer].overflow)) + ")" - }).filter(a=>a).join("\n"))).chat() - new Message(new TextComponent("&aDungeon: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons.total))) - .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons).map(dungeons=>{ - if(dungeons === "total"){ - return null + + ChatLib.chat("&c" + ChatLib.getChatBreak("-")) + ChatLib.chat(userData.data.stats.nameWithPrefix + "'s senither weight (best profile):") + ChatLib.chat("&aTotal: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.total))) + new Message(new TextComponent("&aSkills: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill.total))) + .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill).map(skill=>{ + if(skill === "total"){ + return null + } + return "&a"+firstLetterCapital(skill)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill[skill].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill[skill].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.skill[skill].overflow)) + ")" + }).filter(a=>a).join("\n"))).chat() + new Message(new TextComponent("&aSlayer: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer.total))) + .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer).map(slayer=>{ + if(slayer === "total"){ + return null + } + return "&a"+firstLetterCapital(slayer)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer[slayer].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer[slayer].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.slayer[slayer].overflow)) + ")" + }).filter(a=>a).join("\n"))).chat() + new Message(new TextComponent("&aDungeon: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons.total))) + .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons).map(dungeons=>{ + if(dungeons === "total"){ + return null + } + return "&a"+firstLetterCapital(dungeons)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons[dungeons].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons[dungeons].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.bestProfileId].members[userData.data.uuid].weight.dungeons[dungeons].overflow)) + ")" + }).filter(a=>a).join("\n"))).chat() + if(sbData.data.stats.bestProfileId !== sbData.data.stats.currentProfileId){ + ChatLib.chat(userData.data.stats.nameWithPrefix + "'s senither weight (current profile):") + ChatLib.chat("&aTotal: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.total))) + new Message(new TextComponent("&aSkills: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill.total))) + .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill).map(skill=>{ + if(skill === "total"){ + return null + } + return "&a"+firstLetterCapital(skill)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill[skill].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill[skill].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.skill[skill].overflow)) + ")" + }).filter(a=>a).join("\n"))).chat() + new Message(new TextComponent("&aSlayer: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer.total))) + .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer).map(slayer=>{ + if(slayer === "total"){ + return null + } + return "&a"+firstLetterCapital(slayer)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer[slayer].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer[slayer].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.slayer[slayer].overflow)) + ")" + }).filter(a=>a).join("\n"))).chat() + new Message(new TextComponent("&aDungeon: &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons.total))) + .setHover("show_text", Object.keys(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons).map(dungeons=>{ + if(dungeons === "total"){ + return null + } + return "&a"+firstLetterCapital(dungeons)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons[dungeons].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons[dungeons].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons[dungeons].overflow)) + ")" + }).filter(a=>a).join("\n"))).chat() } - return "&a"+firstLetterCapital(dungeons)+": &b" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons[dungeons].total)) + " &7(" + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons[dungeons].weight)) + " | " + numberWithCommas(Math.round(sbData.data.profiles[sbData.data.stats.currentProfileId].members[userData.data.uuid].weight.dungeons[dungeons].overflow)) + ")" - }).filter(a=>a).join("\n"))).chat() - } - ChatLib.chat("&c" + ChatLib.getChatBreak("-")) + ChatLib.chat("&c" + ChatLib.getChatBreak("-")) + + }) + }) } showFirstLoadPage(){ @@ -161,7 +160,7 @@ class Hud extends Feature { if(key){ try{ var url = "https://api.hypixel.net/key?key=" + key - let data = JSON.parse(FileLib.getUrlContent(url)) + let data = fetch(url).json() // console.log(data) @@ -269,7 +268,7 @@ class Hud extends Feature { if(key){ try{ var url = "https://api.hypixel.net/key?key=" + key - let data = JSON.parse(FileLib.getUrlContent(url)) + let data = fetch(url).json() if(data.success){ return true @@ -289,7 +288,7 @@ class Hud extends Feature { new Thread(()=>{ try{ var url = "https://api.hypixel.net/key?key=" + this.module.apiKeySetting.getValue() - let data = JSON.parse(FileLib.getUrlContent(url)) + let data = fetch(url).json() if(data.success){ new Notification("§aSuccess!", ["Your api key is valid!"]) diff --git a/features/hud/index.js b/features/hud/index.js index d37fc42..917a2f6 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -150,7 +150,7 @@ class Hud extends Feature { for(let i = 1;i<8;i++){ hudStatTypes["completions_floor_"+i] = "Floor " + i + " completions" } - for(let i = 1;i<7;i++){ + for(let i = 1;i<8;i++){ hudStatTypes["completions_master_"+i] = "Master " + i + " completions" } for(let i = 1;i<8;i++){ @@ -252,7 +252,7 @@ class Hud extends Feature { this.apiLoad(this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock_raw, "skyblock", false, true) } - new Thread(()=>{ + new Thread(()=>{ //TODO: dont create this thread if you have the feature disabled while(this.enabled){ this.updateSpotify() Thread.sleep(5000) @@ -532,9 +532,9 @@ class Hud extends Feature { updateHudThingos(){ let insb = this.FeatureManager.features["dataLoader"].class.isInSkyblock if(Date.now()-this.lastUpdatedStatData > 5*60000 && this.hudStat[0].enabled.getValue() && (insb || this.hudStat.map(a=>a.onlySb.getValue()).includes(false))){ - new Thread(()=>{ - this.FeatureManager.features["dataLoader"].class.loadApiData("skyblock", false) - }).start() + + this.FeatureManager.features["dataLoader"].class.loadApiData("skyblock", false) + this.lastUpdatedStatData = Date.now() return } diff --git a/features/networthGUI/index.js b/features/networthGUI/index.js index f04f7dd..90033e9 100644 --- a/features/networthGUI/index.js +++ b/features/networthGUI/index.js @@ -14,6 +14,7 @@ import SoopyBoxElement from "../../../guimanager/GuiElement/SoopyBoxElement"; import SoopyMarkdownElement from "../../../guimanager/GuiElement/SoopyMarkdownElement"; import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent"; import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"; +import { fetch } from "../../utils/networkUtils"; class NetworthGui extends Feature { constructor() { @@ -61,11 +62,9 @@ class NetworthPage extends GuiPage { this.nameInput.addEvent(new SoopyKeyPressEvent().setHandler((key, keyId)=>{ if(this.nameInput.text.selected && keyId === 28){ - new Thread(()=>{ - this.playerLoad = this.nameInput.text.text - this.nameInput.setText("") - this.updateData(this.playerLoad) - }).start() + this.playerLoad = this.nameInput.text.text + this.nameInput.setText("") + this.updateData(this.playerLoad) } })) @@ -85,11 +84,9 @@ class NetworthPage extends GuiPage { this.sidebarUsernameSearch.addEvent(new SoopyKeyPressEvent().setHandler((key, keyId)=>{ if(this.sidebarUsernameSearch.text.selected && keyId === 28){ - new Thread(()=>{ - let search = this.sidebarUsernameSearch.text.text - this.sidebarUsernameSearch.setText("") - this.sidebarSearch(search) - }).start() + let search = this.sidebarUsernameSearch.text.text + this.sidebarUsernameSearch.setText("") + this.sidebarSearch(search) } })) @@ -98,10 +95,10 @@ class NetworthPage extends GuiPage { this.sidebarElement.addChild(this.lbBackButton) this.sidebarElement.addChild(this.lbNextButton) this.lbBackButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - if(this.currentLbPage > 0)new Thread(()=>{this.goToLeaderboardPage(this.currentLbPage-1)}).start() + if(this.currentLbPage > 0)this.goToLeaderboardPage(this.currentLbPage-1) })) this.lbNextButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - new Thread(()=>{this.goToLeaderboardPage(this.currentLbPage+1)}).start() + this.goToLeaderboardPage(this.currentLbPage+1) })) this.leaderboardArea = new SoopyGuiElement().setLocation(0.05, 0.15, 0.9, 0.85).setScrollable(true) @@ -121,91 +118,91 @@ class NetworthPage extends GuiPage { this.statArea.clearChildren() this.statArea.addChild(this.loadingElm) - let playerData = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/v2/player/" + player)) + fetch("http://soopymc.my.to/api/v2/player/" + player).json(playerData=>{ - if(player !== this.playerLoad) return + if(player !== this.playerLoad) return - if(!playerData.success){ - this.statArea.clearChildren() - this.statArea.addChild(this.errorElm) - this.errorElm.setText("§0" + playerData.error.name) - this.errorElm.setDesc("§0" + playerData.error.description) - return - } - - let skyblockData = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/v2/player_skyblock/" + playerData.data.uuid + "?items")) - - if(player !== this.playerLoad) return - - this.statArea.clearChildren() - - if(!skyblockData.success){ - this.statArea.addChild(this.errorElm) - this.errorElm.setText("§0" + skyblockData.error.name) - this.errorElm.setDesc("§0" + skyblockData.error.description) - return - } - - let highestProf = undefined - Object.keys(skyblockData.data.profiles).forEach(prof=>{ - if(highestProf === undefined || skyblockData.data.profiles[prof].members[playerData.data.uuid].soopyNetworth.networth > skyblockData.data.profiles[highestProf].members[playerData.data.uuid].soopyNetworth.networth) highestProf = prof - }) - - let nwData = skyblockData.data.profiles[highestProf].members[playerData.data.uuid].soopyNetworth - let nameElm = new SoopyTextElement().setText(playerData.data.stats.nameWithPrefix.replace(/§f/g, "§7")).setMaxTextScale(2).setLocation(0.1, 0.05, 0.8, 0.1) - this.statArea.addChild(nameElm) - this.statArea.addChild(new SoopyTextElement().setText("§0Networth (" + skyblockData.data.profiles[highestProf].stats.cute_name + "): §2$" + numberWithCommas(Math.round(nwData.networth)).replace(/,/g, "§7,§2")).setMaxTextScale(1.5).setLocation(0.1, 0.15, 0.8, 0.1)) - this.statArea.addChild(new SoopyTextElement().setText("§0Purse: §2$" + numberWithCommas(Math.round(nwData.purse)).replace(/,/g, "§7,§2") + "§0 | Bank: §2$" + numberWithCommas(Math.round(nwData.bank)).replace(/,/g, "§7,§2") + "§0 | Sack: §2$" + numberWithCommas(Math.round(nwData.sack)).replace(/,/g, "§7,§2")).setMaxTextScale(1.5).setLocation(0.1, 0.25, 0.8, 0.1)) + if(!playerData.success){ + this.statArea.clearChildren() + this.statArea.addChild(this.errorElm) + this.errorElm.setText("§0" + playerData.error.name) + this.errorElm.setDesc("§0" + playerData.error.description) + return + } - Object.keys(nwData.categories).sort((a, b)=>nwData.categories[b].total-nwData.categories[a].total).forEach((name, i)=>{ - let renderName = firstLetterWordCapital(name.replace(/_/g, " ")) - - let data = nwData.categories[name] + fetch("http://soopymc.my.to/api/v2/player_skyblock/" + playerData.data.uuid + "?items").json(skyblockData=>{ - let box = new SoopyBoxElement().setLocation(i%2===0?0:0.525, 0.45 + Math.floor(i/2)*0.35, 0.475, 0.25) - - box.addChild(new SoopyMarkdownElement().setLocation(0,0,1,1).setText(data.items.filter(i=>i.name).splice(0,5).map(a=>{ - let name = (a.name.startsWith("§f") || a.name.startsWith("§7[Lvl "))?a.name.replace("§f","§7"):a.name - return "§0" + name + "§0: §2$" + numberWithCommas(Math.round(a.p)).replace(/,/g, "§7,§2") - }).join("\n"))) + if(player !== this.playerLoad) return + + this.statArea.clearChildren() - let boxName = new SoopyTextElement().setLocation(i%2===0?0:0.525, 0.4+Math.floor(i/2)*0.35, 0.475, 0.05).setText("§0" + renderName + "§0: §2$" + numberWithCommas(Math.round(data.total)).replace(/,/g, "§7,§2")) - - this.statArea.addChild(box) - this.statArea.addChild(boxName) - }) - - let leaderboardData = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/v2/leaderboard/networth/user/" + playerData.data.uuid)) + if(!skyblockData.success){ + this.statArea.addChild(this.errorElm) + this.errorElm.setText("§0" + skyblockData.error.name) + this.errorElm.setDesc("§0" + skyblockData.error.description) + return + } - if(player !== this.playerLoad) return - - if(leaderboardData.success)nameElm.setText("§0#" + numberWithCommas(leaderboardData.data.data.position+1) + " " + playerData.data.stats.nameWithPrefix.replace(/§f/g, "§7")) + let highestProf = undefined + Object.keys(skyblockData.data.profiles).forEach(prof=>{ + if(highestProf === undefined || skyblockData.data.profiles[prof].members[playerData.data.uuid].soopyNetworth.networth > skyblockData.data.profiles[highestProf].members[playerData.data.uuid].soopyNetworth.networth) highestProf = prof + }) + + let nwData = skyblockData.data.profiles[highestProf].members[playerData.data.uuid].soopyNetworth + let nameElm = new SoopyTextElement().setText(playerData.data.stats.nameWithPrefix.replace(/§f/g, "§7")).setMaxTextScale(2).setLocation(0.1, 0.05, 0.8, 0.1) + this.statArea.addChild(nameElm) + this.statArea.addChild(new SoopyTextElement().setText("§0Networth (" + skyblockData.data.profiles[highestProf].stats.cute_name + "): §2$" + numberWithCommas(Math.round(nwData.networth)).replace(/,/g, "§7,§2")).setMaxTextScale(1.5).setLocation(0.1, 0.15, 0.8, 0.1)) + this.statArea.addChild(new SoopyTextElement().setText("§0Purse: §2$" + numberWithCommas(Math.round(nwData.purse)).replace(/,/g, "§7,§2") + "§0 | Bank: §2$" + numberWithCommas(Math.round(nwData.bank)).replace(/,/g, "§7,§2") + "§0 | Sack: §2$" + numberWithCommas(Math.round(nwData.sack)).replace(/,/g, "§7,§2")).setMaxTextScale(1.5).setLocation(0.1, 0.25, 0.8, 0.1)) + + Object.keys(nwData.categories).sort((a, b)=>nwData.categories[b].total-nwData.categories[a].total).forEach((name, i)=>{ + let renderName = firstLetterWordCapital(name.replace(/_/g, " ")) + + let data = nwData.categories[name] + + let box = new SoopyBoxElement().setLocation(i%2===0?0:0.525, 0.45 + Math.floor(i/2)*0.35, 0.475, 0.25) + + box.addChild(new SoopyMarkdownElement().setLocation(0,0,1,1).setText(data.items.filter(i=>i.name).splice(0,5).map(a=>{ + let name = (a.name.startsWith("§f") || a.name.startsWith("§7[Lvl "))?a.name.replace("§f","§7"):a.name + return "§0" + name + "§0: §2$" + numberWithCommas(Math.round(a.p)).replace(/,/g, "§7,§2") + }).join("\n"))) + + let boxName = new SoopyTextElement().setLocation(i%2===0?0:0.525, 0.4+Math.floor(i/2)*0.35, 0.475, 0.05).setText("§0" + renderName + "§0: §2$" + numberWithCommas(Math.round(data.total)).replace(/,/g, "§7,§2")) + + this.statArea.addChild(box) + this.statArea.addChild(boxName) + }) + + fetch("http://soopymc.my.to/api/v2/leaderboard/networth/user/" + playerData.data.uuid).json(leaderboardData=>{ + if(player !== this.playerLoad) return + + if(leaderboardData.success)nameElm.setText("§0#" + numberWithCommas(leaderboardData.data.data.position+1) + " " + playerData.data.stats.nameWithPrefix.replace(/§f/g, "§7")) + }) + }) + }) } onOpen(){ - new Thread(()=>{ - this.playerLoad = Player.getName() - this.updateData(Player.getName()) + this.playerLoad = Player.getName() + this.updateData(Player.getName()) - this.goToLeaderboardPage(0) - }).start() + this.goToLeaderboardPage(0) this.openSidebarPage(this.sidebarElement) } sidebarSearch(user){ - let data = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/v2/leaderboard/networth/user/" + user)) + fetch("http://soopymc.my.to/api/v2/leaderboard/networth/user/" + user).json(data=>{ + if(!data.success){ + return + } - if(!data.success){ - return - } - - let position = data.data.data.position - - this.goToLeaderboardPage(Math.floor(position/100), false) - - this.leaderboardArea._scrollAmount = -((position%100)*0.1-0.45)*this.leaderboardArea.location.getHeightExact() - this.leaderboardArea.location.scroll.y.set(-((position%100)*0.1-0.45)*this.leaderboardArea.location.getHeightExact(),100) + let position = data.data.data.position + + this.goToLeaderboardPage(Math.floor(position/100), false) + + this.leaderboardArea._scrollAmount = -((position%100)*0.1-0.45)*this.leaderboardArea.location.getHeightExact() + this.leaderboardArea.location.scroll.y.set(-((position%100)*0.1-0.45)*this.leaderboardArea.location.getHeightExact(),100) + }) } goToLeaderboardPage(page, scroll=true){ @@ -214,20 +211,18 @@ class NetworthPage extends GuiPage { if(scroll)this.leaderboardArea._scrollAmount = 0 if(scroll)this.leaderboardArea.location.scroll.y.set(0,100) - let data = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/v2/leaderboard/networth/" + page)) - - this.leaderboardArea.clearChildren() - data.data.data.forEach((user, i)=>{ - this.leaderboardArea.addChild( - new SoopyTextElement().setText("§0#" + numberWithCommas(i+1+page*100) + ": " + user.username).setMaxTextScale(1.5).setLocation(0.05, i*0.1, 0.5, 0.1).setLore(["Click to show detailed stats"]).addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - new Thread(()=>{ + fetch("http://soopymc.my.to/api/v2/leaderboard/networth/" + page).json(data=>{ + this.leaderboardArea.clearChildren() + data.data.data.forEach((user, i)=>{ + this.leaderboardArea.addChild( + new SoopyTextElement().setText("§0#" + numberWithCommas(i+1+page*100) + ": " + user.username).setMaxTextScale(1.5).setLocation(0.05, i*0.1, 0.5, 0.1).setLore(["Click to show detailed stats"]).addEvent(new SoopyMouseClickEvent().setHandler(()=>{ this.updateData(user.uuid) - }).start() - })) - ) - this.leaderboardArea.addChild( - new SoopyTextElement().setText("§2$" + numberWithCommas(Math.round(user.networth)).replace(/,/g, "§7,§2")).setMaxTextScale(1.5).setLocation(0.6, i*0.1, 0.35, 0.1) - ) + })) + ) + this.leaderboardArea.addChild( + new SoopyTextElement().setText("§2$" + numberWithCommas(Math.round(user.networth)).replace(/,/g, "§7,§2")).setMaxTextScale(1.5).setLocation(0.6, i*0.1, 0.35, 0.1) + ) + }) }) } } diff --git a/features/senitherGui/index.js b/features/senitherGui/index.js index 50bda18..1a68092 100644 --- a/features/senitherGui/index.js +++ b/features/senitherGui/index.js @@ -17,6 +17,7 @@ import Dropdown from "../../../guimanager/GuiElement/Dropdown"; import SoopyMarkdownElement from "../../../guimanager/GuiElement/SoopyMarkdownElement" import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"; import SoopyRenderUpdateEvent from "../../../guimanager/EventListener/SoopyRenderUpdateEvent"; +import { fetch } from "../../utils/networkUtils"; class SenitherGui extends Feature { constructor() { @@ -254,9 +255,7 @@ class SettingPage extends GuiPage { step(){ if(!this.playerInformationUpdated && !this.updatingPlayerInfo){ - new Thread(()=>{ - this.loadPlayerInformation() - }).start() + this.loadPlayerInformation() } let pbHeight = this.playersBox.location.getHeightExact() @@ -302,17 +301,15 @@ class SettingPage extends GuiPage { this.goToPage(2) - new Thread(()=>{ - this.loadGuildInformation() - }).start() + this.loadGuildInformation() } loadGuildInformation(){ - let data = JSON.parse(FileLib.getUrlContent("https://hypixel-app-api.senither.com/leaderboard/")) - - this.guildData = data.data - - this.regenGuildElements() + fetch("https://hypixel-app-api.senither.com/leaderboard/").json(data=>{ + this.guildData = data.data + + this.regenGuildElements() + }) } regenGuildElements(){ @@ -381,58 +378,56 @@ class SettingPage extends GuiPage { if(this.updatingPlayerInfo) return this.updatingPlayerInfo = true this.playerInformationUpdated = true - let players = JSON.parse(FileLib.getUrlContent("https://hypixel-app-api.senither.com/leaderboard/players?perPage=100&page=1&sort=" + this.playerSortThing + (this.playerSearch?"&username="+this.playerSearch:""))) - - this.playersBox.clearChildren() - players.data.forEach((p, i)=>{ - let element = new SoopyBoxElement().setLocation(0,i*0.175, 1, 0.15) - - element.addEvent(new SoopyHoverChangeEvent().setHandler(()=>{ - if(element.hovered){ - if(element.color[0]+element.color[1]+element.color[2]<0.5*(255+255+255)){ - element.setColorOffset(10, 10, 10, 100) + fetch("https://hypixel-app-api.senither.com/leaderboard/players?perPage=100&page=1&sort=" + this.playerSortThing + (this.playerSearch?"&username="+this.playerSearch:"")).json(players=>{ + this.playersBox.clearChildren() + players.data.forEach((p, i)=>{ + let element = new SoopyBoxElement().setLocation(0,i*0.175, 1, 0.15) + + element.addEvent(new SoopyHoverChangeEvent().setHandler(()=>{ + if(element.hovered){ + if(element.color[0]+element.color[1]+element.color[2]<0.5*(255+255+255)){ + element.setColorOffset(10, 10, 10, 100) + }else{ + element.setColorOffset(-10, -10, -10, 100) + } }else{ - element.setColorOffset(-10, -10, -10, 100) + element.setColorOffset(0, 0, 0, 100) } - }else{ - element.setColorOffset(0, 0, 0, 100) - } - })) - - element.addChild(new SoopyTextElement().setText("§0#"+(i+1)).setLocation(0,0,0.075,1)) - element.addChild(new SoopyTextElement().setText("§0"+p.username).setLocation(0.1,0,0.2,1)) - element.addChild(new SoopyTextElement().setText("§0"+p.guild_name).setLocation(0.325,0,0.2,1)) - element.addChild(new SoopyTextElement().setText("§0"+numberWithCommas(p.weight)).setLocation(0.55,0,0.2,1)) - element.addChild(new SoopyTextElement().setText("§0"+numberWithCommas(p[this.selectedPlayerVal])).setLocation(0.75,0,0.2,1)) - - this.playersBox.addChild(element) + })) + + element.addChild(new SoopyTextElement().setText("§0#"+(i+1)).setLocation(0,0,0.075,1)) + element.addChild(new SoopyTextElement().setText("§0"+p.username).setLocation(0.1,0,0.2,1)) + element.addChild(new SoopyTextElement().setText("§0"+p.guild_name).setLocation(0.325,0,0.2,1)) + element.addChild(new SoopyTextElement().setText("§0"+numberWithCommas(p.weight)).setLocation(0.55,0,0.2,1)) + element.addChild(new SoopyTextElement().setText("§0"+numberWithCommas(p[this.selectedPlayerVal])).setLocation(0.75,0,0.2,1)) + + this.playersBox.addChild(element) + }) + this.updatingPlayerInfo = false }) - this.updatingPlayerInfo = false } loadFirstPageInformation(){ - let stats = JSON.parse(FileLib.getUrlContent("https://hypixel-app-api.senither.com/leaderboard/stats")) - - this.guildButton.setDesc("§0Guilds tracked: " + numberWithCommas(stats.data.guilds)) - this.playerButton.setDesc("§0Players tracked: " + numberWithCommas(stats.data.players)) - - let leaveAndJoins = JSON.parse(FileLib.getUrlContent("https://hypixel-app-api.senither.com/leaderboard/history?perPage=10&page=1")) + fetch("https://hypixel-app-api.senither.com/leaderboard/stats").json(stats=>{ + this.guildButton.setDesc("§0Guilds tracked: " + numberWithCommas(stats.data.guilds)) + this.playerButton.setDesc("§0Players tracked: " + numberWithCommas(stats.data.players)) + }) - this.leaveAndJoinsBox.clearChildren() - let y = 0 - leaveAndJoins.data.forEach(elm=>{ - this.leaveAndJoinsBox.addChild(new SoopyTextElement().setText(`§1${elm.username} §7${elm.type===0?"joined":"left"} §1${elm.guild_name}`).setLocation(0.05, y, 0.8, 0.1)) - this.leaveAndJoinsBox.addChild(new SoopyTextElement().setText(`§7${timeSince(elm.created_at)} ago`).setLocation(0.8125, y, 0.175, 0.1)) - y += 0.1 + fetch("https://hypixel-app-api.senither.com/leaderboard/history?perPage=10&page=1").json(leaveAndJoins=>{ + this.leaveAndJoinsBox.clearChildren() + let y = 0 + leaveAndJoins.data.forEach(elm=>{ + this.leaveAndJoinsBox.addChild(new SoopyTextElement().setText(`§1${elm.username} §7${elm.type===0?"joined":"left"} §1${elm.guild_name}`).setLocation(0.05, y, 0.8, 0.1)) + this.leaveAndJoinsBox.addChild(new SoopyTextElement().setText(`§7${timeSince(elm.created_at)} ago`).setLocation(0.8125, y, 0.175, 0.1)) + y += 0.1 + }) }) } onOpen(){ - new Thread(()=>{ - this.loadFirstPageInformation() - }).start() - + this.loadFirstPageInformation() + let sidebar = new SoopyGuiElement().setLocation(0.1,0.1,0.8,0.8).setScrollable(true).enableFrameBuffer() this.openSidebarPage(sidebar) let markdown = new SoopyMarkdownElement().setText("# NOTE: \nAll credit for the idea, design of this gui, and loading of data goes to Senither who made the original leaderboard (https://hypixel-leaderboard.senither.com/)\n\nThis is just a recode of that to allow for checking the leaderboard from in-game") diff --git a/features/spamHider/index.js b/features/spamHider/index.js index 1163116..36c9a95 100644 --- a/features/spamHider/index.js +++ b/features/spamHider/index.js @@ -3,6 +3,7 @@ import SoopyContentChangeEvent from "../../../guimanager/EventListener/SoopyContentChangeEvent"; import Feature from "../../featureClass/class"; import soopyV2Server from "../../socketConnection"; +import { fetch } from "../../utils/networkUtils"; import ToggleSetting from "../settings/settingThings/toggle"; class SpamHider extends Feature { @@ -107,43 +108,44 @@ class SpamHider extends Feature { } loadSpamMessages(){ - let messages = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/spamHiderMessages.json")) - this.hideMessages = messages.hideMessages - this.moveMessages = messages.moveMessages - - this.hideMessagesDict = { - all: [] - } - - this.hideMessagesRexex = [] - this.hideMessages.forEach(message=>{ - let regex = new RegExp(message.replace(/[\\^$*+?.()|[\]{}]/g, '$&') - .replace(/\$\{\*\}/g, "(?:.+)")) - if(!message.substring(0,5).includes("$")){ - if(!this.hideMessagesDict[message.substring(0,5)]) this.hideMessagesDict[message.substring(0,5)] = [] - this.hideMessagesDict[message.substring(0,5)].push(regex) - }else{ - this.hideMessagesDict.all.push(regex) + fetch("http://soopymc.my.to/api/soopyv2/spamHiderMessages.json").json(messages=>{ + this.hideMessages = messages.hideMessages + this.moveMessages = messages.moveMessages + + this.hideMessagesDict = { + all: [] } - this.hideMessagesRexex.push(regex) - }) - - this.moveMessagesDict = { - all: [] - } - - this.moveMessagesRexex = [] - this.moveMessages.forEach(message=>{ - let regex = new RegExp(message.replace(/[\\^$*+?.()|[\]{}]/g, '$&') - .replace(/\$\{\*\}/g, "(?:.+)")) - - if(!message.substring(0,5).includes("$")){ - if(!this.moveMessagesDict[message.substring(0,5)]) this.moveMessagesDict[message.substring(0,5)] = [] - this.moveMessagesDict[message.substring(0,5)].push(regex) - }else{ - this.moveMessagesDict.all.push(regex) + + this.hideMessagesRexex = [] + this.hideMessages.forEach(message=>{ + let regex = new RegExp(message.replace(/[\\^$*+?.()|[\]{}]/g, '$&') + .replace(/\$\{\*\}/g, "(?:.+)")) + if(!message.substring(0,5).includes("$")){ + if(!this.hideMessagesDict[message.substring(0,5)]) this.hideMessagesDict[message.substring(0,5)] = [] + this.hideMessagesDict[message.substring(0,5)].push(regex) + }else{ + this.hideMessagesDict.all.push(regex) + } + this.hideMessagesRexex.push(regex) + }) + + this.moveMessagesDict = { + all: [] } - this.moveMessagesRexex.push(regex) + + this.moveMessagesRexex = [] + this.moveMessages.forEach(message=>{ + let regex = new RegExp(message.replace(/[\\^$*+?.()|[\]{}]/g, '$&') + .replace(/\$\{\*\}/g, "(?:.+)")) + + if(!message.substring(0,5).includes("$")){ + if(!this.moveMessagesDict[message.substring(0,5)]) this.moveMessagesDict[message.substring(0,5)] = [] + this.moveMessagesDict[message.substring(0,5)].push(regex) + }else{ + this.moveMessagesDict.all.push(regex) + } + this.moveMessagesRexex.push(regex) + }) }) } diff --git a/features/streamsGUI/index.js b/features/streamsGUI/index.js index b9912c2..bc3fa6e 100644 --- a/features/streamsGUI/index.js +++ b/features/streamsGUI/index.js @@ -11,6 +11,7 @@ import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseCl import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"; import BoxWithText from "../../../guimanager/GuiElement/BoxWithText"; import { drawBoxAtBlock } from "../../utils/renderUtils"; +import { fetch } from "../../utils/networkUtils"; class StreamsGui extends Feature { constructor() { @@ -64,22 +65,22 @@ class StreamPage extends GuiPage { } updateStreams(){ - let streams = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/skyblockstreams")) - - this.streamsBox.clearChildren() - - let y = 0 - - Object.keys(streams.twitch).forEach((channel, i)=>{ - let stream = streams.twitch[channel] - - if(i%2===0){ - this.streamsBox.addChild(new StreamElement().setStream(stream, true).setLocation(0, y, 0.45, 0.55).setStreamPage(this)) - } - if(i%2===1){ - this.streamsBox.addChild(new StreamElement().setStream(stream, true).setLocation(0.55, y, 0.45, 0.55).setStreamPage(this)) - y+= 0.6 - } + fetch("http://soopymc.my.to/api/skyblockstreams").json(streams=>{ + this.streamsBox.clearChildren() + + let y = 0 + + Object.keys(streams.twitch).forEach((channel, i)=>{ + let stream = streams.twitch[channel] + + if(i%2===0){ + this.streamsBox.addChild(new StreamElement().setStream(stream, true).setLocation(0, y, 0.45, 0.55).setStreamPage(this)) + } + if(i%2===1){ + this.streamsBox.addChild(new StreamElement().setStream(stream, true).setLocation(0.55, y, 0.45, 0.55).setStreamPage(this)) + y+= 0.6 + } + }) }) } @@ -120,9 +121,7 @@ class StreamPage extends GuiPage { } onOpen(){ - new Thread(()=>{ - this.updateStreams() - }).start() + this.updateStreams() } } diff --git a/features/suggestionsGui/index.js b/features/suggestionsGui/index.js index f74f8c0..5da46d1 100644 --- a/features/suggestionsGui/index.js +++ b/features/suggestionsGui/index.js @@ -16,6 +16,7 @@ import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseCl import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"; import Dropdown from "../../../guimanager/GuiElement/Dropdown"; import SoopyContentChangeEvent from "../../../guimanager/EventListener/SoopyContentChangeEvent"; +import { fetch } from "../../utils/networkUtils"; class SuggestionGui extends Feature { constructor() { @@ -55,11 +56,9 @@ class SuggestionPage extends GuiPage { elm.addEvent(new SoopyKeyPressEvent().setHandler((key, keyId)=>{ if(elm.text.selected && keyId === 28){ - new Thread(()=>{ - this.password = elm.text.text - elm.setText("") - elm.text.selected = false - }).start() + this.password = elm.text.text + elm.setText("") + elm.text.selected = false } })) }else{ @@ -81,141 +80,135 @@ class SuggestionPage extends GuiPage { this.pages[0].addChild(this.suggestionsArea) - this.tags = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/suggestionTags.json")) + fetch("http://soopymc.my.to/api/soopyv2/suggestionTags.json").json(data=>{ + this.tags = data + }) this.finaliseLoading() } loadSuggestionPage(){ - let data = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/suggestion/new")) - - this.suggestionElements = {} - this.suggestionsArea.clearChildren() - - let i = 0 - - data.suggestions.forEach((suggestion) => { - - if(suggestion.status === "pending_review" || suggestion.status === "closed"){ - if(suggestion.uuid !== Player.getUUID().toString().replace(/-/g, "") && Player.getUUID().toString().replace(/-/g, "") !== "dc8c39647b294e03ae9ed13ebd65dd29")return - } - - let box = new SoopyBoxElement().setLocation(0, 0.225 * i, 1, 0.2).setLore(["Click for more information + vote buttons"]) - this.suggestionsArea.addChild(box) - - let title = new SoopyTextElement().setText("§0" + suggestion.title + " §7(" + this.tags.suggestionTags[suggestion.tag] + ")").setMaxTextScale(2).setLocation(0, 0, 0.8,1) - box.addChild(title) - - let popularity = new SoopyTextElement().setText("§0Opinion: " + numberWithCommas(suggestion.likes-suggestion.dislikes)).setMaxTextScale(2).setLocation(0.85,0,0.1,1) - box.addChild(popularity) - - this.suggestionElements[suggestion._id] = { - title: title, - popularity: popularity - } - - box.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - new Thread(()=>{ + fetch("http://soopymc.my.to/api/soopyv2/suggestion/new").json(data=>{ + this.suggestionElements = {} + this.suggestionsArea.clearChildren() + + let i = 0 + + data.suggestions.forEach((suggestion) => { + + if(suggestion.status === "pending_review" || suggestion.status === "closed"){ + if(suggestion.uuid !== Player.getUUID().toString().replace(/-/g, "") && Player.getUUID().toString().replace(/-/g, "") !== "dc8c39647b294e03ae9ed13ebd65dd29")return + } + + let box = new SoopyBoxElement().setLocation(0, 0.225 * i, 1, 0.2).setLore(["Click for more information + vote buttons"]) + this.suggestionsArea.addChild(box) + + let title = new SoopyTextElement().setText("§0" + suggestion.title + " §7(" + this.tags.suggestionTags[suggestion.tag] + ")").setMaxTextScale(2).setLocation(0, 0, 0.8,1) + box.addChild(title) + + let popularity = new SoopyTextElement().setText("§0Opinion: " + numberWithCommas(suggestion.likes-suggestion.dislikes)).setMaxTextScale(2).setLocation(0.85,0,0.1,1) + box.addChild(popularity) + + this.suggestionElements[suggestion._id] = { + title: title, + popularity: popularity + } + + box.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ this.loadSuggestion(suggestion._id) - }).start() - })) - - i++ - }); + })) + + i++ + }); + }) } loadSuggestion(id){ - let data = JSON.parse(FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/suggestion/" + id + "/user/" + Player.getUUID().toString().replace(/-/g,""))) - - let sideBarElm = new SoopyGuiElement().setLocation(0,0,1,1).setScrollable(true) - if(!data.success){ - sideBarElm.addChild(new SoopyTextElement().setText("§cError loading suggestion").setMaxTextScale(3).setLocation(0.5,0.5,0.5,0.5)) - this.openSidebarPage(sideBarElm) - return - } - - this.suggestionElements[id].title.setText("§0" + data.suggestion.title + " §7(" + this.tags.suggestionTags[data.suggestion.tag] + ")") - this.suggestionElements[id].popularity.setText("§0Opinion: " + numberWithCommas(data.suggestion.likes-data.suggestion.dislikes)) - - - let title = new SoopyTextElement().setText("§0" + data.suggestion.title + " §7(" + this.tags.suggestionTags[data.suggestion.tag] + ")").setMaxTextScale(2).setLocation(0.05, 0.05, 0.9,0.1) - sideBarElm.addChild(title) - - if(Player.getUUID().toString().replace(/-/g, "") !== "dc8c39647b294e03ae9ed13ebd65dd29"){ - let suggestor = new SoopyTextElement().setText("§7Suggested by " + data.suggestion.username + " | Status: " + this.tags.statusTags[data.suggestion.status]).setMaxTextScale(1).setLocation(0.05, 0.15, 0.9,0.05) - sideBarElm.addChild(suggestor) - }else{ - let suggestor = new SoopyTextElement().setText("§7Suggested by " + data.suggestion.username + " | Status: ").setMaxTextScale(1).setLocation(0.05, 0.15, 0.6,0.05) - sideBarElm.addChild(suggestor) - - let drop = new Dropdown().setLocation(0.65, 0.13, 0.3, 0.09).setOptions({...this.tags.statusTags,"delete": "Delete"}).setSelectedOption(data.suggestion.status) - sideBarElm.addChild(drop) - - drop.addEvent(new SoopyContentChangeEvent().setHandler((newVal)=>{ - new Thread(()=>{ + fetch("http://soopymc.my.to/api/soopyv2/suggestion/" + id + "/user/" + Player.getUUID().toString().replace(/-/g,"")).json(data=>{ + let sideBarElm = new SoopyGuiElement().setLocation(0,0,1,1).setScrollable(true) + if(!data.success){ + sideBarElm.addChild(new SoopyTextElement().setText("§cError loading suggestion").setMaxTextScale(3).setLocation(0.5,0.5,0.5,0.5)) + this.openSidebarPage(sideBarElm) + return + } + + this.suggestionElements[id].title.setText("§0" + data.suggestion.title + " §7(" + this.tags.suggestionTags[data.suggestion.tag] + ")") + this.suggestionElements[id].popularity.setText("§0Opinion: " + numberWithCommas(data.suggestion.likes-data.suggestion.dislikes)) + + + let title = new SoopyTextElement().setText("§0" + data.suggestion.title + " §7(" + this.tags.suggestionTags[data.suggestion.tag] + ")").setMaxTextScale(2).setLocation(0.05, 0.05, 0.9,0.1) + sideBarElm.addChild(title) + + if(Player.getUUID().toString().replace(/-/g, "") !== "dc8c39647b294e03ae9ed13ebd65dd29"){ + let suggestor = new SoopyTextElement().setText("§7Suggested by " + data.suggestion.username + " | Status: " + this.tags.statusTags[data.suggestion.status]).setMaxTextScale(1).setLocation(0.05, 0.15, 0.9,0.05) + sideBarElm.addChild(suggestor) + }else{ + let suggestor = new SoopyTextElement().setText("§7Suggested by " + data.suggestion.username + " | Status: ").setMaxTextScale(1).setLocation(0.05, 0.15, 0.6,0.05) + sideBarElm.addChild(suggestor) + + let drop = new Dropdown().setLocation(0.65, 0.13, 0.3, 0.09).setOptions({...this.tags.statusTags,"delete": "Delete"}).setSelectedOption(data.suggestion.status) + sideBarElm.addChild(drop) + + drop.addEvent(new SoopyContentChangeEvent().setHandler((newVal)=>{ if(newVal === "delete"){ - FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/suggestion/" + id + "/delete/" + this.password) + fetch("http://soopymc.my.to/api/soopyv2/suggestion/" + id + "/delete/" + this.password).async() this.loadSuggestionPage() this.closeSidebarPage() return } - FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/suggestion/" + id + "/status/" + newVal+ "/" + this.password) + fetch("http://soopymc.my.to/api/soopyv2/suggestion/" + id + "/status/" + newVal+ "/" + this.password).async() this.loadSuggestion(id) - }).start() - })) - } - - let likesText = new SoopyTextElement().setText("§0Dislikes: " + numberWithCommas(data.suggestion.dislikes) + " Likes: " + numberWithCommas(data.suggestion.likes)).setMaxTextScale(1).setLocation(0.35, 0.225, 0.3,0.1) - sideBarElm.addChild(likesText) - if(!data.suggestion.hasDisliked){ - let dislikeButton = new ButtonWithArrow().setDirectionRight(false).setText("§cDislike").setLocation(0.05, 0.225, 0.275,0.1) - sideBarElm.addChild(dislikeButton) - dislikeButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - this.voteSuggestion(id, "dislike") - })) - }else{ - let dislikeButton = new ButtonWithArrow().setDirectionRight(false).setText("§cUndislike").setLocation(0.05, 0.225, 0.275,0.1) - sideBarElm.addChild(dislikeButton) - dislikeButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - this.voteSuggestion(id, "clear") - })) - } - if(!data.suggestion.hasLiked){ - let likeButton = new ButtonWithArrow().setText("§aLike").setLocation(0.675, 0.225, 0.275,0.1) - sideBarElm.addChild(likeButton) - likeButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - this.voteSuggestion(id, "like") - })) - }else{ - let likeButton = new ButtonWithArrow().setText("§aUnlike").setLocation(0.675, 0.225, 0.275,0.1) - sideBarElm.addChild(likeButton) - likeButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - this.voteSuggestion(id, "clear") - })) - } - - - let description = new SoopyMarkdownElement().setText(data.suggestion.description).setLocation(0.05, 0.325, 0.9,0.6) - sideBarElm.addChild(description) - - this.openSidebarPage(sideBarElm) + })) + } + + let likesText = new SoopyTextElement().setText("§0Dislikes: " + numberWithCommas(data.suggestion.dislikes) + " Likes: " + numberWithCommas(data.suggestion.likes)).setMaxTextScale(1).setLocation(0.35, 0.225, 0.3,0.1) + sideBarElm.addChild(likesText) + if(!data.suggestion.hasDisliked){ + let dislikeButton = new ButtonWithArrow().setDirectionRight(false).setText("§cDislike").setLocation(0.05, 0.225, 0.275,0.1) + sideBarElm.addChild(dislikeButton) + dislikeButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + this.voteSuggestion(id, "dislike") + })) + }else{ + let dislikeButton = new ButtonWithArrow().setDirectionRight(false).setText("§cUndislike").setLocation(0.05, 0.225, 0.275,0.1) + sideBarElm.addChild(dislikeButton) + dislikeButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + this.voteSuggestion(id, "clear") + })) + } + if(!data.suggestion.hasLiked){ + let likeButton = new ButtonWithArrow().setText("§aLike").setLocation(0.675, 0.225, 0.275,0.1) + sideBarElm.addChild(likeButton) + likeButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + this.voteSuggestion(id, "like") + })) + }else{ + let likeButton = new ButtonWithArrow().setText("§aUnlike").setLocation(0.675, 0.225, 0.275,0.1) + sideBarElm.addChild(likeButton) + likeButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + this.voteSuggestion(id, "clear") + })) + } + + + let description = new SoopyMarkdownElement().setText(data.suggestion.description).setLocation(0.05, 0.325, 0.9,0.6) + sideBarElm.addChild(description) + + this.openSidebarPage(sideBarElm) + }) } voteSuggestion(id, type){ - new Thread(()=>{ - FileLib.getUrlContent("http://soopymc.my.to/api/soopyv2/suggestion/" + id + "/vote/" + (type) + "/" + Player.getUUID().toString().replace(/-/g,"")) - - this.loadSuggestion(id) - }).start() + fetch("http://soopymc.my.to/api/soopyv2/suggestion/" + id + "/vote/" + (type) + "/" + Player.getUUID().toString().replace(/-/g,"")).async() + + this.loadSuggestion(id) } onOpen(){ - new Thread(()=>{ - this.loadSuggestionPage() - }).start() + this.loadSuggestionPage() } } |