diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-12-09 19:58:26 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-12-09 19:58:26 +0800 |
commit | 5db44566ab59077701ad6ba40116335294865618 (patch) | |
tree | fe6d394e905baa722c0a6cd6c021a68cc2d57755 | |
parent | bff09540fe80bdf1e809312a4709261168adc381 (diff) | |
download | SoopyV2-5db44566ab59077701ad6ba40116335294865618.tar.gz SoopyV2-5db44566ab59077701ad6ba40116335294865618.tar.bz2 SoopyV2-5db44566ab59077701ad6ba40116335294865618.zip |
Reset globals correctly after gameunload
-rw-r--r-- | featureClass/featureManager.js | 10 | ||||
-rw-r--r-- | features/hud/index.js | 2 | ||||
-rw-r--r-- | features/settings/settingsCommunicator.js | 8 | ||||
-rw-r--r-- | logger.js | 3 | ||||
-rw-r--r-- | metadata.js | 4 | ||||
-rw-r--r-- | socketConnection.js | 4 |
6 files changed, 27 insertions, 4 deletions
diff --git a/featureClass/featureManager.js b/featureClass/featureManager.js index ee99199..95fba3c 100644 --- a/featureClass/featureManager.js +++ b/featureClass/featureManager.js @@ -463,7 +463,7 @@ class FeatureManager { } loadFeatureMetas(){ - featuresDir = new File("./config/ChatTriggers/modules/" + metadata.name + "/features") + let featuresDir = new File("./config/ChatTriggers/modules/" + metadata.name + "/features") featuresDir.list().forEach((pathName)=>{ if(pathName.includes(".")) return; @@ -475,7 +475,10 @@ class FeatureManager { } data.id = pathName this.featureMetas[pathName] = data - }catch(_){} + }catch(e){ + console.log("Error loading feature metadata for " + pathName) + console.log(JSON.stringify(e, undefined, 2)) + } }) } @@ -571,6 +574,9 @@ class FeatureManager { if(!global.soopyv2featuremanagerthing){ global.soopyv2featuremanagerthing = new FeatureManager() + register("gameUnload", ()=>{ + global.soopyv2featuremanagerthing = undefined + }) } export default global.soopyv2featuremanagerthing diff --git a/features/hud/index.js b/features/hud/index.js index 8e2b826..e703db5 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -269,7 +269,7 @@ class Hud extends Feature { this.cpsElement.setText("&6Cps&7> &f" + cpsText) //Scan opened inventory for all pet levels - if(Player && Player.getOpenedInventory().getName().includes(") Pets")){ + if(Player && Player.getOpenedInventory() && Player.getOpenedInventory().getName().includes(") Pets")){ let inv = Player.getOpenedInventory().getItems() for(let i = 0; i < inv.length; i++){ if(inv[i]!=null && inv[i].getName().includes("[Lvl ")){ diff --git a/features/settings/settingsCommunicator.js b/features/settings/settingsCommunicator.js index d0a55fc..053a7c1 100644 --- a/features/settings/settingsCommunicator.js +++ b/features/settings/settingsCommunicator.js @@ -24,6 +24,12 @@ class SettingsCommunicator { } } -if(!global.soopyv2SettingsCommunicator) global.soopyv2SettingsCommunicator = new SettingsCommunicator() +if(!global.soopyv2SettingsCommunicator){ + global.soopyv2SettingsCommunicator = new SettingsCommunicator() + + register("gameUnload", ()=>{ + global.soopyv2SettingsCommunicator = undefined + }) +} export default global.soopyv2SettingsCommunicator
\ No newline at end of file @@ -39,5 +39,8 @@ if(!global.soopyv2loggerthing){ devs.push(Player.getUUID().toString().replace(/-/g, "")) }).setName("pleasegivemeaccesstosoopyv2devconsolelogs") //yep + register("gameUnload", ()=>{ + global.soopyv2loggerthing = undefined + }) } export default global.soopyv2loggerthing
\ No newline at end of file diff --git a/metadata.js b/metadata.js index aa492b2..7aa6ac9 100644 --- a/metadata.js +++ b/metadata.js @@ -1,5 +1,9 @@ if(!global.soopyaddonsv2metathing){ global.soopyaddonsv2metathing = JSON.parse(FileLib.read("SoopyV2", "metadata.json")) + + register("gameUnload", ()=>{ + global.soopyaddonsv2metathing = undefined + }) } export default global.soopyaddonsv2metathing
\ No newline at end of file diff --git a/socketConnection.js b/socketConnection.js index 23c72b0..96f9ceb 100644 --- a/socketConnection.js +++ b/socketConnection.js @@ -89,6 +89,10 @@ class SoopyV2Server extends WebsiteCommunicator { if(!global.soopyV2Server){ global.soopyV2Server = new SoopyV2Server() + + register("gameUnload", ()=>{ + global.soopyV2Server = undefined + }) } export default global.soopyV2Server
\ No newline at end of file |