diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-06-09 17:31:08 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-06-09 17:31:08 +0800 |
commit | eedf2e6b47ea57d87065af4a71a1ab61c088d7a2 (patch) | |
tree | 3daf7f87a4b764c4f88e3f04c5c358bb113abdbe | |
parent | d75bd7bacbd535951fbef392873df32f17801161 (diff) | |
download | SoopyV2-eedf2e6b47ea57d87065af4a71a1ab61c088d7a2.tar.gz SoopyV2-eedf2e6b47ea57d87065af4a71a1ab61c088d7a2.tar.bz2 SoopyV2-eedf2e6b47ea57d87065af4a71a1ab61c088d7a2.zip |
+ make soulflow overlay use new soulflow api
+ util library for delaying function calls
-rw-r--r-- | features/hud/index.js | 27 | ||||
-rw-r--r-- | utils/delayUtils.js | 29 |
2 files changed, 33 insertions, 23 deletions
diff --git a/features/hud/index.js b/features/hud/index.js index 11c2554..a889345 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -121,7 +121,7 @@ class Hud extends Feature { this.witherImpactCooldownSetting = new ToggleSetting("Show Wither Impact Cooldown", "This will render a small cooldown above your crosshair", true, "wither_impact_cooldown_enabled", this) - this.guidedSheepCooldownSetting = new ToggleSetting("Show Guided Sheep / Explosive Shot Cooldown", "This will render a small cooldown below your crosshair", true, "guided_sheep_cooldown_enabled", this) + // this.guidedSheepCooldownSetting = new ToggleSetting("Show Guided Sheep / Explosive Shot Cooldown", "This will render a small cooldown below your crosshair", true, "guided_sheep_cooldown_enabled", this) this.showSpotifyPlaying = new ToggleSetting("Show Current Playing Spotify Song", "(WINDOWS + Spotify Desktop only)", false, "spotify_now_playing", this) this.spotifyElement = new HudTextElement() @@ -552,32 +552,13 @@ class Hud extends Feature { data.profiles.forEach(p => { if (!this.lastStatData || (p.members[Player.getUUID().toString().replace(/-/g, "")] && p.members[Player.getUUID().toString().replace(/-/g, "")].last_save > this.lastStatData.last_save)) { this.lastStatData = p.members[Player.getUUID().toString().replace(/-/g, "")] - this.lastStatData.itemsData = {} - - if (this.lastStatData?.talisman_bag && this.lastStatData?.talisman_bag?.data) { - let nbtTagCompound = CompressedStreamTools[m.readCompressed](new ByteArrayInputStream(Base64.getDecoder().decode(this.lastStatData.talisman_bag.data))); - - this.lastStatData.itemsData.talisman_bag = new NBTTagCompound(nbtTagCompound) - } } }) - if (this.lastStatData.itemsData.talisman_bag) { - let isSoulflowCounting = false - this.lastStatData.itemsData.talisman_bag.toString().split(",").forEach(line => { //omega scuffed because i cba actually using the nbt like a normal person - if (isSoulflowCounting) { - this.lastStatData._soulflow *= 1000 - this.lastStatData._soulflow += parseInt(ChatLib.removeFormatting(line.split(` `)[0]).replace(/[^0-9]/g, "")) - isSoulflowCounting = !line.endsWith(`Soulflow"`) - } - if (line.startsWith(`display:{Lore:[0:"§7Internalized:`) || line.startsWith(`4:"§7Internalized:`)) { - isSoulflowCounting = !line.endsWith(`Soulflow"`) - this.lastStatData._soulflow = parseInt(ChatLib.removeFormatting(line.split(`"§7Internalized: `)[1])) + if (this.lastStatData) { + if (this.lastStatData.soulflow) this.apiSoulflow = true - this.apiSoulflow = true - } - }) - if (this.apiSoulflow) this.soulflowElement.setText("&6Soulflow&7> &f" + this.numberUtils.numberWithCommas(this.lastStatData._soulflow)) + if (this.apiSoulflow) this.soulflowElement.setText("&6Soulflow&7> &f" + this.numberUtils.numberWithCommas(this.lastStatData.soulflow)) } this.updateHudThingos() diff --git a/utils/delayUtils.js b/utils/delayUtils.js new file mode 100644 index 0000000..4c66d0f --- /dev/null +++ b/utils/delayUtils.js @@ -0,0 +1,29 @@ +const { default: FlatQueue } = require("../datastructures/flatqueue") + +if (!global.delayThingSoopy) { + + let functionQueue = new FlatQueue() + let functions = new Map() + let functionId = 0 + + function delay(time, callback) { + let id = functionId++ + functionQueue.push(id, Date.now() + time) + functions.set(id, callback) + } + + register("tick", () => { + while (functionQueue.length > 0 && Date.now() > functionQueue.peekValue()) { + let id = functionQueue.pop() + + functions.get(id)() + functions.delete(id) + } + }) + + global.delayThingSoopy = { + delay + } +} + +module.exports = global.delayThingSoopy |