diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-06-02 17:54:59 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-06-02 17:54:59 +0800 |
commit | 7940745eb519224a6826f2b94ab7802cf05d94b8 (patch) | |
tree | 65e1558e2c904c7452b7aa3fb3b03cca201b1581 /features/dataLoader/index.js | |
parent | f1461a7798e688ebfa0c6224688b03b67bc77659 (diff) | |
download | SoopyV2-7940745eb519224a6826f2b94ab7802cf05d94b8.tar.gz SoopyV2-7940745eb519224a6826f2b94ab7802cf05d94b8.tar.bz2 SoopyV2-7940745eb519224a6826f2b94ab7802cf05d94b8.zip |
move loading mayor data to dataLoader
Diffstat (limited to 'features/dataLoader/index.js')
-rw-r--r-- | features/dataLoader/index.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/features/dataLoader/index.js b/features/dataLoader/index.js index 849e0fd..0553b2a 100644 --- a/features/dataLoader/index.js +++ b/features/dataLoader/index.js @@ -24,6 +24,7 @@ class DataLoader extends Feature { this.registerStep(true, 2, this.step) this.registerStep(false, 170, this.loadApiStepThing) + this.registerStep(false, 60 * 5, this.step_5min) this.registerEvent("worldLoad", this.worldLoad) @@ -32,6 +33,8 @@ class DataLoader extends Feature { this.lastServer = undefined this.lastSentServer = 0 + this.currentMayorPerks = new Set() + this.loadedApiDatas = {} this.lastApiData = { @@ -45,9 +48,19 @@ class DataLoader extends Feature { this.loadApi() + this.step_5min() + this.firstLoaded = false } + step_5min() { + fetch("http://soopymc.my.to/api/v2/mayor").json(data => { + if (!data.success) return + this.mayorData = data.data + this.currentMayorPerks = new Set(data.data.mayor.perks.map(a => a.name)) + }) + } + worldLoad() { this.area = undefined this.areaFine = undefined |