From 1ecfecc53f68a9ee371bf105eb8a656e0a98c5b3 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Tue, 11 Jan 2022 05:03:00 +0800 Subject: + Warning message when cannot connect to soopy server + Museum gui performance improvements + HUD api stat thingo + Settings for slayer features actually toggle things + Stat next to name loading time optimisations (should help if you are in a party) --- features/betterGuis/museumGui.js | 10 ++- features/dataLoader/index.js | 8 ++ features/hud/index.js | 144 ++++++++++++++++++++++++++++++++++++ features/slayers/index.js | 28 +++---- features/stat_next_to_name/index.js | 6 +- 5 files changed, 180 insertions(+), 16 deletions(-) (limited to 'features') diff --git a/features/betterGuis/museumGui.js b/features/betterGuis/museumGui.js index 0faa2f0..47e29d2 100644 --- a/features/betterGuis/museumGui.js +++ b/features/betterGuis/museumGui.js @@ -251,8 +251,16 @@ class MuseumGui { this.itemsBox = new SoopyBoxElement().setLocation(0.5-widthPer*3/2, 0.35, widthPer*3, 0.6).enableFrameBuffer() this.mainPage.addChild(this.itemsBox) - new Array(this.donateBox, this.favoriteBox).forEach((box, i)=>{ + new Array(this.donateBox, this.favoriteBox, this.itemsBox).forEach((box, i)=>{ box.addEvent(new SoopyHoverChangeEvent().setHandler((hovered)=>{ + if(i===2){ + if(this.searchText){ + + }else{ + box.enableFrameBuffer() + return + } + } if(hovered){ box.disableFrameBuffer() }else{ diff --git a/features/dataLoader/index.js b/features/dataLoader/index.js index e24c34c..9389c03 100644 --- a/features/dataLoader/index.js +++ b/features/dataLoader/index.js @@ -22,6 +22,8 @@ class DataLoader extends Feature { this.api_loaded_event = this.createCustomEvent("apiLoad") + this.loadedApiDatas = {} + this.lastApiData = { "skyblock": undefined, "player": undefined, @@ -52,6 +54,12 @@ class DataLoader extends Feature { let key = this.FeatureManager.features["globalSettings"].class.apiKeySetting.getValue() if(!key) return + if(this.loadedApiDatas[type] !== undefined){ + if(Date.now()-this.loadedApiDatas[type] < 5000) return + } + + this.loadedApiDatas[type] = Date.now() + if(soopyServer){ }else{ diff --git a/features/hud/index.js b/features/hud/index.js index 777783e..a4e594e 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -6,6 +6,9 @@ import { m } from "../../../mappings/mappings"; import LocationSetting from "../settings/settingThings/location"; import ToggleSetting from "../settings/settingThings/toggle"; import HudTextElement from "./HudTextElement"; +import DropdownSetting from "../settings/settingThings/dropdownSetting"; +import { getLevelByXp } from "../../utils/statUtils"; +import { firstLetterCapital } from "../../utils/stringUtils"; class Hud extends Feature { constructor() { @@ -103,6 +106,54 @@ class Hud extends Feature { 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) + let hudStatTypes = { + "cata": "Catacombs level + Exp", + "totaldeaths": "Total deaths" + } + + this.skillLevelCaps = { + "experience_skill_combat": 60, + "experience_skill_foraging": 50, + "experience_skill_farming": 60, + "experience_skill_fishing": 50, + "experience_skill_alchemy": 50, + "experience_skill_enchanting": 60, + "experience_skill_mining": 60, + "experience_skill_taming": 50, + }; + + Object.keys(this.skillLevelCaps).forEach(skill => { + hudStatTypes[skill] = firstLetterCapital(skill.split("_").pop()) + " level + Exp" + }) + + hudStatTypes.completions_enterance = "Enterance completions" + for(let i = 1;i<8;i++){ + hudStatTypes["completions_floor_"+i] = "Floor " + i + " completions" + } + for(let i = 1;i<7;i++){ + hudStatTypes["completions_master_"+i] = "Master " + i + " completions" + } + for(let i = 1;i<8;i++){ + hudStatTypes["completions_dungeon_"+i] = "Dungeon " + i + " completions" + } + + this.hudStat = [] + for(let i = 0;i<5;i++){ + this.hudStat[i] = {} + this.hudStat[i].enabled = new ToggleSetting("Hud Stat Slot #"+(i+1), "Allows you to render a custom stat on your hud", false, "hud_stat_"+i, this) + this.hudStat[i].type = new DropdownSetting("Hud Stat Slot #" + (i + 1) + " Type", "The type of stat to render", "weight" , "hud_stat_" + i + "_type", this, hudStatTypes) + this.hudStat[i].location = new LocationSetting("Hud Stat Slot #"+(i+1)+" Location", "Allows you to edit the location of the hud stat", "hud_stat_"+i+"_location", this, [10, 50+i*10, 1, 1]).editTempText("&6Hud Stat&7> &f12,345") + this.hudStat[i].textElement = new HudTextElement().setToggleSetting(this.hudStat[i].enabled).setLocationSetting(this.hudStat[i].location).setText("&6Hud Stat&7> &fLoading...") + this.hudStat[i].onlySb = new ToggleSetting("Hud Stat Slot #"+(i+1)+" Only SB", "Only render this stat when you are in skyblock", true, "hud_stat_"+i+"_only_sb", this).requires(this.hudStat[i].enabled) + + this.hudStat[i].location.requires(this.hudStat[i].enabled) + this.hudStat[i].type.requires(this.hudStat[i].enabled) + if(this.hudStat[i-1]){ + this.hudStat[i].enabled.requires(this.hudStat[i-1].enabled) + } + } + + // this.showDragonDamages = new ToggleSetting("Show dragon damages", "This will render the top 3 damages + your damage during a dragon fight", true, "dragon_dmg_enable", this).requires(this.soulflowEnabledSetting) // this.dragonDamageElement = new HudTextElement() // .setToggleSetting(this.showDragonDamages) @@ -126,6 +177,10 @@ class Hud extends Feature { this.lastAbsorbtion = 0 this.impactTest = false + this.lastUpdatedStatData = 0 + + this.lastStatData = undefined + this.lastFrameRates = [0,0,0,0,0,0,0,0,0,0] this.lastFrameRatesS = [0,0,0,0,0,0,0,0,0,0] @@ -138,6 +193,7 @@ class Hud extends Feature { this.registerStep(true, 5, this.step) this.registerStep(false, 5, this.step_5second) this.registerEvent("renderWorld", this.renderWorld) + this.registerEvent("worldLoad", this.worldLoad) this.petLevels = {} this.petText = "" @@ -172,6 +228,9 @@ class Hud extends Feature { this.lastSwappedPet = Date.now() } + if(this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock_raw){ + this.apiLoad(this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock_raw, "skyblock", false, true) + } this.registerActionBar("${m}", this.actionbarMessage) } @@ -203,6 +262,10 @@ class Hud extends Feature { Renderer.drawString(Math.max(0,Math.ceil((5000-(Date.now()-this.lastWitherImpact))/1000)) + "s", Renderer.screen.getWidth() / 2 - Renderer.getStringWidth(Math.max(0,Math.ceil((5000-(Date.now()-this.lastWitherImpact))/1000)) + "s") / 2, Renderer.screen.getHeight() / 2 - 15) } + + this.hudStat.forEach(stat=>{ + stat.textElement.render() + }) } renderWorld(){ @@ -233,6 +296,7 @@ class Hud extends Feature { } step(){ + this.updateHudThingos() let fps = 0 if(this.fpsEnabledSetting.getValue() && this.fpsFastSetting.getValue()){ @@ -305,6 +369,7 @@ class Hud extends Feature { } step_5second(){ + if(!this.soulflowEnabledSetting.getValue()) return if(!Player.getPlayer()) return if(!Player.getInventory()) return @@ -352,7 +417,82 @@ class Hud extends Feature { this.soulflowElement.setText("&6Soulflow&7> &f" + this.numberUtils.numberWithCommas(soulflowCount)) } + statApiLoadThingo(data){ + 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.updateHudThingos() + } + + 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.lastUpdatedStatData = Date.now() + return + } + + this.hudStat.forEach(stat=>{ + if(stat.enabled.getValue()){ + this.updateHudThing(stat, insb) + } + }) + } + + updateHudThing(thing, insb){ + if(!this.lastStatData) return + + if(!insb && thing.onlySb.getValue()){ + thing.textElement.setText("") + return + } + + let type = thing.type.getValue() + + let string = "Unknown stat" + if(type === "totaldeaths"){ + string = "&6Deaths&7> &f" + this.numberUtils.numberWithCommas(this.lastStatData.death_count) + } + if(type === "cata"){ + let cataData = getLevelByXp(this.lastStatData.dungeons.dungeon_types.catacombs.experience, 2, 50) + string = "&6Cata&7> &f" + (cataData.level+cataData.progress).toFixed(2) + " &7(" + this.numberUtils.numberWithCommas(cataData.xpCurrent) + (cataData.level===50?"":"/" + this.numberUtils.numberWithCommas(cataData.xpForNext)) + ")" + } + + Object.keys(this.skillLevelCaps).forEach(skill => { + if(type === skill){ + let skillData = getLevelByXp(this.lastStatData[skill], 0, this.skillLevelCaps[skill]) + string = "&6" + firstLetterCapital(skill.split("_").pop()) + "&7> &f" + (skillData.level+skillData.progress).toFixed(2) + " &7(" + this.numberUtils.numberWithCommas(skillData.xpCurrent) + (skillData.level===this.skillLevelCaps[skill]?"":"/" + this.numberUtils.numberWithCommas(skillData.xpForNext)) + ")" + } + }) + + if(type === "completions_enterance"){ + string = "&6E Comps&7> &f" + this.numberUtils.numberWithCommas((this.lastStatData.dungeons?.dungeon_types?.catacombs?.tier_completions?.[0]||0)) + } + if(type.startsWith("completions_floor_")){ + let floor = parseInt(type.split("_").pop()) + string = "&6F" + floor +" Comps&7> &f" + this.numberUtils.numberWithCommas((this.lastStatData.dungeons?.dungeon_types?.catacombs?.tier_completions?.[floor]||0)) + } + if(type.startsWith("completions_master_")){ + let floor = parseInt(type.split("_").pop()) + string = "&6F" + floor +" Comps&7> &f" + this.numberUtils.numberWithCommas((this.lastStatData.dungeons?.dungeon_types?.master_catacombs?.tier_completions?.[floor]||0)) + } + if(type.startsWith("completions_dungeon_")){ + let floor = parseInt(type.split("_").pop()) + string = "&6Dungeon " + floor +" Comps&7> &f" + this.numberUtils.numberWithCommas((this.lastStatData.dungeons?.dungeon_types?.catacombs?.tier_completions?.[floor]||0)+(this.lastStatData.dungeons?.dungeon_types?.master_catacombs?.tier_completions?.[floor]||0)) + } + + thing.textElement.setText(string) + } + apiLoad(data, dataType, isSoopyServer, isLatest){ + if(dataType === "skyblock" && !isSoopyServer){ + this.statApiLoadThingo(data) + } if(!isSoopyServer || !isLatest) return if(dataType !== "skyblock") return @@ -376,6 +516,10 @@ class Hud extends Feature { this.petElement.setText("&6Pet&7> &7[Lvl " + pet.level.level + "] " + petTierColor[pet.tier] + pet.name) this.petText = "&6Pet&7> &7[Lvl " + pet.level.level + "] " + petTierColor[pet.tier] + pet.name } + + worldLoad(){ + this.lastUpdatedStatData = 0 + } } module.exports = { diff --git a/features/slayers/index.js b/features/slayers/index.js index 8827343..8035953 100644 --- a/features/slayers/index.js +++ b/features/slayers/index.js @@ -120,17 +120,22 @@ class Slayers extends Feature { renderWorld(ticks){ - if(this.emanBoss) drawBoxAtEntity(this.emanBoss, 0, 255, 0, 1, -3, ticks, 4, false) - - Object.values(this.beaconPoints).forEach(line=>{ - let lastPoint = undefined - line.forEach(p=>{ - if(lastPoint){ - drawLine(lastPoint[0], lastPoint[1], lastPoint[2], p[0], p[1], p[2], 0, 0, 255, 3) - } - lastPoint = p + if(this.emanBoss && this.boxAroundEmanBoss.getValue()) drawBoxAtEntity(this.emanBoss, 0, 255, 0, 1, -3, ticks, 4, false) + + if(this.boxToEmanBeacon.getValue()){ + Object.values(this.beaconPoints).forEach(line=>{ + let lastPoint = undefined + line.forEach(p=>{ + if(lastPoint){ + drawLine(lastPoint[0], lastPoint[1], lastPoint[2], p[0], p[1], p[2], 0, 0, 255, 3) + } + lastPoint = p + }) }) - }) + Object.values(this.beaconLocations).forEach(loc=>{ + drawFilledBox(loc[0]+0.5, loc[1], loc[2]+0.5, 1.01, 1.01, 0, 0, 1, 1, true) + }) + } this.eyeE.forEach(e=>{ let x = e.getX() + ((e.getX()-e.getLastX())*ticks) @@ -140,9 +145,6 @@ class Slayers extends Feature { drawBoxAtBlock(x-0.5, y+0.7, z-0.5, 255, 0, 0) }) - Object.values(this.beaconLocations).forEach(loc=>{ - drawFilledBox(loc[0]+0.5, loc[1], loc[2]+0.5, 1.01, 1.01, 0, 0, 1, 1, true) - }) } entityJoinWorldEvent(event){ diff --git a/features/stat_next_to_name/index.js b/features/stat_next_to_name/index.js index c76ecd7..c38fcc7 100644 --- a/features/stat_next_to_name/index.js +++ b/features/stat_next_to_name/index.js @@ -29,6 +29,7 @@ class StatNextToName extends Feature { "networth": "small" } + this.oldUserStats = {} this.userStats = {} this.loadingStats = [] @@ -45,7 +46,7 @@ class StatNextToName extends Feature { let nearestDistance = Infinity World.getAllPlayers().forEach(player => { - if(this.userStats[player.getUUID().toString().replace(/-/g, "")]){ + if(this.userStats[player.getUUID().toString().replace(/-/g, "")] || this.oldUserStats[player.getUUID().toString().replace(/-/g, "")]){ this.updatePlayerNametag(player) return } @@ -67,6 +68,7 @@ class StatNextToName extends Feature { worldLoad(){ let playerStats = this.userStats[Player.getUUID().toString().replace(/-/g, "")] + this.oldUserStats = this.userStats this.userStats = {} this.loadingStats = [] if(playerStats){ @@ -75,7 +77,7 @@ class StatNextToName extends Feature { } updatePlayerNametag(player){ - let stats = this.userStats[player.getUUID().toString().replace(/-/g, "")] + let stats = this.userStats[player.getUUID().toString().replace(/-/g, "")] || this.oldUserStats[player.getUUID().toString().replace(/-/g, "")] let nameTagString = player.getName() -- cgit