From 431e4fc9d1657a50ebc34b8ac24f9bfaea06417f Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Sat, 17 Sep 2022 19:39:05 +0800 Subject: Initial move to babel + change fetch to use async/await --- src/features/bestiary/index.js | 250 ++++ src/features/bestiary/metadata.json | 8 + src/features/betterGuis/dungeonReadyGui.js | 284 +++++ src/features/betterGuis/index.js | 386 ++++++ src/features/betterGuis/metadata.json | 8 + src/features/betterGuis/museumGui.js | 1024 ++++++++++++++++ src/features/changeLogGUI/index.js | 255 ++++ src/features/changeLogGUI/metadata.json | 8 + src/features/cosmetics/cosmetic.js | 29 + .../cosmetics/cosmetic/dragon/dragonWings.js | 482 ++++++++ src/features/cosmetics/hiddenRequirement.js | 4 + src/features/cosmetics/index.js | 271 ++++ src/features/cosmetics/metadata.json | 8 + src/features/dataLoader/index.js | 280 +++++ src/features/dataLoader/metadata.json | 8 + src/features/dungeonMap/dungeonBossImages/f1.png | Bin 0 -> 4681 bytes src/features/dungeonMap/index.js | 1186 ++++++++++++++++++ src/features/dungeonMap/map.png | Bin 0 -> 5648 bytes src/features/dungeonMap/metadata.json | 8 + src/features/dungeonMap2/DungeonMapData.js | 513 ++++++++ src/features/dungeonMap2/DungeonMapRoom.js | 256 ++++ src/features/dungeonMap2/DungeonRoomStaticData.js | 19 + src/features/dungeonMap2/index.js | 312 +++++ src/features/dungeonMap2/metadata.json | 8 + src/features/dungeonRoutes/index.js | 481 ++++++++ src/features/dungeonRoutes/metadata.json | 8 + src/features/dungeonRoutes/routesData.json | 1296 ++++++++++++++++++++ src/features/dungeonSolvers/f7data.json | 263 ++++ src/features/dungeonSolvers/index.js | 1270 +++++++++++++++++++ src/features/dungeonSolvers/metadata.json | 8 + src/features/events/index.js | 816 ++++++++++++ src/features/events/metadata.json | 8 + src/features/eventsGUI/index.js | 287 +++++ src/features/eventsGUI/metadata.json | 8 + src/features/featureBase/index.js | 24 + src/features/featureBase/metadata.json | 8 + src/features/fpsImproveGui/index.js | 49 + src/features/fpsImproveGui/metadata.json | 8 + src/features/fragBot/index.js | 84 ++ src/features/fragBot/metadata.json | 8 + src/features/friendsGUI/index.js | 363 ++++++ src/features/friendsGUI/metadata.json | 8 + src/features/globalSettings/firstLoadPage.js | 42 + src/features/globalSettings/firstLoadPages.js | 135 ++ src/features/globalSettings/index.js | 1121 +++++++++++++++++ src/features/globalSettings/metadata.json | 8 + src/features/globalSettings/warps.json | 41 + src/features/guild/index.js | 70 ++ src/features/guild/metadata.json | 8 + src/features/hud/HudTextElement.js | 143 +++ src/features/hud/index.js | 812 ++++++++++++ src/features/hud/metadata.json | 8 + src/features/lockedFeatures/index.js | 121 ++ src/features/lockedFeatures/metadata.json | 8 + src/features/mining/coords.json | 202 +++ src/features/mining/index.js | 469 +++++++ src/features/mining/metadata.json | 8 + src/features/nether/index.js | 406 ++++++ src/features/nether/metadata.json | 8 + src/features/networthGUI/index.js | 239 ++++ src/features/networthGUI/metadata.json | 8 + src/features/performance/hiddenRequirement.js | 7 + src/features/performance/index.js | 128 ++ src/features/performance/metadata.json | 8 + src/features/senitherGui/index.js | 453 +++++++ src/features/senitherGui/metadata.json | 8 + src/features/settings/helpDataLoader.js | 50 + src/features/settings/index.js | 332 +++++ src/features/settings/locationSettingHolder.js | 27 + src/features/settings/metadata.json | 8 + .../settings/settingThings/FakeRequireToggle.js | 27 + src/features/settings/settingThings/button.js | 18 + .../settings/settingThings/dropdownSetting.js | 41 + .../settings/settingThings/imageLocation.js | 321 +++++ src/features/settings/settingThings/location.js | 340 +++++ src/features/settings/settingThings/settingBase.js | 162 +++ src/features/settings/settingThings/textSetting.js | 41 + src/features/settings/settingThings/toggle.js | 62 + src/features/settings/settingsCommunicator.js | 35 + src/features/slayers/index.js | 1022 +++++++++++++++ src/features/slayers/metadata.json | 8 + src/features/soopyGui/GuiPage.js | 68 + src/features/soopyGui/categoryManager.js | 37 + src/features/soopyGui/index.js | 215 ++++ src/features/soopyGui/metadata.json | 8 + src/features/spamHider/index.js | 351 ++++++ src/features/spamHider/metadata.json | 8 + src/features/specialMining/index.js | 461 +++++++ src/features/specialMining/metadata.json | 8 + src/features/statHistoryGui/index.js | 189 +++ src/features/statHistoryGui/metadata.json | 8 + src/features/stat_next_to_name/index.js | 193 +++ src/features/stat_next_to_name/metadata.json | 8 + src/features/streamsGUI/index.js | 181 +++ src/features/streamsGUI/metadata.json | 8 + src/features/suggestionsGui/index.js | 217 ++++ src/features/suggestionsGui/metadata.json | 8 + src/features/waypoints/index.js | 323 +++++ src/features/waypoints/metadata.json | 8 + src/features/waypoints/minewaypoints_socket.js | 49 + src/features/waypoints/pathfind.js | 96 ++ 101 files changed, 20003 insertions(+) create mode 100644 src/features/bestiary/index.js create mode 100644 src/features/bestiary/metadata.json create mode 100644 src/features/betterGuis/dungeonReadyGui.js create mode 100644 src/features/betterGuis/index.js create mode 100644 src/features/betterGuis/metadata.json create mode 100644 src/features/betterGuis/museumGui.js create mode 100644 src/features/changeLogGUI/index.js create mode 100644 src/features/changeLogGUI/metadata.json create mode 100644 src/features/cosmetics/cosmetic.js create mode 100644 src/features/cosmetics/cosmetic/dragon/dragonWings.js create mode 100644 src/features/cosmetics/hiddenRequirement.js create mode 100644 src/features/cosmetics/index.js create mode 100644 src/features/cosmetics/metadata.json create mode 100644 src/features/dataLoader/index.js create mode 100644 src/features/dataLoader/metadata.json create mode 100644 src/features/dungeonMap/dungeonBossImages/f1.png create mode 100644 src/features/dungeonMap/index.js create mode 100644 src/features/dungeonMap/map.png create mode 100644 src/features/dungeonMap/metadata.json create mode 100644 src/features/dungeonMap2/DungeonMapData.js create mode 100644 src/features/dungeonMap2/DungeonMapRoom.js create mode 100644 src/features/dungeonMap2/DungeonRoomStaticData.js create mode 100644 src/features/dungeonMap2/index.js create mode 100644 src/features/dungeonMap2/metadata.json create mode 100644 src/features/dungeonRoutes/index.js create mode 100644 src/features/dungeonRoutes/metadata.json create mode 100644 src/features/dungeonRoutes/routesData.json create mode 100644 src/features/dungeonSolvers/f7data.json create mode 100644 src/features/dungeonSolvers/index.js create mode 100644 src/features/dungeonSolvers/metadata.json create mode 100644 src/features/events/index.js create mode 100644 src/features/events/metadata.json create mode 100644 src/features/eventsGUI/index.js create mode 100644 src/features/eventsGUI/metadata.json create mode 100644 src/features/featureBase/index.js create mode 100644 src/features/featureBase/metadata.json create mode 100644 src/features/fpsImproveGui/index.js create mode 100644 src/features/fpsImproveGui/metadata.json create mode 100644 src/features/fragBot/index.js create mode 100644 src/features/fragBot/metadata.json create mode 100644 src/features/friendsGUI/index.js create mode 100644 src/features/friendsGUI/metadata.json create mode 100644 src/features/globalSettings/firstLoadPage.js create mode 100644 src/features/globalSettings/firstLoadPages.js create mode 100644 src/features/globalSettings/index.js create mode 100644 src/features/globalSettings/metadata.json create mode 100644 src/features/globalSettings/warps.json create mode 100644 src/features/guild/index.js create mode 100644 src/features/guild/metadata.json create mode 100644 src/features/hud/HudTextElement.js create mode 100644 src/features/hud/index.js create mode 100644 src/features/hud/metadata.json create mode 100644 src/features/lockedFeatures/index.js create mode 100644 src/features/lockedFeatures/metadata.json create mode 100644 src/features/mining/coords.json create mode 100644 src/features/mining/index.js create mode 100644 src/features/mining/metadata.json create mode 100644 src/features/nether/index.js create mode 100644 src/features/nether/metadata.json create mode 100644 src/features/networthGUI/index.js create mode 100644 src/features/networthGUI/metadata.json create mode 100644 src/features/performance/hiddenRequirement.js create mode 100644 src/features/performance/index.js create mode 100644 src/features/performance/metadata.json create mode 100644 src/features/senitherGui/index.js create mode 100644 src/features/senitherGui/metadata.json create mode 100644 src/features/settings/helpDataLoader.js create mode 100644 src/features/settings/index.js create mode 100644 src/features/settings/locationSettingHolder.js create mode 100644 src/features/settings/metadata.json create mode 100644 src/features/settings/settingThings/FakeRequireToggle.js create mode 100644 src/features/settings/settingThings/button.js create mode 100644 src/features/settings/settingThings/dropdownSetting.js create mode 100644 src/features/settings/settingThings/imageLocation.js create mode 100644 src/features/settings/settingThings/location.js create mode 100644 src/features/settings/settingThings/settingBase.js create mode 100644 src/features/settings/settingThings/textSetting.js create mode 100644 src/features/settings/settingThings/toggle.js create mode 100644 src/features/settings/settingsCommunicator.js create mode 100644 src/features/slayers/index.js create mode 100644 src/features/slayers/metadata.json create mode 100644 src/features/soopyGui/GuiPage.js create mode 100644 src/features/soopyGui/categoryManager.js create mode 100644 src/features/soopyGui/index.js create mode 100644 src/features/soopyGui/metadata.json create mode 100644 src/features/spamHider/index.js create mode 100644 src/features/spamHider/metadata.json create mode 100644 src/features/specialMining/index.js create mode 100644 src/features/specialMining/metadata.json create mode 100644 src/features/statHistoryGui/index.js create mode 100644 src/features/statHistoryGui/metadata.json create mode 100644 src/features/stat_next_to_name/index.js create mode 100644 src/features/stat_next_to_name/metadata.json create mode 100644 src/features/streamsGUI/index.js create mode 100644 src/features/streamsGUI/metadata.json create mode 100644 src/features/suggestionsGui/index.js create mode 100644 src/features/suggestionsGui/metadata.json create mode 100644 src/features/waypoints/index.js create mode 100644 src/features/waypoints/metadata.json create mode 100644 src/features/waypoints/minewaypoints_socket.js create mode 100644 src/features/waypoints/pathfind.js (limited to 'src/features') diff --git a/src/features/bestiary/index.js b/src/features/bestiary/index.js new file mode 100644 index 0000000..da09463 --- /dev/null +++ b/src/features/bestiary/index.js @@ -0,0 +1,250 @@ +/// +/// +import Feature from "../../featureClass/class"; +import { numberWithCommas } from "../../utils/numberUtils"; +import HudTextElement from "../hud/HudTextElement"; +import DropdownSetting from "../settings/settingThings/dropdownSetting"; +import LocationSetting from "../settings/settingThings/location"; +import SettingBase from "../settings/settingThings/settingBase"; +import ToggleSetting from "../settings/settingThings/toggle"; + +let dontUseApi = new Set() +dontUseApi.add("arachne") +dontUseApi.add("barbarian_duke_x") +dontUseApi.add("bladesoul") +dontUseApi.add("mage_outlaw") +dontUseApi.add("ashfang") +dontUseApi.add("magma_cube_boss") +dontUseApi.add("headless_horseman") +dontUseApi.add("dragon") + + +class Bestiary extends Feature { + constructor() { + super() + } + + onEnable() { + this.bestiaryData = JSON.parse(FileLib.read("soopyAddonsData", "bestiaryData.json") || "{}") + this.bestiaryChanged = false + + this.bestiaryApiTracking = {} + + this.registerStep(true, 5, this.scanInv) + this.registerStep(false, 5, this.saveData) + + + this.bestiaryStatTypes = { + "barbarian_duke_x": "Barbarian Duke X" + } + Object.keys(this.bestiaryData).forEach(k => { + if (this.bestiaryData[k].guiName) this.bestiaryStatTypes[k] = this.bestiaryData[k].guiName + }) + + new SettingBase("NOTE: u need to open ur bestiary menu", "before this will work", true, "info_bestiary", this) + this.hudStat = [] + for (let i = 0; i < 10; i++) { + this.hudStat[i] = {} + this.hudStat[i].enabled = new ToggleSetting("Bestiary Slot #" + (i + 1), "Allows you to render a custom besiary kills on your hud", false, "bestiary_stat_" + i, this) + this.hudStat[i].type = new DropdownSetting("Bestiary Slot #" + (i + 1) + " Type", "The bestiary type", "barbarian_duke_x", "bestiary_stat_" + i + "_type", this, this.bestiaryStatTypes) + this.hudStat[i].location = new LocationSetting("Bestiary Slot #" + (i + 1) + " Location", "Allows you to edit the location of the bestiary stat", "bestiary_stat_" + i + "_location", this, [10, 50 + i * 10, 1, 1]).editTempText("&6Bestiary Stat Stat&7> &f12,345") + this.hudStat[i].textElement = new HudTextElement().setToggleSetting(this.hudStat[i].enabled).setLocationSetting(this.hudStat[i].location).setText("&6Bestiary Stat&7> &fLoading...") + this.hudStat[i].onlySb = new ToggleSetting("Bestiary Slot #" + (i + 1) + " Only SB", "Only render this stat when you are in skyblock", true, "bestiary_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.registerStep(false, 5, this.updateHudElements) + let lastThing = undefined + let lastThingTime = 0 + this.registerChat("${chat}", (chat) => { + let thing + switch (chat.trim()) { + case "MAGE OUTLAW DOWN!": + thing = "mage_outlaw" + break; + case "BARBARIAN DUKE X DOWN!": + thing = "barbarian_duke_x" + break; + case "BLADESOUL DOWN!": + thing = "bladesoul" + break; + case "ASHFANG DOWN!": + thing = "ashfang" + break; + // case "MAGMA BOSS DOWN!": + // thing = "magma_cube_boss" + // break; + case "ARACHNE DOWN!": + lastThing = "arachne" + lastThingTime = Date.now() + break; + case "HORSEMAN DOWN!": + lastThing = "arachne" + lastThingTime = Date.now() + break; + default: + break; + } + if (chat.includes("DRAGON")) { + lastThing = "dragon" + lastThingTime = Date.now() + } + + if (chat.trim().startsWith("Your Damage: ")) { + let dmg = parseInt(chat.trim().split("Your Damage: ")[1].split(" ")[0]) + if (dmg > 0 && Date.now() - lastThingTime < 1000) { + thing = lastThing + lastThing = "" + lastThingTime = 0 + } + } + + if (thing) { + this.bestiaryData[thing].guessCount++ + this.bestiaryChanged = true + } + }) + this.registerSoopy("apiLoad", this.apiLoad); + + if (this.FeatureManager.features["dataLoader"] && this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock_raw) { + this.apiLoad(this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock_raw, "skyblock", false, true); + } + } + + getBestiaryCount(id) { + if (!this.bestiaryData[id]) return "???" + let count = this.bestiaryData[id].count + + if (!dontUseApi.has(id)) { + let currApiData = this.bestiaryApiTracking[id] + + count += currApiData - this.bestiaryData[id].apiCount + } + + count += this.bestiaryData[id].guessCount + + return count + } + + updateHudElements() { + if (!this.FeatureManager.features["dataLoader"]) return + + let insb = this.FeatureManager.features["dataLoader"].class.isInSkyblock + + this.hudStat.forEach(stat => { + if (stat.enabled.getValue()) { + if (!insb && stat.onlySb.getValue()) { + stat.textElement.setText("") + return + } + + let type = stat.type.getValue() + + stat.textElement.setText(`&6${this.bestiaryData[type]?.guiName}&7> &f${numberWithCommas(this.getBestiaryCount(type))}`) + } else { + stat.textElement.setText("") + } + }) + } + + apiLoad(data, dataType, isSoopyServer, isLatest) { + if (isSoopyServer || !isLatest) return; + if (dataType !== "skyblock") return; + + let currentProfile = {} + let currentProfileTime = 0 + + data.profiles.forEach(p => { + if (p.members[Player.getUUID().toString().replace(/-/g, "")].last_save > currentProfileTime) { + currentProfileTime = p.members[Player.getUUID().toString().replace(/-/g, "")].last_save + currentProfile = p.members[Player.getUUID().toString().replace(/-/g, "")] + } + }) + + Object.keys(currentProfile.stats).forEach(key => { + if (key.startsWith("kills_")) { + this.bestiaryApiTracking[key.replace("kills_", "")] = currentProfile.stats[key] + } + }) + } + + scanInv() { + if (!Player.getContainer()) return + if (!Player.getContainer().getName().startsWith("Bestiary ➜ ")) return + let tempChanged = false + let seen = new Set() + + for (let item of Player.getContainer().getItems()) { + if (!item) continue + let name = ChatLib.removeFormatting(item.getName()).split(" ") + name.pop() + let apiName = name.join("_").toLowerCase() + if (seen.has(apiName)) continue + seen.add(apiName) + + if (apiName === "skeletor_prime") continue + + if (this.bestiaryApiTracking[apiName] || dontUseApi.has(apiName)) { + + let count = 0 + + for (let l of item.getLore()) { + l = ChatLib.removeFormatting(l) + + if (l.startsWith("Kills: ")) { + count = parseInt(l.split("Kills: ")[1].replace(/,/g, "")) + break; + } + } + + let needsChange = !this.bestiaryData[apiName] || this.bestiaryData[apiName].guiName !== name.join(" ") || this.bestiaryData[apiName].count !== count || this.bestiaryData[apiName].apiCount !== (this.bestiaryApiTracking[apiName] || 0) || this.bestiaryData[apiName].guessCount !== 0 + if (needsChange) { + this.bestiaryData[apiName] = { + guiName: name.join(" "), + count, + apiCount: this.bestiaryApiTracking[apiName] || 0, + guessCount: 0 + } + this.bestiaryChanged = true + + tempChanged = true + + } + } + } + + if (tempChanged) { + this.bestiaryStatTypes = {} + Object.keys(this.bestiaryData).forEach(k => { + if (this.bestiaryData[k]?.guiName) this.bestiaryStatTypes[k] = this.bestiaryData[k].guiName + }) + + this.hudStat.forEach(s => { + s.type.dropdownObject.setOptions(this.bestiaryStatTypes) + }) + + this.updateHudElements() + } + start = Date.now() + } + + saveData() { + if (this.bestiaryChanged) { + FileLib.write("soopyAddonsData", "bestiaryData.json", JSON.stringify(this.bestiaryData)) + } + } + + onDisable() { + this.hudStat.forEach(h => h.textElement.delete()) + this.saveData() + } + +} +module.exports = { + class: new Bestiary() +} diff --git a/src/features/bestiary/metadata.json b/src/features/bestiary/metadata.json new file mode 100644 index 0000000..3ff9383 --- /dev/null +++ b/src/features/bestiary/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "Bestiary", + "description": "Bestiary trackers", + "isHidden": false, + "isTogglable": true, + "defaultEnabled": true, + "sortA": 0 +} \ No newline at end of file diff --git a/src/features/betterGuis/dungeonReadyGui.js b/src/features/betterGuis/dungeonReadyGui.js new file mode 100644 index 0000000..ad9a5dd --- /dev/null +++ b/src/features/betterGuis/dungeonReadyGui.js @@ -0,0 +1,284 @@ +import { SoopyGui, SoopyRenderEvent } from "../../../guimanager" +import SoopyKeyPressEvent from "../../../guimanager/EventListener/SoopyKeyPressEvent" +import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent" +import BoxWithTextAndDescription from "../../../guimanager/GuiElement/BoxWithTextAndDescription" +import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow" +import SoopyGuiElement from "../../../guimanager/GuiElement/SoopyGuiElement" +import SoopyTextElement from "../../../guimanager/GuiElement/SoopyTextElement" + + +const ContainerChest = Java.type("net.minecraft.inventory.ContainerChest"); + +class DungeonReadyGui { + constructor() { + this.checkMenu = false; + + this.soopyGui = new SoopyGui(); + + this.soopyGui.optimisedLocations = true; + + this.mainPage = new SoopyGuiElement().setLocation(0, 0, 1, 1); + this.soopyGui.element.addChild(this.mainPage); + this.soopyGui.element.addEvent(new SoopyKeyPressEvent().setHandler((...args) => + this.keyPress(...args) + )); + + + this.startButton = new ButtonWithArrow() + .setText("§0Start Dungeon") + .setLocation(0.25, 0.25, 0.5, 0.5) + .addEvent(new SoopyMouseClickEvent().setHandler(() => + this.startDungeon() + )); + this.soopyGui.element.addChild(this.startButton); + + this.startButton.desc = new SoopyTextElement() + .setMaxTextScale(2) + .setLocation(0.05, 0.6, 0.7, 0.4) + .setText(""); + this.startButton.addChild(this.startButton.desc); + + this.closeMenu = 0; + this.nameToId = {}; + this.nextId = 0; + this.currPlayers = 1; + this.readyBoxes = []; + this.confirmationCooldown = 0; + for (let i = 0; i < 4; i++) { + let readyBox = new BoxWithTextAndDescription() + .setText("§0") + .setDesc("§0") + .setLocation(0.1 + 0.2 * i, 0.75, 0.15, 0.15) + .setColor(255, 150, 150); + this.readyBoxes.push(readyBox); + + + readyBox.text.setLocation(0, 0, 1, 0.6); + readyBox.description.setLocation(0.05, 0.6, 0.9, 0.4); + readyBox.visable = false; + + + this.mainPage.addChild(readyBox); + } + + this.classBoxes = []; + this.currentPlayerClass = -1; + this.classes = { + "Healer": new Item("minecraft:potion"), + "Mage": new Item("minecraft:blaze_rod"), + "Berserker": new Item("minecraft:iron_sword"), + "Archer": new Item("minecraft:bow"), + "Tank": new Item("minecraft:leather_chestplate") + }; + Object.keys(this.classes).forEach((clas, i) => { + let classBox = new BoxWithTextAndDescription() + .setText("§0" + clas + "&7 - 0") + .setDesc("§0") + .setLocation(0.1 + 0.1625 * i, 0.1, 0.15, 0.1); + this.classBoxes.push(classBox); + + let classIndex = i; + + classBox.text.setLocation(0, 0, 1, 0.6); + classBox.description.setLocation(0.05, 0.6, 0.9, 0.4); + classBox.addEvent(new SoopyRenderEvent() + .setHandler(() => { + let scale = 16 / Math.min(classBox.location.getWidthExact(), classBox.location.getHeightExact() / 2) * 3; + this.classes[clas].draw(classBox.location.getXExact() + classBox.location.getWidthExact() / 2 - 16 * scale / 2, classBox.location.getYExact() + classBox.location.getHeightExact() - 16 * scale - 4, scale); + })).addEvent(new SoopyMouseClickEvent().setHandler(() => + this.clickedClass(classIndex) + )); + + this.mainPage.addChild(classBox) + }) + + this.playerReadyButton = new ButtonWithArrow() + .setText("§0Ready") + .setLocation(0.33, 0.33, 0.33, 0.33) + .setColor(255, 150, 150) + .addEvent(new SoopyMouseClickEvent() + .setHandler(() => this.ready())); + this.mainPage.addChild(this.playerReadyButton); + } + + joinedDungeon(players) { + this.currPlayers = players; + } + + startDungeon() { + if (Player.getContainer().getName() !== "Start Dungeon?") return; + + if (!this.confirmationCooldown && World.getAllPlayers().filter(p => p.getPing() === 1).length !== this.currPlayers && !(World.getAllPlayers().filter(p => p.getPing() === 1).length === 1 && this.currPlayers === 2)) { + this.startButton.setText("§0Confirm starting Dungeon? (3s)"); + this.startButton.desc.setText("§0(" + World.getAllPlayers().filter(p => p.getPing() === 1).length + "/" + this.currPlayers + " in dungeon)"); + this.confirmationCooldown = Date.now() + 3000; + return; + } + if (Date.now() < this.confirmationCooldown) return; + + this.startButton.visable = false; + Player.getContainer().click(13, false, "MIDDLE"); + } + + ready() { + if (!Player.getContainer().getName().startsWith("Catacombs - Floor ")) return; + this.playerReadyButton.setColor(150, 150, 150); + for (let i = 0; i < 5; i++) { + if (ChatLib.removeFormatting(Player.getContainer().getStackInSlot(3 + i).getName().split(" ").pop()) === Player.getName()) + Player.getContainer().drop(12 + i, false); + } + } + + clickedClass(classIndex) { + if (!Player.getContainer().getName().startsWith("Catacombs - Floor ")) return; + + Player.getContainer().drop(2 + 4 * 9 + classIndex, false); + + this.classBoxes[classIndex].setColor(150, 150, 150); + + if (this.currentPlayerClass !== -1) this.classBoxes[this.currentPlayerClass].setColor(253, 255, 227); + } + + reset() { + this.startButton.visable = true; + this.playerReadyButton.setColor(255, 150, 150); + + this.nameToId = {}; + this.nextId = 0; + this.closeMenu = 0; + + this.startButton.setText("§0Start Dungeon"); + this.startButton.desc.setText(""); + this.confirmationCooldown = 0; + + this.readyBoxes.forEach(b => b.visable = false); + } + + readyInOneSecond() { + this.closeMenu = Date.now() + 1000; + } + + tick() { + if (!this.soopyGui.ctGui.isOpen()) return; + + if (this.closeMenu > 0 && Date.now() > this.closeMenu) { + this.soopyGui.close(); + Client.currentGui.close(); + this.closeMenu = 0; + return; + } + + if (Player.getContainer().getName().startsWith("Catacombs - Floor ")) { + this.startButton.visable = false; + + let clickingClassButton = -1; + + for (let i = 0; i < 5; i++) { + //ready up buttons + if (Player.getContainer().getStackInSlot(3 + i)) { + if (ChatLib.removeFormatting(Player.getContainer().getStackInSlot(3 + i).getName().split(" ").pop()) === Player.getName()) { + if (Player.getContainer().getStackInSlot(12 + i)) { + if (ChatLib.removeFormatting(Player.getContainer().getStackInSlot(12 + i).getName()) === "Ready") { + this.playerReadyButton.setColor(150, 255, 150); + } else { + this.playerReadyButton.setColor(255, 150, 150); + } + } else { + this.playerReadyButton.setColor(150, 150, 150); + } + } else { + let boxId = this.nameToId[ChatLib.removeFormatting(Player.getContainer().getStackInSlot(3 + i).getName().split(" ").pop())]; + + if (boxId) { + this.readyBoxes[boxId].setColor(255, 150, 150); + if (ChatLib.removeFormatting(Player.getContainer().getStackInSlot(12 + i).getName()) === "Ready") + this.readyBoxes[boxId].setColor(150, 255, 150); + + this.readyBoxes[boxId].setLore(Player.getContainer().getStackInSlot(3 + i).getLore()); + this.readyBoxes[boxId].setDesc("§0" + ChatLib.removeFormatting(Player.getContainer().getStackInSlot(3 + i).getLore()[2])); + } + } + } + + + //select class buttons + if (Player.getContainer().getStackInSlot(2 + 4 * 9 + i)) { + this.classBoxes[i].setColor(253, 255, 227); + if (Player.getContainer().getStackInSlot(2 + 4 * 9 + i).getDamage() === 10) + this.classBoxes[i].setColor(250, 255, 150); + + this.classBoxes[i] + .setText("§0" + Object.keys(this.classes)[i] + "§7 - " + ChatLib.removeFormatting(Player.getContainer().getStackInSlot(2 + 4 * 9 + i).getName().split(" ")[0])) + .setLore(Player.getContainer().getStackInSlot(2 + 4 * 9 + i).getLore()); + + let isPlayerClass = false; + Player.getContainer().getStackInSlot(2 + 4 * 9 + i).getLore().forEach(line => { + if (!ChatLib.removeFormatting(line).startsWith(" - ")) return; + if (ChatLib.removeFormatting(line.split(" ").pop()) === Player.getName()) + isPlayerClass = true; + }) + + if (isPlayerClass) { + this.currentPlayerClass = i; + this.classBoxes[i].setColor(150, 255, 150); + } + } else clickingClassButton = i; + } + + if (clickingClassButton !== -1) { + this.classBoxes[clickingClassButton].setColor(150, 150, 150); + if (this.currentPlayerClass !== -1) this.classBoxes[this.currentPlayerClass].setColor(253, 255, 227); + } + }; + + if (this.confirmationCooldown) { + this.startButton.setText("§0Confirm starting Dungeon? (" + Math.ceil(Math.max(0, this.confirmationCooldown - Date.now()) / 1000) + "s)"); + }; + + World.getAllPlayers().filter(p => p.getPing() === 1).forEach(p => { + if (p.getUUID().toString() === Player.getUUID().toString()) return; + + if (p.getName() in this.nameToId) return; + + this.nameToId[p.getName()] = this.nextId++; + + this.readyBoxes[this.nameToId[p.getName()]].setText("§0" + p.getName()).visable = true; + }); + } + + guiOpened(event) { + let name = ""; + if (event.gui && event.gui.field_147002_h instanceof ContainerChest) + name = event.gui.field_147002_h.func_85151_d().func_145748_c_().func_150260_c(); + + if (this.soopyGui.ctGui.isOpen()) { + if (!event.gui || !event.gui.field_147002_h) return; + Player.getPlayer().field_71070_bA = event.gui.field_147002_h + + if (!Player.getContainer().getName().startsWith("Catacombs - Floor ")) return; + + event.gui = this.soopyGui.ctGui + this.soopyGui.ctGui.open(); + return + } + + if (name === "Start Dungeon?" || name.startsWith("Catacombs - Floor ")) { + if (event.gui && event.gui.field_147002_h) Player.getPlayer().field_71070_bA = event.gui.field_147002_h; + + this.soopyGui.open(); + event.gui = this.soopyGui.ctGui; + } + } + + keyPress(key, keyId) { + if (keyId === 1) //escape key + // this.dontOpen = 1 + Client.currentGui.close(); + + if (keyId === 18) //'e' key + Client.currentGui.close(); + + } +} + +export default DungeonReadyGui; \ No newline at end of file diff --git a/src/features/betterGuis/index.js b/src/features/betterGuis/index.js new file mode 100644 index 0000000..dcd8fb9 --- /dev/null +++ b/src/features/betterGuis/index.js @@ -0,0 +1,386 @@ +/// +/// +import Feature from "../../featureClass/class"; +import logger from "../../logger"; +import { f, m } from "../../../mappings/mappings"; +import ToggleSetting from "../settings/settingThings/toggle"; +import MuseumGui from "./museumGui.js"; +import DungeonReadyGui from "./dungeonReadyGui"; +import { SoopyGui } from "../../../guimanager"; +import TextBox from "../../../guimanager/GuiElement/TextBox"; +import SoopyNumber from "../../../guimanager/Classes/SoopyNumber"; + +class BetterGuis extends Feature { + constructor() { + super(); + } + + inSkyblock() { + return this.FeatureManager.features["dataLoader"] && this.FeatureManager.features["dataLoader"].class.isInSkyblock; + } + + onEnable() { + this.initVariables(); + + this.museumGui = new MuseumGui(); + this.dungeonReady = new DungeonReadyGui(); + + this.replaceSbMenuClicks = new ToggleSetting("Improve Clicks on SBMENU", "This will change clicks to middle clicks, AND use commands where possible (eg /pets)", true, "sbmenu_clicks", this); + this.reliableSbMenuClicks = { getValue: () => false }//removed because hypixel fixed, code kept incase hypixel adds back bug later //new ToggleSetting("Make SBMENU clicks reliable", "This will delay clicks on sbmenu to time them so they dont get canceled", true, "sbmenu_time", this) + + this.museumGuiEnabled = new ToggleSetting("Custom Museum GUI", "Custom gui for the Museum", true, "custom_museum_enabled", this); + this.dungeonReadyGuiEnabled = new ToggleSetting("Custom Dungeon Ready GUI", "Custom gui for the dungeon ready up menu", false, "custom_dungeon_ready_enabled", this); + + this.chestSearchBar = new ToggleSetting("Inventory Search Bar", "use '&' to make it filter by stuff that contains multiple things", false, "inv_search", this); + this.customBars = new ToggleSetting("Custom hp and mana bar", "Also hides stuff like armor bar", false, "custom_bars", this); + + this.lastWindowId = 0; + this.shouldHold = 10; + this.clickSlot = -1; + this.clickSlotTime = 0; + + this.middleClickGuis = [ + "Your SkyBlock Profile", + "Your Skills", + "Farming Skill", + "Mining Skill", + "Heart of the Mountain", + "Combat Skill", + "Foraging Skill", + "Fishing Skill", + "Enchanting Skill", + "Alchemy Skill", + "Carpentry Skill", + "Runecrafting Skill", + "Social Skill", + "Taming Skill", + "Dungeoneering", + "Your Essence", + "Healer Class Perks", + "Mage Class Perks", + "Beserk Class Perks", + "Archer Class Perks", + "Tank Class Perks", + "Recipe Book", + "Trades", + "Quest Log", + "Quest Log (Completed)", + "Fairt Souls Guide", + "Dungeon Journals", + "Calendar and Events", + "Booster Cookie", + "Island Management", + "Toggle Potion Effects", + "Bank", + "Bank Account Upgrades", + "Co-op Bank Account", + "Bank Deposit", + "Bank Withdrawal", + "Personal Bank Account", + "Bazaar Orders", + "Co-op Bazaar Orders", + "Pets" + ] + this.middleClickStartsWith = [ + "Bestiary", + "Private Island", + "Hub", + "Spiders Den", + "Blazing Fortress", + "The End", + "Deep Caverns", + "The Park", + "Spooky Festival", + "Catacombs", + "The Catacombs", + "Settings", + "Bazaar", + "Farming", + "Mining", + "Woods & Fishes", + "Oddities" + ]; + this.middleClickEndsWith = [ + "Recipe", + "Recipes", + ") Pets", + "Collection", + "Active Effects" + ]; + + this.registerChat("&r&aDungeon starts in 1 second.&r", () => + this.dungeonReady.readyInOneSecond.call(this.dungeonReady)); + this.registerChat("&r&aDungeon starts in 1 second. Get ready!&r", () => + this.dungeonReady.readyInOneSecond.call(this.dungeonReady)); + this.registerEvent("guiMouseClick", this.guiClicked); + this.registerEvent("guiOpened", (event) => { + if (this.museumGuiEnabled.getValue()) this.museumGui.guiOpened.call(this.museumGui, event); + if (this.dungeonReadyGuiEnabled.getValue()) this.dungeonReady.guiOpened.call(this.dungeonReady, event); + }); + this.registerEvent("worldLoad", () => this.dungeonReady.reset()); + this.registerChat("&e${*} &r&cThe Catacombs &r&ewith &r&9${players}/5 players &r&eon &r${*}&r", (players) => { + if (this.dungeonReadyGuiEnabled.getValue()) this.dungeonReady.joinedDungeon.call(this.dungeonReady, ~~players); + }) + this.registerChat("&eSkyBlock Dungeon Warp &r&7(${players} players)&r", (players) => { + if (this.dungeonReadyGuiEnabled.getValue()) this.dungeonReady.joinedDungeon.call(this.dungeonReady, ~~players) + }) + this.registerStep(true, 10, this.step) + this.registerEvent("worldUnload", () => this.museumGui.saveMuseumCache.call(this.museumGui)); + this.registerStep(false, 30, () => this.museumGui.saveMuseumCache.call(this.museumGui)); + + + this.invSearchSoopyGui = new SoopyGui(); + this.invSearchSoopyGui._renderBackground = () => { }; + + this.invSearchTextBox = new TextBox().setPlaceholder("Click to search").setLocation(0.4, 0.05, 0.2, 0.05); + this.invSearchSoopyGui.element.addChild(this.invSearchTextBox); + + this.mana = new SoopyNumber(0); + this.overflowMana = new SoopyNumber(0); + this.maxMana = new SoopyNumber(0); + this.lastOverFlow = Date.now(); + + this.slotMatches = new Map(); + this.registerEvent("renderHealth", this.renderHealth).registeredWhen(() => this.inSkyblock() && this.customBars.getValue()); + this.registerEvent("renderFood", cancel).registeredWhen(() => this.inSkyblock() && this.customBars.getValue()); + this.registerEvent("renderArmor", this.renderMana).registeredWhen(() => this.inSkyblock() && this.customBars.getValue()); + let registerActionBar = this.registerCustom("actionbar", this.actionbarMana); + registerActionBar.trigger.setCriteria('&b${curr}/${max}✎').setParameter('contains'); + let registerActionBar2 = this.registerCustom("actionbar", this.actionbarOverflowMana); + registerActionBar2.trigger.setCriteria('&3${curr}ʬ').setParameter('contains'); + //&c2532/2532❤ &a798&a❈ Defense &b2525/2525✎ &31ʬ&r (100) + //&c2532/2532❤ &f20&f❂ True Defense &b2414/2414✎ &3600ʬ&r (13) + //&c2665/2665❤ &a972&a❈ Defense &b2145/2145✎ &3600ʬ&r + //&c2,806/2,806❤ &a1,050&a❈ Defense &b1,945/1,945✎ &3600ʬ&r + this.registerEvent("guiRender", this.postGuiRender).registeredWhen(() => this.chestSearchBar.getValue()); + this.registerEvent("guiMouseClick", this.guiMouseClick).registeredWhen(() => this.chestSearchBar.getValue()); + this.registerEvent("guiKey", this.guiKey).registeredWhen(() => this.chestSearchBar.getValue()); + this.registerEvent("renderSlot", this.renderSlot).registeredWhen(() => this.chestSearchBar.getValue()); + this.registerEvent("guiOpened", this.guiOpened).registeredWhen(() => this.chestSearchBar.getValue()); + } + + actionbarMana(curr, max) { + if (curr.includes("Mana")) + curr = curr.split("&b").pop(); + + this.mana.set(parseInt(curr.replace(/,/g, "")), 500); + this.maxMana.set(parseInt(max.replace(/,/g, "")), 500); + if (Date.now() - this.lastOverFlow > 1000) this.overflowMana.set(0, 500); + } + + actionbarOverflowMana(curr) { + this.overflowMana.set(parseInt(curr.replace(/,/g, "")), 500); + this.lastOverFlow = Date.now(); + } + + renderMana(event) { + cancel(event); + + let left = Renderer.screen.getWidth() / 2 + 91 - 80; + let top = Renderer.screen.getHeight() - 40; + + Renderer.retainTransforms(true); + Renderer.translate(left, top); + + let totalAmt = Math.max(this.maxMana.get(), this.mana.get() + this.overflowMana.get()); + + let manaPercent = this.mana.get() / totalAmt; + let ofPercent = this.overflowMana.get() / totalAmt; + + Renderer.drawRect(Renderer.color(0, 0, 0), 0, 0, 80, 10); + Renderer.drawRect(Renderer.color(50, 50, 50), 2, 2, 76, 6); + Renderer.drawRect(Renderer.color(0, 0, 255), 2, 2, manaPercent * 76, 6); + Renderer.drawRect(Renderer.color(0, 255, 255), 2 + manaPercent * 76, 2, ofPercent * 76, 6); + Renderer.retainTransforms(false); + } + + renderHealth(event) { + cancel(event); + + let left = Renderer.screen.getWidth() / 2 - 91; + let top = Renderer.screen.getHeight() - 40; + + Renderer.retainTransforms(true); + Renderer.translate(left, top); + + let totalAmt = Math.max(Player.asPlayerMP().getMaxHP(), Player.getHP() + Player.asPlayerMP().getAbsorption()); + + let hpPercent = Player.getHP() / totalAmt; + let abPercent = Player.asPlayerMP().getAbsorption() / totalAmt; + + + Renderer.drawRect(Renderer.color(0, 0, 0), 0, 0, 80, 10); + Renderer.drawRect(Renderer.color(50, 50, 50), 2, 2, 76, 6); + Renderer.drawRect(Renderer.color(255, 0, 0), 2, 2, hpPercent * 76, 6); + Renderer.drawRect(Renderer.color(255, 255, 0), 2 + hpPercent * 76, 2, abPercent * 76, 6); + + Renderer.retainTransforms(false); + } + + postGuiRender(x, y, gui) { + if (gui instanceof net.minecraft.client.gui.inventory.GuiChest) + this.invSearchSoopyGui._render(x, y, 0); + } + guiMouseClick(x, y, button, gui) { + if (gui instanceof net.minecraft.client.gui.inventory.GuiChest) + this.invSearchSoopyGui._onClick(x, y, button); + } + guiKey(char, code, gui, event) { + if (!(gui instanceof net.minecraft.client.gui.inventory.GuiChest)) return; + + this.invSearchSoopyGui._onKeyPress(char, code); + + if (this.invSearchTextBox.text.selected) { + cancel(event); + this.slotMatches.clear(); + } + } + guiOpened() { + this.slotMatches.clear(); + } + + renderSlot(slot, gui, event) { + if (!(gui instanceof net.minecraft.client.gui.inventory.GuiChest)) return; + if (!this.invSearchTextBox.getText()) return; + + let searchText = this.invSearchTextBox.getText().toLowerCase(); + + let isMatching = false; + let slotMatches = this.slotMatches.get(slot.getIndex()); + if (slotMatches && Date.now() - slotMatches.timestamp < 500) { + if (!slotMatches.isMatching) { + Renderer.translate(0, 0, 100); + Renderer.drawRect(Renderer.color(0, 0, 0, 200), slot.getDisplayX(), slot.getDisplayY(), 8 * Renderer.screen.getScale(), 8 * Renderer.screen.getScale()); + } + return; + } + let item = slot.getItem(); + if (item) { + isMatching = !searchText.split("&").map(a => { + a = a.trim(); + let isMatching2 = false; + if (ChatLib.removeFormatting(item.getName()).toLowerCase().includes(a)) isMatching2 = true; + if (!isMatching2 && item.getLore().some(b => ChatLib.removeFormatting(b).toLowerCase().includes(a))) isMatching2 = true; + return isMatching2; + }).includes(false); + } + + this.slotMatches.set(slot.getIndex(), { isMatching, timestamp: Date.now() }); + + if (!isMatching) { + Renderer.translate(0, 0, 100); + Renderer.drawRect(Renderer.color(0, 0, 0, 200), slot.getDisplayX(), slot.getDisplayY(), 8 * Renderer.screen.getScale(), 8 * Renderer.screen.getScale()); + } + } + + guiClicked(mouseX, mouseY, button, gui, event) { + if (!(gui instanceof net.minecraft.client.gui.inventory.GuiChest) || button !== 0 || !this.replaceSbMenuClicks.getValue()) return; + + let hoveredSlot = gui.getSlotUnderMouse(); + if (!hoveredSlot) return; + + let hoveredSlotId = hoveredSlot[f.slotNumber]; + + // logger.logMessage(hoveredSlotId, 4) + + if (this.guiSlotClicked(ChatLib.removeFormatting(Player.getContainer().getName()), hoveredSlotId)) + cancel(event); + } + + step() { + if (this.museumGuiEnabled.getValue()) this.museumGui.tick.call(this.museumGui); + if (this.dungeonReadyGuiEnabled.getValue()) this.dungeonReady.tick.call(this.dungeonReady); + + if (!this.replaceSbMenuClicks.getValue()) return + if (Player.getContainer() && Player.getContainer().getName() !== "SkyBlock Menu") { + this.lastWindowId = 0; + return; + } + if (this.lastWindowId === 0) { + this.lastWindowId = Player.getContainer().getWindowId(); + return; + } + if (Player.getContainer().getWindowId() === this.lastWindowId) { + this.shouldHold-- + return; + } + + this.lastWindowId = Player.getContainer().getWindowId(); + this.shouldHold += 10; + if (Date.now() - this.clickSlotTime > 1000) { + this.clickSlot = -1; + } + if (this.clickSlot && this.clickSlot != -1) { + Player.getContainer().click(this.clickSlot, false, "MIDDLE"); + this.clickSlot = -1; + } + } + + guiSlotClicked(inventoryName, slotId) { + if (inventoryName.endsWith(" Sack")) return false + switch (inventoryName) { + case "SkyBlock Menu": + switch (slotId) { + case 30: + ChatLib.command("pets") + break + case 25: + ChatLib.command("storage") + break + default: + if (this.shouldHold > 0 && this.reliableSbMenuClicks.getValue()) { + this.clickSlot = slotId + this.clickSlotTime = Date.now() + } else { + Player.getContainer().click(slotId, false, "MIDDLE") + } + break; + } + return true + break + default: + if (this.middleClickGuis.includes(inventoryName)) { + Player.getContainer().click(slotId, false, "MIDDLE") + return true + } + for (let thing of this.middleClickStartsWith) { + if (inventoryName.startsWith(thing)) { + Player.getContainer().click(slotId, false, "MIDDLE") + return true + } + } + for (let thing of this.middleClickEndsWith) { + if (inventoryName.endsWith(thing)) { + Player.getContainer().click(slotId, false, "MIDDLE") + return true + } + } + return false + break + } + } + + initVariables() { + this.replaceSbMenuClicks = undefined; + this.lastWindowId = undefined; + this.shouldHold = undefined; + this.clickSlot = undefined; + this.clickSlotTime = undefined; + this.reliableSbMenuClicks = undefined; + this.middleClickGuis = undefined; + this.middleClickStartsWith = undefined; + this.middleClickEndsWith = undefined; + + this.museumGui = undefined; + } + + onDisable() { + this.initVariables(); + + this.invSearchSoopyGui.delete(); + } +} + +module.exports = { + class: new BetterGuis() +} \ No newline at end of file diff --git a/src/features/betterGuis/metadata.json b/src/features/betterGuis/metadata.json new file mode 100644 index 0000000..6aeed27 --- /dev/null +++ b/src/features/betterGuis/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "Better guis", + "description": "Edits to a bunch of guis to make them nicer to use", + "isHidden": false, + "isTogglable": true, + "defaultEnabled": true, + "sortA": 1 +} \ No newline at end of file diff --git a/src/features/betterGuis/museumGui.js b/src/features/betterGuis/museumGui.js new file mode 100644 index 0000000..06497af --- /dev/null +++ b/src/features/betterGuis/museumGui.js @@ -0,0 +1,1024 @@ +import { SoopyGui, SoopyRenderEvent } from "../../../guimanager" +import SoopyContentChangeEvent from "../../../guimanager/EventListener/SoopyContentChangeEvent" +import SoopyHoverChangeEvent from "../../../guimanager/EventListener/SoopyHoverChangeEvent" +import SoopyKeyPressEvent from "../../../guimanager/EventListener/SoopyKeyPressEvent" +import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent" +import SoopyOpenGuiEvent from "../../../guimanager/EventListener/SoopyOpenGuiEvent" +import BoxWithText from "../../../guimanager/GuiElement/BoxWithText" +import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow" +import ProgressBar from "../../../guimanager/GuiElement/ProgressBar" +import SoopyBoxElement from "../../../guimanager/GuiElement/SoopyBoxElement" +import SoopyGuiElement from "../../../guimanager/GuiElement/SoopyGuiElement" +import SoopyMarkdownElement from "../../../guimanager/GuiElement/SoopyMarkdownElement" +import SoopyTextElement from "../../../guimanager/GuiElement/SoopyTextElement" +import TextBox from "../../../guimanager/GuiElement/TextBox" +import Notification from "../../../guimanager/Notification" +import renderLibs from "../../../guimanager/renderLibs" +import { m } from "../../../mappings/mappings" +import * as utils from "../../utils/utils" + + +const ContainerChest = Java.type("net.minecraft.inventory.ContainerChest") + +class MuseumGui { + constructor() { + this.checkMenu = false + + this.isInMuseum = false + this.guiOpenTickThing = false + this.dontOpen = 0 + this.lastClosed = 0 + this.itemsInPages = JSON.parse(FileLib.read("soopyAddonsData", "museumItemsCache.json") || "{}") || {} + this.itemsInPagesSaved = true + + this.soopyGui = new SoopyGui() + + this.soopyGui.optimisedLocations = true + + this.soopyGui.element.addEvent(new SoopyKeyPressEvent().setHandler((...args) => { + this.keyPress(...args) + })) + + this.mainPage = new SoopyGuiElement().setLocation(0, 0, 1, 1) + this.soopyGui.element.addChild(this.mainPage) + + let widthPer = 0.2 + let leftOffset = (1 - widthPer * 3 - widthPer * 4 / 5) / 2 + + this.weaponsIndicator = new SoopyBoxElement().setLocation(leftOffset, 0.05, widthPer * 4 / 5, 0.15) + this.weaponsIndicator.addEvent(new SoopyRenderEvent().setHandler(() => { + if (this.weaponsIndicator.hovered && ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) !== "Weapons") { + this.weaponText.location.location.x.set(0.05, 500) + this.weaponText.location.size.x.set(0.9, 500) + this.weaponText.location.location.y.set(0.025, 500) + this.weaponText.location.size.y.set(0.35, 500) + + this.weaponsIndicator.setColorOffset(-20, -20, -20, 100) + + Renderer.translate(0, 0, 100) + Renderer.drawRect(Renderer.color(0, 0, 0, 100), this.weaponsIndicator.location.getXExact(), this.weaponsIndicator.location.getYExact(), this.weaponsIndicator.location.getWidthExact(), this.weaponsIndicator.location.getHeightExact()) + let clicks = Player.getContainer().getName() === "Your Museum" ? "1" : "2" + Renderer.translate(0, 0, 100) + renderLibs.drawStringCenteredFull(clicks, this.weaponsIndicator.location.getXExact() + this.weaponsIndicator.location.getWidthExact() / 2, this.weaponsIndicator.location.getYExact() + this.weaponsIndicator.location.getHeightExact() / 2, Math.min(this.weaponsIndicator.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, this.weaponsIndicator.location.getHeightExact() / 4 / 2)) + } else { + this.weaponText.location.location.x.set(0.1, 500) + this.weaponText.location.size.x.set(0.8, 500) + this.weaponText.location.location.y.set(0.05, 500) + this.weaponText.location.size.y.set(0.3, 500) + + this.weaponsIndicator.setColorOffset(0, 0, 0, 100) + } + })).addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.clickedTopButton("Weapons") + })) + + this.weaponText = new SoopyTextElement().setText("§5Weapons").setMaxTextScale(10).setLocation(0.1, 0.05, 0.8, 0.3) + this.weaponsIndicator.addChild(this.weaponText) + this.weaponsPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.2).setText("§0Items Donated: §7Loading...").setMaxTextScale(10) + this.weaponsIndicator.addChild(this.weaponsPercentageText) + this.weaponsProgressBar = new ProgressBar().setLocation(0.1, 0.6, 0.8, 0.35).showPercentage(true) + this.weaponsIndicator.addChild(this.weaponsProgressBar) + this.mainPage.addChild(this.weaponsIndicator) + + this.armourIndicator = new SoopyBoxElement().setLocation(leftOffset + widthPer, 0.05, widthPer * 4 / 5, 0.15) + this.armourIndicator.addEvent(new SoopyRenderEvent().setHandler(() => { + if (this.armourIndicator.hovered && ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) !== "Armor Sets") { + this.armourText.location.location.x.set(0.05, 500) + this.armourText.location.size.x.set(0.9, 500) + this.armourText.location.location.y.set(0.025, 500) + this.armourText.location.size.y.set(0.35, 500) + + this.armourIndicator.setColorOffset(-20, -20, -20, 100) + + Renderer.translate(0, 0, 100) + Renderer.drawRect(Renderer.color(0, 0, 0, 100), this.armourIndicator.location.getXExact(), this.armourIndicator.location.getYExact(), this.armourIndicator.location.getWidthExact(), this.armourIndicator.location.getHeightExact()) + let clicks = Player.getContainer().getName() === "Your Museum" ? "1" : "2" + Renderer.translate(0, 0, 100) + renderLibs.drawStringCenteredFull(clicks, this.armourIndicator.location.getXExact() + this.armourIndicator.location.getWidthExact() / 2, this.armourIndicator.location.getYExact() + this.armourIndicator.location.getHeightExact() / 2, Math.min(this.armourIndicator.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, this.armourIndicator.location.getHeightExact() / 4 / 2)) + } else { + this.armourText.location.location.x.set(0.1, 500) + this.armourText.location.size.x.set(0.8, 500) + this.armourText.location.location.y.set(0.05, 500) + this.armourText.location.size.y.set(0.3, 500) + + this.armourIndicator.setColorOffset(0, 0, 0, 100) + } + })).addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.clickedTopButton("Armor Sets") + })) + + this.armourText = new SoopyTextElement().setText("§5Armor Sets").setMaxTextScale(10).setLocation(0.1, 0.05, 0.8, 0.3) + this.armourIndicator.addChild(this.armourText) + this.armourPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.2).setText("§0Items Donated: §7Loading...").setMaxTextScale(10) + this.armourIndicator.addChild(this.armourPercentageText) + this.armourProgressBar = new ProgressBar().setLocation(0.1, 0.6, 0.8, 0.35).showPercentage(true) + this.armourIndicator.addChild(this.armourProgressBar) + this.mainPage.addChild(this.armourIndicator) + + this.raritiesIndicator = new SoopyBoxElement().setLocation(leftOffset + widthPer * 2, 0.05, widthPer * 4 / 5, 0.15) + this.raritiesIndicator.addEvent(new SoopyRenderEvent().setHandler(() => { + if (this.raritiesIndicator.hovered && ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) !== "Rarities") { + this.raritiesText.location.location.x.set(0.05, 500) + this.raritiesText.location.size.x.set(0.9, 500) + this.raritiesText.location.location.y.set(0.025, 500) + this.raritiesText.location.size.y.set(0.35, 500) + + this.raritiesIndicator.setColorOffset(-20, -20, -20, 100) + + Renderer.translate(0, 0, 100) + Renderer.drawRect(Renderer.color(0, 0, 0, 100), this.raritiesIndicator.location.getXExact(), this.raritiesIndicator.location.getYExact(), this.raritiesIndicator.location.getWidthExact(), this.raritiesIndicator.location.getHeightExact()) + let clicks = Player.getContainer().getName() === "Your Museum" ? "1" : "2" + Renderer.translate(0, 0, 100) + renderLibs.drawStringCenteredFull(clicks, this.raritiesIndicator.location.getXExact() + this.raritiesIndicator.location.getWidthExact() / 2, this.raritiesIndicator.location.getYExact() + this.raritiesIndicator.location.getHeightExact() / 2, Math.min(this.raritiesIndicator.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, this.raritiesIndicator.location.getHeightExact() / 4 / 2)) + } else { + this.raritiesText.location.location.x.set(0.1, 500) + this.raritiesText.location.size.x.set(0.8, 500) + this.raritiesText.location.location.y.set(0.05, 500) + this.raritiesText.location.size.y.set(0.3, 500) + + this.raritiesIndicator.setColorOffset(0, 0, 0, 100) + } + })).addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.clickedTopButton("Rarities") + })) + + this.raritiesText = new SoopyTextElement().setText("§5Rarities").setMaxTextScale(10).setLocation(0.1, 0.05, 0.8, 0.3) + this.raritiesIndicator.addChild(this.raritiesText) + this.raritiesPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.2).setText("§0Items Donated: §7Loading...").setMaxTextScale(10) + this.raritiesIndicator.addChild(this.raritiesPercentageText) + this.raritiesProgressBar = new ProgressBar().setLocation(0.1, 0.6, 0.8, 0.35).showPercentage(true) + this.raritiesIndicator.addChild(this.raritiesProgressBar) + this.mainPage.addChild(this.raritiesIndicator) + + this.specialIndicator = new SoopyBoxElement().setLocation(leftOffset + widthPer * 3, 0.05, widthPer * 4 / 5, 0.15) + this.specialIndicator.addEvent(new SoopyRenderEvent().setHandler(() => { + if (this.specialIndicator.hovered && ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) !== "Special Items") { + this.specialText.location.location.x.set(0.05, 500) + this.specialText.location.size.x.set(0.9, 500) + this.specialText.location.location.y.set(0.025, 500) + this.specialText.location.size.y.set(0.35, 500) + + this.specialIndicator.setColorOffset(-20, -20, -20, 100) + + Renderer.translate(0, 0, 100) + Renderer.drawRect(Renderer.color(0, 0, 0, 100), this.specialIndicator.location.getXExact(), this.specialIndicator.location.getYExact(), this.specialIndicator.location.getWidthExact(), this.specialIndicator.location.getHeightExact()) + let clicks = Player.getContainer().getName() === "Your Museum" ? "1" : "2" + Renderer.translate(0, 0, 100) + renderLibs.drawStringCenteredFull(clicks, this.specialIndicator.location.getXExact() + this.specialIndicator.location.getWidthExact() / 2, this.specialIndicator.location.getYExact() + this.specialIndicator.location.getHeightExact() / 2, Math.min(this.specialIndicator.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, this.specialIndicator.location.getHeightExact() / 4 / 2)) + + } else { + this.specialText.location.location.x.set(0.1, 500) + this.specialText.location.size.x.set(0.8, 500) + this.specialText.location.location.y.set(0.05, 500) + this.specialText.location.size.y.set(0.3, 500) + + this.specialIndicator.setColorOffset(0, 0, 0, 100) + } + })).addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.clickedTopButton("Special Items") + })) + + this.specialText = new SoopyTextElement().setText("§5Special Items").setMaxTextScale(10).setLocation(0.1, 0.05, 0.8, 0.3) + this.specialIndicator.addChild(this.specialText) + this.specialPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.6).setText("§0Items Donated: §7Loading...").setMaxTextScale(10) + this.specialIndicator.addChild(this.spe