aboutsummaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
Diffstat (limited to 'features')
-rw-r--r--features/changeLogGUI/index.js17
-rw-r--r--features/cosmetics/index.js7
-rw-r--r--features/dataLoader/index.js20
-rw-r--r--features/events/index.js14
-rw-r--r--features/globalSettings/index.js139
-rw-r--r--features/hud/index.js10
-rw-r--r--features/networthGUI/index.js183
-rw-r--r--features/senitherGui/index.js97
-rw-r--r--features/spamHider/index.js72
-rw-r--r--features/streamsGUI/index.js37
-rw-r--r--features/suggestionsGui/index.js225
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 "../../../guimana