aboutsummaryrefslogtreecommitdiff
path: root/features/dataLoader
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-03-27 15:41:20 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-03-27 15:41:20 +0800
commit0cf3a67c2bbd4cdaa5d364436c9153e6456624f1 (patch)
tree03d6b37ee2f4109875050d61d63f363659031e6b /features/dataLoader
parentb94794a3de8827f4bddb5251b010dc32943d79a1 (diff)
downloadSoopyV2-0cf3a67c2bbd4cdaa5d364436c9153e6456624f1.tar.gz
SoopyV2-0cf3a67c2bbd4cdaa5d364436c9153e6456624f1.tar.bz2
SoopyV2-0cf3a67c2bbd4cdaa5d364436c9153e6456624f1.zip
make network requests all go on one permenantly open thread
Diffstat (limited to 'features/dataLoader')
-rw-r--r--features/dataLoader/index.js20
1 files changed, 7 insertions, 13 deletions
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))
- }
+ })
}
}
}