diff options
Diffstat (limited to 'features')
-rw-r--r-- | features/betterGuis/dungeonReadyGui.js | 206 | ||||
-rw-r--r-- | features/betterGuis/index.js | 107 | ||||
-rw-r--r-- | features/betterGuis/museumGui.js | 767 | ||||
-rw-r--r-- | features/dungeonMap/index.js | 55 | ||||
-rw-r--r-- | features/dungeonSolvers/index.js | 16 |
5 files changed, 693 insertions, 458 deletions
diff --git a/features/betterGuis/dungeonReadyGui.js b/features/betterGuis/dungeonReadyGui.js index 956d4a6..a0c928c 100644 --- a/features/betterGuis/dungeonReadyGui.js +++ b/features/betterGuis/dungeonReadyGui.js @@ -1,32 +1,206 @@ -import { SoopyGui } from "../../../guimanager" +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" const ContainerChest = Java.type("net.minecraft.inventory.ContainerChest") class DungeonReadyGui { - constructor(){ + 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.closeMenu = 0 + this.nameToId = {} + this.nextId = 0 + this.readyBoxes = [] + 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) } - tickMenu(){ + startDungeon() { + if (Player.getContainer().getName() !== "Start Dungeon?") return + this.startButton.visable = false + Player.getContainer().click(13, false, "MIDDLE") } - guiOpened(event){ + 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.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) { + if (ChatLib.removeFormatting(Player.getContainer().getStackInSlot(12 + i).getName()) === "Ready") { + this.readyBoxes[boxId].setColor(150, 255, 150) + } else { + this.readyBoxes[boxId].setColor(255, 150, 150) + } + this.readyBoxes[boxId].setDesc("§0" + Player.getContainer().getStackInSlot(3 + i).getLore()[1]) + } + } + } + + + //select class buttons + if (Player.getContainer().getStackInSlot(2 + 4 * 9 + i)) { + if (Player.getContainer().getStackInSlot(2 + 4 * 9 + i).getDamage() === 10) { + this.currentPlayerClass = i + this.classBoxes[i].setColor(250, 255, 150) + } else { + this.classBoxes[i].setColor(253, 255, 227) + } + 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()) + } 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) + } + } + + 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){ + 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){ + if (this.soopyGui.ctGui.isOpen()) { + if (event.gui && event.gui.field_147002_h) { Player.getPlayer().field_71070_bA = event.gui.field_147002_h - if(!Player.getContainer().getName().startsWith("Catacombs - Floor ")){ - return + if (!Player.getContainer().getName().startsWith("Catacombs - Floor ")) { + return } event.gui = this.soopyGui.ctGui @@ -34,17 +208,21 @@ class DungeonReadyGui { } 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 + 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 } } - tick(){ - if(this.soopyGui.ctGui.isOpen()){ - this.tickMenu() + keyPress(key, keyId) { + if (keyId === 1) { //escape key + // this.dontOpen = 1 + Client.currentGui.close() + } + if (keyId === 18) { //'e' key + Client.currentGui.close() } } } diff --git a/features/betterGuis/index.js b/features/betterGuis/index.js index 1e9c144..128b2d1 100644 --- a/features/betterGuis/index.js +++ b/features/betterGuis/index.js @@ -5,25 +5,25 @@ import logger from "../../logger"; import { f } from "../../../mappings/mappings"; import ToggleSetting from "../settings/settingThings/toggle"; import MuseumGui from "./museumGui.js"; -// import DungeonReadyGui from "./dungeonReadyGui"; +import DungeonReadyGui from "./dungeonReadyGui"; class BetterGuis extends Feature { constructor() { super() } - onEnable(){ + onEnable() { this.initVariables() this.museumGui = new MuseumGui() - // this.dungeonReady = new DungeonReadyGui() + 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.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", true, "custom_dungeon_ready_enabled", this) - + this.dungeonReadyGuiEnabled = new ToggleSetting("Custom Dungeon Ready GUI (UNFINISHED)", "Custom gui for the dungeon ready up menu", false, "custom_dungeon_ready_enabled", this) + this.lastWindowId = 0 this.shouldHold = 10 this.clickSlot = -1 @@ -98,106 +98,115 @@ class BetterGuis extends Feature { "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("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.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.registerEvent("worldUnload", () => { this.museumGui.saveMuseumCache.call(this.museumGui) }) + this.registerStep(false, 30, () => { this.museumGui.saveMuseumCache.call(this.museumGui) }) } - guiClicked(mouseX, mouseY, button, gui, event){ - if(gui.class.toString()==="class net.minecraft.client.gui.inventory.GuiChest" && button===0 && this.replaceSbMenuClicks.getValue()){ - + guiClicked(mouseX, mouseY, button, gui, event) { + if (gui.class.toString() === "class net.minecraft.client.gui.inventory.GuiChest" && button === 0 && this.replaceSbMenuClicks.getValue()) { + let hoveredSlot = gui.getSlotUnderMouse() - if(!hoveredSlot) return + if (!hoveredSlot) return let hoveredSlotId = hoveredSlot[f.slotNumber] // logger.logMessage(hoveredSlotId, 4) - if(this.guiSlotClicked(ChatLib.removeFormatting(Player.getContainer().getName()), hoveredSlotId)){ + 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()){ - if(Player.getContainer() && Player.getContainer().getName()==="SkyBlock Menu"){ - if(this.lastWindowId === 0){ + 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()) { + if (Player.getContainer() && Player.getContainer().getName() === "SkyBlock Menu") { + if (this.lastWindowId === 0) { this.lastWindowId = Player.getContainer().getWindowId() return; } - if(Player.getContainer().getWindowId()!==this.lastWindowId){ + if (Player.getContainer().getWindowId() !== this.lastWindowId) { this.lastWindowId = Player.getContainer().getWindowId() - this.shouldHold+= 10 - if(Date.now()-this.clickSlotTime >1000){ + this.shouldHold += 10 + if (Date.now() - this.clickSlotTime > 1000) { this.clickSlot = -1 } - if(this.clickSlot && this.clickSlot != -1){ + if (this.clickSlot && this.clickSlot != -1) { Player.getContainer().click(this.clickSlot, false, "MIDDLE") this.clickSlot = -1 } - }else{ + } else { this.shouldHold-- } - }else{ - this.lastWindowId =0 + } else { + this.lastWindowId = 0 } } } - guiSlotClicked(inventoryName, slotId){ - if(inventoryName.endsWith(" Sack")) return false - switch(inventoryName){ + guiSlotClicked(inventoryName, slotId) { + if (inventoryName.endsWith(" Sack")) return false + switch (inventoryName) { case "SkyBlock Menu": - switch(slotId){ + switch (slotId) { case 30: ChatLib.command("pets") - break + break case 25: ChatLib.command("storage") - break + break default: - if(this.shouldHold>0 && this.reliableSbMenuClicks.getValue()){ + if (this.shouldHold > 0 && this.reliableSbMenuClicks.getValue()) { this.clickSlot = slotId this.clickSlotTime = Date.now() - }else{ + } else { Player.getContainer().click(slotId, false, "MIDDLE") } - break; + break; } return true - break + break default: - if(this.middleClickGuis.includes(inventoryName)){ + if (this.middleClickGuis.includes(inventoryName)) { Player.getContainer().click(slotId, false, "MIDDLE") return true } - for(let thing of this.middleClickStartsWith){ - if(inventoryName.startsWith(thing)){ + 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)){ + for (let thing of this.middleClickEndsWith) { + if (inventoryName.endsWith(thing)) { Player.getContainer().click(slotId, false, "MIDDLE") return true } } return false - break + break } } - initVariables(){ + initVariables() { this.replaceSbMenuClicks = undefined this.lastWindowId = undefined this.shouldHold = undefined @@ -211,7 +220,7 @@ class BetterGuis extends Feature { this.museumGui = undefined } - onDisable(){ + onDisable() { this.initVariables() } } diff --git a/features/betterGuis/museumGui.js b/features/betterGuis/museumGui.js index 0f7a3e9..2e6fb79 100644 --- a/features/betterGuis/museumGui.js +++ b/features/betterGuis/museumGui.js @@ -20,46 +20,46 @@ import * as utils from "../../utils/utils" const ContainerChest = Java.type("net.minecraft.inventory.ContainerChest") class MuseumGui { - constructor(){ + 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.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.soopyGui.element.addEvent(new SoopyKeyPressEvent().setHandler((...args) => { this.keyPress(...args) })) - this.mainPage = new SoopyGuiElement().setLocation(0,0,1,1) + 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 + 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.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{ + 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) @@ -67,68 +67,69 @@ class MuseumGui { this.weaponsIndicator.setColorOffset(0, 0, 0, 100) } - })).addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + })).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.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.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.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.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{ + 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.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.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.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.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.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{ + 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) @@ -136,35 +137,35 @@ class MuseumGui { this.raritiesIndicator.setColorOffset(0, 0, 0, 100) } - })).addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + })).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.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.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.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.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{ + 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) @@ -172,42 +173,42 @@ class MuseumGui { this.specialIndicator.setColorOffset(0, 0, 0, 100) } - })).addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + })).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.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.specialPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.6).setText("§0Items Donated: §7Loading...").setMaxTextScale(10) this.specialIndicator.addChild(this.specialPercentageText) this.mainPage.addChild(this.specialIndicator) - let box = new SoopyBoxElement().setLocation(0.5-widthPer*0.75, 0.25, widthPer*2*0.75, 0.075).setLore(["Click to search"]) - this.pageTitle = new SoopyTextElement().setText("§5Your Museum").setMaxTextScale(10).setLocation(0,0,1,1) + let box = new SoopyBoxElement().setLocation(0.5 - widthPer * 0.75, 0.25, widthPer * 2 * 0.75, 0.075).setLore(["Click to search"]) + this.pageTitle = new SoopyTextElement().setText("§5Your Museum").setMaxTextScale(10).setLocation(0, 0, 1, 1) box.addChild(this.pageTitle) this.mainPage.addChild(box) this.searchText = "" - let search = new TextBox().setLocation(0.5-widthPer*0.75, 0.25, widthPer*2*0.75, 0.075) - box.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + let search = new TextBox().setLocation(0.5 - widthPer * 0.75, 0.25, widthPer * 2 * 0.75, 0.075) + box.addEvent(new SoopyMouseClickEvent().setHandler(() => { box.visable = false search.visable = true search.select() })) search.visable = false - search.text.mouseClickG = (mouseX, mouseY)=>{ - if(search.text.selected && !this.searchText){ + search.text.mouseClickG = (mouseX, mouseY) => { + if (search.text.selected && !this.searchText) { box.visable = true search.visable = false } search.text.selected = false } - search.text.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFunction)=>{ + search.text.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFunction) => { this.searchText = newVal this.showSearchItems() })) this.mainPage.addChild(search) - this.mainPage.addEvent(new SoopyOpenGuiEvent().setHandler(()=>{ + this.mainPage.addEvent(new SoopyOpenGuiEvent().setHandler(() => { box.visable = true search.visable = false search.text.selected = false @@ -215,55 +216,55 @@ class MuseumGui { this.searchText = "" })) - this.nextButton = new ButtonWithArrow().setLocation(0.5+widthPer*3/2-widthPer/2, 0.25, widthPer/2, 0.075).setText("§0Next Page") - this.nextButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - if(this.nextButton.visable)this.nextPage() + this.nextButton = new ButtonWithArrow().setLocation(0.5 + widthPer * 3 / 2 - widthPer / 2, 0.25, widthPer / 2, 0.075).setText("§0Next Page") + this.nextButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { + if (this.nextButton.visable) this.nextPage() })) this.mainPage.addChild(this.nextButton) - this.previousButton = new ButtonWithArrow().setLocation(0.5-widthPer*3/2, 0.25, widthPer/2, 0.075).setText("§0Previous Page").setDirectionRight(false) - this.previousButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ - if(this.previousButton.visable)this.previousPage() + this.previousButton = new ButtonWithArrow().setLocation(0.5 - widthPer * 3 / 2, 0.25, widthPer / 2, 0.075).setText("§0Previous Page").setDirectionRight(false) + this.previousButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { + if (this.previousButton.visable) this.previousPage() })) this.mainPage.addChild(this.previousButton) this.nextButton.visable = false this.previousButton.visable = false - this.donateTitleBox = new SoopyBoxElement().setLocation(0.5+widthPer*3/2+0.025, 0.25, 0.5-widthPer*1.5-0.05, 0.075) - let donateTitle = new SoopyTextElement().setText("§5Donate").setMaxTextScale(10).setLocation(0,0,1,1) + this.donateTitleBox = new SoopyBoxElement().setLocation(0.5 + widthPer * 3 / 2 + 0.025, 0.25, 0.5 - widthPer * 1.5 - 0.05, 0.075) + let donateTitle = new SoopyTextElement().setText("§5Donate").setMaxTextScale(10).setLocation(0, 0, 1, 1) this.donateTitleBox.addChild(donateTitle) this.mainPage.addChild(this.donateTitleBox) - this.donateBox = new SoopyBoxElement().setLocation(0.5+widthPer*3/2+0.025, 0.35, 0.5-widthPer*1.5-0.05, 0.6).setScrollable(true).enableFrameBuffer() + this.donateBox = new SoopyBoxElement().setLocation(0.5 + widthPer * 3 / 2 + 0.025, 0.35, 0.5 - widthPer * 1.5 - 0.05, 0.6).setScrollable(true).enableFrameBuffer() this.mainPage.addChild(this.donateBox) - this.favoriteTitleBox = new SoopyBoxElement().setLocation(0.025, 0.25, 0.5-widthPer*1.5-0.05, 0.075) - let favoriteTitle = new SoopyTextElement().setText("§5Favourite Items").setMaxTextScale(10).setLocation(0,0,1,1) + this.favoriteTitleBox = new SoopyBoxElement().setLocation(0.025, 0.25, 0.5 - widthPer * 1.5 - 0.05, 0.075) + let favoriteTitle = new SoopyTextElement().setText("§5Favourite Items").setMaxTextScale(10).setLocation(0, 0, 1, 1) this.favoriteTitleBox.addChild(favoriteTitle) this.mainPage.addChild(this.favoriteTitleBox) - this.favoriteBox = new SoopyBoxElement().setLocation(0.025, 0.35, 0.5-widthPer*1.5-0.05, 0.6).setScrollable(true).enableFrameBuffer() + this.favoriteBox = new SoopyBoxElement().setLocation(0.025, 0.35, 0.5 - widthPer * 1.5 - 0.05, 0.6).setScrollable(true).enableFrameBuffer() this.mainPage.addChild(this.favoriteBox) - this.itemsBox = new SoopyBoxElement().setLocation(0.5-widthPer*3/2, 0.35, widthPer*3, 0.6).enableFrameBuffer() + 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, this.itemsBox).forEach((box, i)=>{ - box.addEvent(new SoopyHoverChangeEvent().setHandler((hovered)=>{ - if(i===2){ - if(this.searchText){ + 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() + } else { + box.enableFrameBuffer() return } } - if(hovered){ + if (hovered) { box.disableFrameBuffer() - }else{ + } else { box.enableFrameBuffer() box.dirtyFrameBuffer(1000) } @@ -273,7 +274,7 @@ class MuseumGui { this.donateItems = [] this.confirm_temp = "" - + this.replacePage = { "Your Museum": "Museum", " Weapons": "Weapons", @@ -286,27 +287,27 @@ class MuseumGui { this.lastGuiTitle = "" - this.favoriteItems = JSON.parse(FileLib.read("soopyAddonsData","museumFavoriteData.json") || "[]") || [] - this.favoriteIds = this.favoriteItems.map(a=>a.sb_id) + this.favoriteItems = JSON.parse(FileLib.read("soopyAddonsData", "museumFavoriteData.json") || "[]") || [] + this.favoriteIds = this.favoriteItems.map(a => a.sb_id) this.updatedFavorites(false) } - saveMuseumCache(){ + saveMuseumCache() { //Called on worldUnload, and ever 30 seconds - if(this.itemsInPagesSaved) return + if (this.itemsInPagesSaved) return this.itemsInPagesSaved = true - new Thread(()=>{ - FileLib.write("soopyAddonsData","museumItemsCache.json",JSON.stringify(this.itemsInPages)) + new Thread(() => { + FileLib.write("soopyAddonsData", "museumItemsCache.json", JSON.stringify(this.itemsInPages)) }).start() } - clickedTopButton(type){ - if(ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName())===type) return + clickedTopButton(type) { + if (ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) === type) return - if(Player.getContainer().getName() === "Your Museum"){ + if (Player.getContainer().getName() === "Your Museum") { //if on main page can just directly click on it - switch(type){ + switch (type) { case "Weapons": Player.getContainer().click(19, false, "MIDDLE") break @@ -320,104 +321,104 @@ class MuseumGui { Player.getContainer().click(25, false, "MIDDLE") break } - }else{ + } else { Player.getContainer().click(48, false, "MIDDLE") } } - nextPage(){ + nextPage() { let itempages = ["Weapons", "Armor Sets", "Rarities", "Special Items"] - if(itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])){ + if (itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])) { Player.getContainer().click(53, false, "MIDDLE") - - let [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a=>parseInt(a)) - this.regenItems(currPage+1) + + let [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a)) + this.regenItems(currPage + 1) } } - previousPage(){ + previousPage() { let itempages = ["Weapons", "Armor Sets", "Rarities", "Special Items"] - if(itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])){ + if (itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])) { Player.getContainer().click(45, false, "MIDDLE") - - let [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a=>parseInt(a)) - this.regenItems(currPage-1) + + let [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a)) + this.regenItems(currPage - 1) } } - tickMenu(first=false){ - if(!first && (this.tickI++)%5!==0){ - if(this.lastGuiTitle === Player.getContainer().getName()){ - return + tickMenu(first = false) { + if (!first && (this.tickI++) % 5 !== 0) { + if (this.lastGuiTitle === Player.getContainer().getName()) { + return } } this.lastGuiTitle = Player.getContainer().getName() - - if(Player.getContainer().getName() === "Your Museum"){//main page - if(!Player.getContainer().getStackInSlot(19)) return + + if (Player.getContainer().getName() === "Your Museum") {//main page + if (!Player.getContainer().getStackInSlot(19)) return let lore = Player.getContainer().getStackInSlot(19).getLore() - lore.forEach((line, i)=>{ - if(i===0) return - - if(line.split(" ")?.[1]?.includes("/")){ + lore.forEach((line, i) => { + if (i === 0) return + + if (line.split(" ")?.[1]?.includes("/")) { let data = ChatLib.removeFormatting(line).split(" ")[1].split("/") - this.weaponsProgressBar.setProgress(parseInt(data[0])/parseInt(data[1])) - this.weaponsPercentageText.setText("§0Items Donated: §7"+data[0]+"/"+data[1]) + this.weaponsProgressBar.setProgress(parseInt(data[0]) / parseInt(data[1])) + this.weaponsPercentageText.setText("§0Items Donated: §7" + data[0] + "/" + data[1]) } }) this.weaponsIndicator.setLore(lore) - + lore = Player.getContainer().getStackInSlot(21).getLore() - lore.forEach((line, i)=>{ - if(i===0) return - - if(line.split(" ")?.[1]?.includes("/")){ + lore.forEach((line, i) => { + if (i === 0) return + + if (line.split(" ")?.[1]?.includes("/")) { let data = ChatLib.removeFormatting(line).split(" ")[1].split("/") - this.armourProgressBar.setProgress(parseInt(data[0])/parseInt(data[1])) - this.armourPercentageText.setText("§0Items Donated: §7"+data[0]+"/"+data[1]) + this.armourProgressBar.setProgress(parseInt(data[0]) / parseInt(data[1])) + this.armourPercentageText.setText("§0Items Donated: §7" + data[0] + "/" + data[1]) } }) this.armourIndicator.setLore(lore) - + lore = Player.getContainer().getStackInSlot(23).getLore() - lore.forEach((line, i)=>{ - if(i===0) return + lore.forEach((line, i) => { + if (i === 0) return - if(line.split(" ")?.[1]?.includes("/")){ + if (line.split(" ")?.[1]?.includes("/")) { let data = ChatLib.removeFormatting(line).split(" ")[1].split("/") - - this.raritiesProgressBar.setProgress(parseInt(data[0])/parseInt(data[1])) - this.raritiesPercentageText.setText("§0Items Donated: §7"+data[0]+"/"+data[1]) + + this.raritiesProgressBar.setProgress(parseInt(data[0]) / parseInt(data[1])) + this.raritiesPercentageText.setText("§0Items Donated: §7" + data[0] + "/" + data[1]) } }) this.raritiesIndicator.setLore(lore) - + lore = Player.getContainer().getStackInSlot(25).getLore() - lore.forEach((line, i)=>{ - if(i===0) return - - if(ChatLib.removeFormatting(line).startsWith("Items Donated: ")){ - this.specialPercentageText.setText("§0Items Donated: §7"+ChatLib.removeFormatting(line).split(": ")[1]) + lore.forEach((line, i) => { + if (i === 0) return + + if (ChatLib.removeFormatting(line).startsWith("Items Donated: ")) { + this.specialPercentageText.setText("§0Items Donated: §7" + ChatLib.removeFormatting(line).split(": ")[1]) } }) this.specialIndicator.setLore(lore) - if((this.pageTitle.text !== ("§5"+Player.getContainer().getName()) || first) && !this.searchText){ + if ((this.pageTitle.text !== ("§5" + Player.getContainer().getName()) || first) && !this.searchText) { this.itemsBox.clearChildren() - let rewardsButton = new ButtonWithArrow().setText("§5Rewards").setLocation(0.1,0.05,0.8,0.2) - rewardsButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + let rewardsButton = new ButtonWithArrow().setText("§5Rewards").setLocation(0.1, 0.05, 0.8, 0.2) + rewardsButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { Player.getContainer().click(40, false, "MIDDLE") })) this.itemsBox.addChild(rewardsButton) - let browserButton = new ButtonWithArrow().setText("§5Museum Browser").setLocation(0.1,0.3,0.8,0.2) - browserButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + let browserButton = new ButtonWithArrow().setText("§5Museum Browser").setLocation(0.1, 0.3, 0.8, 0.2) + browserButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { Player.getContainer().click(50, false, "MIDDLE") })) this.itemsBox.addChild(browserButton) - + this.itemsBox.dirtyFrameBuffer() } } @@ -429,31 +430,31 @@ class MuseumGui { this.donateBox.visable = false let itempages = ["Weapons", "Armor Sets", "Rarities", "Special Items"] - if(itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])){ + if (itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])) { let page = this.replacePage[Player.getContainer().getName().split("➜").pop()] - let [currPage, pageNum] = Player.getContainer().getName().includes("/")?Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a=>parseInt(a)):[1,1] + let [currPage, pageNum] = Player.getContainer().getName().includes("/") ? Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a)) : [1, 1] - if(!this.searchText){ - if(currPage > 1){ + if (!this.searchText) { + if (currPage > 1) { this.previousButton.visable = true - if(Player.getContainer().getStackInSlot(45)) this.previousButton.setLore(Player.getContainer().getStackInSlot(45).getLore()) + if (Player.getContainer().getStackInSlot(45)) this.previousButton.setLore(Player.getContainer().getStackInSlot(45).getLore()) } - if(currPage < pageNum){ + if (currPage < pageNum) { this.nextButton.visable = true - if(Player.getContainer().getStackInSlot(53))this.nextButton.setLore(Player.getContainer().getStackInSlot(53).getLore()) + if (Player.getContainer().getStackInSlot(53)) this.nextButton.setLore(Player.getContainer().getStackInSlot(53).getLore()) } } - + this.donateTitleBox.visable = true this.donateBox.visable = true let oldDonateItems = JSON.stringify(this.donateItems) this.donateItems = [] let donateArmorSets = {} - Player.getContainer().getItems().forEach((item, slot)=>{ - if(!item) return - if(item.getID() === -1) return - item.getLore().forEach(line=>{ - if(ChatLib.removeFormatting(line) === "Click to donate item!"){ + Player.getContainer().getItems().forEach((item, slot) => { + if (!item) return + if (item.getID() === -1) return + item.getLore().forEach(line => { + if (ChatLib.removeFormatting(line) === "Click to donate item!") { let sb_id = utils.getSBID(item) this.donateItems.push({ @@ -463,16 +464,16 @@ class MuseumGui { slot: slot }) } - if(ChatLib.removeFormatting(line) === "Click to donate armor set!"){ + if (ChatLib.removeFormatting(line) === "Click to donate armor set!") { let sb_id = utils.getSBID(item) let setId = sb_id.split("_") setId.pop() setId = setId.join("_") - donateArmorSets[setId] = (donateArmorSets[setId]||0)+1 + donateArmorSets[setId] = (donateArmorSets[setId] || 0) + 1 - if(donateArmorSets[setId] === 3){ + if (donateArmorSets[setId] === 3) { this.donateItems.push({ sb_id: sb_id || "NA", name: item.getName() || "", @@ -484,93 +485,93 @@ class MuseumGui { } }) }) - if(oldDonateItems !== JSON.stringify(this.donateItems)){ + if (oldDonateItems !== JSON.stringify(this.donateItems)) { this.regenDonateItems() } - if(!this.itemsInPages[page]) this.itemsInPages[page] = [] + if (!this.itemsInPages[page]) this.itemsInPages[page] = [] //10-16 43 let changed = false - for(let i = 0;i<4;i++){ - for(let j = 10;j<17;j++){ - let slot = i*9+j + for (let i = 0; i < 4; i++) { + for (let j = 10; j < 17; j++) { + let slot = i * 9 + j let item = Player.getContainer().getStackInSlot(slot) let sb_id = utils.getSBID(item) - if(!this.itemsInPages[page][currPage]) this.itemsInPages[page][currPage] = [] + if (!this.itemsInPages[page][currPage]) this.itemsInPages[page][currPage] = [] - if(item && item.getID() !== -1){ + if (item && item.getID() !== -1) { - let itemData = { - sb_id: "NA", - name: item.getName() || "", - lore: item.getLore() || [] - } + let itemData = { + sb_id: "NA", + name: item.getName() || "", + lore: item.getLore() || [] + } - if(sb_id){ - itemData.sb_id = sb_id - } - if(!this.itemsInPages[page][currPage][slot] || this.itemsInPages[page][currPage][slot].sb_id !== itemData.sb_id){ - this.itemsInPages[page][currPage][slot] = itemData - - changed = true - this.itemsInPagesSaved = false - } - }else{ - if(this.itemsInPages[page][currPage][slot]){ + if (sb_id) { + itemData.sb_id = sb_id + } + if (!this.itemsInPages[page][currPage][slot] || this.itemsInPages[page][currPage][slot].sb_id !== itemData.sb_id) { + this.itemsInPages[page][currPage][slot] = itemData + + changed = true + this.itemsInPagesSaved = false + } + } else { + if (this.itemsInPages[page][currPage][slot]) { delete this.itemsInPages[page][currPage][slot] - + changed = true this.itemsInPagesSaved = false } } } } - if(changed || this.guiUpdated || first) this.regenItems(currPage) + if (changed || this.guiUpdated || first) this.regenItems(currPage) } - if(Player.getContainer().getName() === "Confirm Donation"){ - let this_confirm_temp_str = (Player.getContainer().getStackInSlot(4)?.getName() || "") +(Player.getContainer().getStackInSlot(2)?.getName() || "") + (Player.getContainer().getStackInSlot(20)?.getName() || "") + (Player.getContainer().getStackInSlot(24)?.getName() || "")//4, 24, 20 - if(this.confirm_temp !== this_confirm_temp_str || first){ + if (Player.getContainer().getName() === "Confirm Donation") { + let this_confirm_temp_str = (Player.getContainer().getStackInSlot(4)?.getName() || "") + (Player.getContainer().getStackInSlot(2)?.getName() || "") + (Player.getContainer().getStackInSlot(20)?.getName() || "") + (Player.getContainer().getStackInSlot(24)?.getName() || "")//4, 24, 20 + if (this.confirm_temp !== this_confirm_temp_str || first) { this.confirm_temp = this_confirm_temp_str this.itemsBox.clearChildren() - let isArmour = utils.getSBID(Player.getContainer().getStackInSlot(4))===null - if(isArmour){ + let isArmour = utils.getSBID(Player.getContainer().getStackInSlot(4)) === null + if (isArmour) { let name = Player.getContainer().getStackInSlot(2).getName() - let itemBox = new BoxWithText().setText(name.startsWith("§f")?"&7"+name.substr(2):name).setLocation(0.1,0.05,0.8,0.2).setLore(Player.getContainer().getStackInSlot(2).getLore()) - + let itemBox = new BoxWithText().setText(name.startsWith("§f") ? "&7" + name.substr(2) : name).setLocation(0.1, 0.05, 0.8, 0.2).setLore(Player.getContainer().getStackInSlot(2).getLore()) + this.itemsBox.addChild(itemBox) - }else{ + } else { let name = Player.getContainer().getStackInSlot(4).getName() - let itemBox = new BoxWithText().setText(name.startsWith("§f")?"&7"+name.substr(2):name).setLocation(0.1,0.05,0.8,0.2).setLore(Player.getContainer().getStackInSlot(4).getLore()) - + let itemBox = new BoxWithText().setText(name.startsWith("§f") ? "&7" + name.substr(2) : name).setLocation(0.1, 0.05, 0.8, 0.2).setLore(Player.getContainer().getStackInSlot(4).getLore()) + this.itemsBox.addChild(itemBox) } - if(Player.getContainer().getStackInSlot(24) && Player.getContainer().getStackInSlot(20)){ + if (Player.getContainer().getStackInSlot(24) && Player.getContainer().getStackInSlot(20)) { - let cancelButton = new ButtonWithArrow().setText("§cCancel").setLocation(0.1,0.4,0.35,0.2).setDirectionRight(false).setLore(Player.getContainer().getStackInSlot(24).getLore()) - cancelButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + let cancelButton = new ButtonWithArrow().setText("§cCancel").setLocation(0.1, 0.4, 0.35, 0.2).setDirectionRight(false).setLore(Player.getContainer().getStackInSlot(24).getLore()) + cancelButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { Player.getContainer().click(24, false, "LEFT") })) this.itemsBox.addChild(cancelButton) - let confirmButton = new ButtonWithArrow().setText("§aConfirm Donation").setLocation(0.55,0.4,0.35,0.2).setLore(Player.getContainer().getStackInSlot(20).getLore()) - confirmButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + let confirmButton = new ButtonWithArrow().setText("§aConfirm Donation").setLocation(0.55, 0.4, 0.35, 0.2).setLore(Player.getContainer().getStackInSlot(20).getLore()) + confirmButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { Player.getContainer().click(20, false, "LEFT") })) this.itemsBox.addChild(confirmButton) } - + this.itemsBox.dirtyFrameBuffer() } this.favoriteBox.visable = false this.favoriteTitleBox.visable = false - }else{ - if(this.confirm_temp && this.searchText){ + } else { + if (this.confirm_temp && this.searchText) { this.showSearchItems() } this.confirm_temp = "" @@ -579,15 +580,15 @@ class MuseumGui { this.favoriteTitleBox.visable = true } - this.pageTitle.setText("§5"+Player.getContainer().getName()) + this.pageTitle.setText("§5" + Player.getContainer().getName()) this.guiUpdated = false } - regenDonateItems(){ + regenDonateItems() { this.donateBox.clearChildren() - this.donateItems.forEach((item, i)=>{ - let itemButton = new ButtonWithArrow().setText(item.name.startsWith("§f")?"&7"+item.name.substr(2):item.name).setLocation(0.05,0.025+0.125*i,0.9,0.1).setLore(item.lore) - itemButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + this.donateItems.forEach((item, i) => { + let itemButton = new ButtonWithArrow().setText(item.name.startsWith("§f") ? "&7" + item.name.substr(2) : item.name).setLocation(0.05, 0.025 + 0.125 * i, 0.9, 0.1).setLore(item.lore) + itemButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { Player.getContainer().click(item.slot, false, "LEFT") })) this.donateBox.addChild(itemButton) @@ -596,10 +597,10 @@ class MuseumGui { this.donateBox.dirtyFrameBuffer() } - showSearchItems(){ - if(Player.getContainer().getName() === "Confirm Donation") return + showSearchItems() { + if (Player.getContainer().getName() === "Confirm Donation") return - if(!this.searchText){ + if (!this.searchText) { this.tickMenu(true) return } @@ -610,17 +611,17 @@ class MuseumGui { let items = [] // this.itemsInPages[page][page2] - Object.keys(this.itemsInPages).forEach((pageKey)=>{ + Object.keys(this.itemsInPages).forEach((pageKey) => { let page = this.itemsInPages[pageKey] - page.forEach((page2, page2I)=>{ - if(!page2) return - if(items.length >= 4*7) return - page2.forEach((item, slotNum)=>{ - if(!item) return - if(items.length >= 4*7) return - if(item.name.toLowerCase().includes(this.searchText.toLowerCase())){ + page.forEach((page2, page2I) => { + if (!page2) return + if (items.length >= 4 * 7) return + page2.forEach((item, slotNum) => { + if (!item) return + if (items.length >= 4 * 7) return + if (item.name.toLowerCase().includes(this.searchText.toLowerCase())) { let loreNew = [] - Object.values(item.lore).forEach(a=>{ + Object.values(item.lore).forEach(a => { loreNew.push(a) }) item.lore = loreNew @@ -637,170 +638,170 @@ class MuseumGui { let y = 0.0325 let itemNum = 0 let width = 3 - let widthPer = 1/(width+1) + let widthPer = 1 / (width + 1) let offset = 0.0125 - items.forEach((slot, slotNum)=>{ - if(!slot) return + items.forEach((slot, slotNum) => { + if (!slot) return let child - if(slot.sb_id === "NA"){ - child =new BoxWithText().setText(slot.name.startsWith("§f")?"&7"+slot.name.substr(2):slot.name).setLore(slot.lore) - if(slot.name.startsWith("§c")){ + if (slot.sb_id === "NA") { + child = new BoxWithText().setText(slot.name.startsWith("§f") ? "&7" + slot.name.substr(2) : slot.name).setLore(slot.lore) + if (slot.name.startsWith("§c")) { child.setColor(255, 100, 100) - child.setText("&0"+slot.name.substr(2)) + child.setText("&0" + slot.name.substr(2)) } - if(slot.name.startsWith("§e")){ + if (slot.name.startsWith("§e")) { child.setColor(255, 255, 100) - child.setText("&0"+slot.name.substr(2)) + child.setText("&0" + slot.name.substr(2)) } - }else{ + } else { let fItem = slot - child = new ButtonWithArrow().setText(slot.name.startsWith("§f")?"&7"+slot.name.substr(2):slot.name).setLore(slot.lore) - child.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button)=>{ - if(button === 2){ //middle click -> add item to favorites + child = new ButtonWithArrow().setText(slot.name.startsWith("§f") ? "&7" + slot.name.substr(2) : slot.name).setLore(slot.lore) + child.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button) => { + if (button === 2) { //middle click -> add item to favorites this.addItemToFavorites(fItem, fItem.page, fItem.page2, fItem.slotNum) return } // Player.getContainer().click(item.slotNum, false,button===1?"RIGHT":"LEFT") - + let currPage, pageNum - if(Player.getContainer().getName().includes("/")){ - [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a=>parseInt(a)) + if (Player.getContainer().getName().includes("/")) { + [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a)) } - - if(this.replacePage[Player.getContainer().getName().split("➜").pop()]===fItem.page){ - if(currPage === fItem.page2){ - Player.getContainer().click(fItem.slotNum, false,"LEFT") - }else{ - if(currPage < fItem.page2){ - Player.getContainer().click(53, false,"MIDDLE") - }else{ - Player.getContainer().click(45, false,"MIDDLE") + + if (this.replacePage[Player.getContainer().getName().split("➜").pop()] === fItem.page) { + if (currPage === fItem.page2) { + Player.getContainer().click(fItem.slotNum, false, "LEFT") + } else { + if (currPage < fItem.page2) { + Player.getContainer().click(53, false, "MIDDLE") + } else { + Player.getContainer().click(45, false, "MIDDLE") } } - }else{ + } else { this.clickedTopButton(fItem.page) } - })).addEvent(new SoopyRenderEvent().setHandler(()=>{ - if(child.hovered){ - + })).addEvent(new SoopyRenderEvent().setHandler(() => { + if (child.hovered) { + child.setColorOffset(-20, -20, -20, 100) - - Renderer.translate(0,0,100) - Renderer.drawRect(Renderer.color(0,0,0,100), child.location.getXExact(), child.location.getYExact(), child.location.getWidthExact(), child.location.getHeightExact()) - + + Renderer.translate(0, 0, 100) + Renderer.drawRect(Renderer.color(0, 0, 0, 100), child.location.getXExact(), child.location.getYExact(), child.location.getWidthExact(), child.location.getHeightExact()) + let clicks = "?" let currPage, pageNum - if(Player.getContainer().getName().includes("/")){ - [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a=>parseInt(a)) + if (Player.getContainer().getName().includes("/")) { + [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a)) } - let pageClicks = Math.abs(currPage-fItem.page2) - if(this.replacePage[Player.getContainer().getName().split("➜").pop()]===fItem.page){ - clicks = (pageClicks+1) + "" - }else{ - if(Player.getContainer().getName() === "Your Museum"){ - clicks = (1+fItem.page2) + "" - }else{ - clicks = (2+fItem.page2) + "" + let pageClicks = Math.abs(currPage - fItem.page2) + if (this.replacePage[Player.getContainer().getName().split("➜").pop()] === fItem.page) { + clicks = (pageClicks + 1) + "" + } else { + if (Player.getContainer().getName() === "Your Museum") { + clicks = (1 + fItem.page2) + "" + } else { + clicks = (2 + fItem.page2) + "" } } - - Renderer.translate(0,0,100) - renderLibs.drawStringCenteredFull(clicks, child.location.getXExact()+child.location.getWidthExact()/2, child.location.getYExact()+child.location.getHeightExact()/2, Math.min(child.location.getWidthExact()/Renderer.getStringWidth(clicks)/4, child.location.getHeightExact()/4/2)) - + + Renderer.translate(0, 0, 100) + renderLibs.drawStringCenteredFull(clicks, child.location.getXExact() + child.location.getWidthExact() / 2, child.location.getYExact() + child.location.getHeightExact() / 2, Math.min(child.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, child.location.getHeightExact() / 4 / 2)) + } })) - if(this.favoriteIds.includes(slot.sb_id)){ + if (this.favoriteIds.includes(slot.sb_id)) { child.setColor(200, 255, 200) } } - child.setLocation(offset+widthPer*itemNum,y,widthPer*9/10,0.125) + child.setLocation(offset + widthPer * itemNum, y, widthPer * 9 / 10, 0.125) this.itemsBox.addChild(child) itemNum++ - if(itemNum>width){ + if (itemNum > width) { itemNum = 0 - y+=0.135 + y += 0.135 } }) this.itemsBox.dirtyFrameBuffer() } - regenItems(page2){ - if(this.searchText) return + regenItems(page2) { + if (this.searchText) return this.itemsBox.clearChildren() - let page = this.replacePage[Player.getContainer().getName().split("➜").pop()] + let page = this.replacePage[Player.getContainer().getName().split("➜").pop()] let y = 0.0325 let itemNum = 0 let width = 3 - let widthPer = 1/(width+1) + let widthPer = 1 / (width + 1) let offset = 0.0125 - if(!this.itemsInPages[page][page2]) this.itemsInPages[page][page2] = [] + if (!this.itemsInPages[page][page2]) this.itemsInPages[page][page2] = [] - this.itemsInPages[page][page2].forEach((slot, slotNum)=>{ - if(!slot) return + this.itemsInPages[page][page2].forEach((slot, slotNum) => { + if (!slot) return let child - if(slot.sb_id === "NA"){ - child =new BoxWithText().setText(slot.name.startsWith("§f")?"&7"+slot.name.substr(2):slot.name).setLore(slot.lore) - if(slot.name.startsWith("§c")){ + if (slot.sb_id === "NA") { + child = new BoxWithText().setText(slot.name.startsWith("§f") ? "&7" + slot.name.substr(2) : slot.name).setLore(slot.lore) + if (slot.name.startsWith("§c")) { child.setColor(255, 100, 100) - child.setText("&0"+slot.name.substr(2)) + child.setText("&0" + slot.name.substr(2)) } - if(slot.name.startsWith("§e")){ + if (slot.name.startsWith("§e")) { child.setColor(255, 255, 100) - child.setText("&0"+slot.name.substr(2)) + child.setText("&0" + slot.name.substr(2)) } - }else{ - child = new ButtonWithArrow().setText(slot.name.startsWith("§f")?"&7"+slot.name.substr(2):slot.name).setLore(slot.lore) - child.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button)=>{ - if(button === 2){ //middle click -> add item to favorites + } else { + child = new ButtonWithArrow().setText(slot.name.startsWith("§f") ? "&7" + slot.name.substr(2) : slot.name).setLore(slot.lore) + child.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button) => { + if (button === 2) { //middle click -> add item to favorites this.addItemToFavorites(slot, page, page2, slotNum) return } // Player.getContainer().click(slotNum, false,button===1?"RIGHT":"LEFT") - Player.getContainer().click(slotNum, false,"LEFT") //TODO: add right click support for viewing armour sets + Player.getContainer().click(slotNum, false, "LEFT") //TODO: add right click support for viewing armour sets })) - if(this.favoriteIds.includes(slot.sb_id)){ + if (this.favoriteIds.includes(slot.sb_id)) { child.setColor(200, 255, 200) } } - child.setLocation(offset+widthPer*itemNum,y,widthPer*9/10,0.125) + child.setLocation(offset + widthPer * itemNum, y, widthPer * 9 / 10, 0.125) this.itemsBox.addChild(child) itemNum++ - if(itemNum>width){ + if (itemNum > width) { itemNum = 0 - y+=0.135 + y += 0.135 } }) this.itemsBox.dirtyFrameBuffer() } - addItemToFavorites(slot, page, page2, slotNum){ - if(page === "Special Items"){ - new Notification("§cError!", ["You cant add Special Items",["to favorites"]]) + addItemToFavorites(slot, page, page2, slotNum) { + if (page === "Special Items") { + new Notification("§cError!", ["You cant add Special Items", ["to favorites"]]) return } - if(this.favoriteItems.map(a=>a.sb_id).includes(slot.sb_id)){ + if (this.favoriteItems.map(a => a.sb_id).includes(slot.sb_id)) { //remove from favorites - this.favoriteItems = this.favoriteItems.filter(a=>a.sb_id!==slot.sb_id) - this.favoriteIds = this.favoriteIds.filter(a=>a!==slot.sb_id) + this.favoriteItems = this.favoriteItems.filter(a => a.sb_id !== slot.sb_id) + this.favoriteIds = this.favoriteIds.filter(a => a !== slot.sb_id) this.regenItems(page2) this.updatedFavorites() return } let loreNew = [] - slot.lore.forEach(a=>{ + slot.lore.forEach(a => { loreNew.push(a) }) slot.lore = loreNew @@ -813,120 +814,120 @@ class MuseumGui { this.updatedFavorites() } - updatedFavorites(saveToFile=true){ + updatedFavorites(saveToFile = true) { this.favoriteBox.clearChildren() - if(this.favoriteItems.length === 0 ){ - let item = new SoopyMarkdownElement().setText("Middle click to add an item to your favorites list").setLocation(0.05,0.025,0.9,0.9) + if (this.favoriteItems.length === 0) { + let item = new SoopyMarkdownElement().setText("Middle click to add an item to your favorites list").setLocation(0.05, 0.025, 0.9, 0.9) this.favoriteBox.addChild(item) } - this.favoriteItems.forEach((fItem, i)=>{ - let item = new ButtonWithArrow().setText(fItem.name.startsWith("§f")?"&7"+fItem.name.substr(2):fItem.name).setLocation(0.05,0.025+0.125*i,0.9,0.1).setLore(fItem.lore) + this.favoriteItems.forEach((fItem, i) => { + let item = new ButtonWithArrow().setText(fItem.name.startsWith("§f") ? "&7" + fItem.name.substr(2) : fItem.name).setLocation(0.05, 0.025 + 0.125 * i, 0.9, 0.1).setLore(fItem.lore) - item.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button)=>{ - if(button === 2){ //middle click -> remove item from favorites (calling add will remove because it alr exists) + item.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button) => { + if (button === 2) { //middle click -> remove item from favorites (calling add will remove because it alr exists) this.addItemToFavorites(fItem, fItem.page, fItem.page2, fItem.slotNum) return } // Player.getContainer().click(item.slotNum, false,button===1?"RIGHT":"LEFT") - + let currPage, pageNum - if(Player.getContainer().getName().includes("/")){ - [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a=>parseInt(a)) + if (Player.getContainer().getName().includes("/")) { + [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a)) } - - if(this.replacePage[Player.getContainer().getName().split("➜").pop()]===fItem.page){ - if(currPage === fItem.page2){ - Player.getContainer().click(fItem.slotNum, false,"LEFT") - }else{ - if(currPage < fItem.page2){ - Player.getContainer().click(53, false,"MIDDLE") - }else{ - Player.getContainer().click(45, false,"MIDDLE") + + if (this.replacePage[Player.getContainer().getName().split("➜").pop()] === fItem.page) { + if (currPage === fItem.page2) { + Player.getContainer().click(fItem.slotNum, false, "LEFT") + } else { + if (currPage < fItem.page2) { + Player.getContainer().click(53, false, "MIDDLE") + } else { + Player.getContainer().click(45, false, "MIDDLE") } } - }else{ + } else { this.clickedTopButton(fItem.page) } - })).addEvent(new SoopyRenderEvent().setHandler(()=>{ - if(item.hovered){ + })).addEvent(new SoopyRenderEvent().setHandler(() => { + if (item.hovered) { item.setColorOffset(-20, -20, -20, 100) - - Renderer.translate(0,0,100) - Renderer.drawRect(Renderer.color(0,0,0,100), item.location.getXExact(), item.location.getYExact(), item.location.getWidthExact(), item.location.getHeightExact()) - + + Renderer.translate(0, 0, 100) + Renderer.drawRect(Renderer.color(0, 0, 0, 100), item.location.getXExact(), item.location.getYExact(), item.location.getWidthExact(), item.location.getHeightExact()) + let clicks = "?" let currPage, pageNum - if(Player.getContainer().getName().includes("/")){ - [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a=>parseInt(a)) + if (Player.getContainer().getName().includes("/")) { + [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a)) } - let pageClicks = Math.abs(currPage-fItem.page2) - if(this.replacePage[Player.getContainer().getName().split("➜").pop()]===fItem.page){ - clicks = (pageClicks+1) + "" - }else{ - if(Player.getContainer().getName() === "Your Museum"){ - clicks = (1+fItem.page2) + "" - }else{ - clicks = (2+fItem.page2) + "" + let pageClicks = Math.abs(currPage - fItem.page2) + if (this.replacePage[Player.getContainer().getName().split("➜").pop()] === fItem.page) { + clicks = (pageClicks + 1) + "" + } else { + if (Player.getContainer().getName() === "Your Museum") { + clicks = (1 + fItem.page2) + "" + } else { + clicks = (2 + fItem.page2) + "" } } - Renderer.translate(0,0,100) - renderLibs.drawStringCenteredFull(clicks, item.location.getXExact()+item.location.getWidthExact()/2, item.location.getYExact()+item.location.getHeightExact()/2, Math.min(item.location.getWidthExact()/Renderer.getStringWidth(clicks)/4, item.location.getHeightExact()/4/2)) - + Renderer.translate(0, 0, 100) + renderLibs.drawStringCenteredFull(clicks, item.location.getXExact() + item.location.getWidthExact() / 2, item.location.getYExact() + item.location.getHeightExact() / 2, Math.min(item.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, item.location.getHeightExact() / 4 / 2)) + } })) this.favoriteBox.addChild(item) }) - if(saveToFile){ - new Thread(()=>{ - FileLib.write("soopyAddonsData","museumFavoriteData.json", JSON.stringify(this.favoriteItems)) + if (saveToFile) { + new Thread(() => { + FileLib.write("soopyAddonsData", "museumFavoriteData.json", JSON.stringify(this.favoriteItems)) }).start() } this.favoriteBox.dirtyFrameBuffer() } - guiOpened(event){ + guiOpened(event) { let name = "" - if(event.gui && event.gui.field_147002_h instanceof ContainerChest){ + 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.dontOpen > 0){ + if (this.dontOpen > 0) { this.dontOpen-- } - if(this.soopyGui.ctGui.isOpen()){ - if(event.gui && event.gui.field_147002_h){ + if (this.soopyGui.ctGui.isOpen()) { + if (event.gui && event.gui.field_147002_h) { Player.getPlayer().field_71070_bA = event.gui.field_147002_h - - if(Player.getContainer().getName() === "Museum Rewards"){ - return + + if (Player.getContainer().getName() === "Museum Rewards") { + return } - if(Player.getContainer().getName().startsWith("Museum Browser")){ - return + if (Player.getContainer().getName().startsWith("Museum Browser")) { + return } event.gui = this.soopyGui.ctGui this.guiUpdated = true this.soopyGui.ctGui.open() - + this.itemsBox.dirtyFrameBuffer() } return } - if(this.isInMuseum){ + if (this.isInMuseum) { this.soopyGui.ctGui.open() - + this.itemsBox.dirtyFrameBuffer() - }else{ - if(name === "Your Museum" && !this.isInMuseum){ + } else { + if (name === "Your Museum" && !this.isInMuseum) { - if(event.gui && event.gui.field_147002_h) Player.getPlayer().field_71070_bA = event.gui.field_147002_h + if (event.gui && event.gui.field_147002_h) Player.getPlayer().field_71070_bA = event.gui.field_147002_h this.isInMuseum = true @@ -935,61 +936,61 @@ class MuseumGui { this.guiOpenTickThing = true this.itemsBox.clearChildren() - let rewardsButton = new ButtonWithArrow().setText("§5Rewards").setLocation(0.1,0.05,0.8,0.2) - rewardsButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + let rewardsButton = new ButtonWithArrow().setText("§5Rewards").setLocation(0.1, 0.05, 0.8, 0.2) + rewardsButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { Player.getContainer().click(40, false, "MIDDLE") })) this.itemsBox.addChild(rewardsButton) - let browserButton = new ButtonWithArrow().setText("§5Museum Browser").setLocation(0.1,0.3,0.8,0.2) - browserButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + let browserButton = new ButtonWithArrow().setText("§5Museum Browser").setLocation(0.1, 0.3, 0.8, 0.2) + browserButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { Player.getContainer().click(50, false, "MIDDLE") })) this.itemsBox.addChild(browserButton) - + this.nextButton.visable = false this.previousButton.visable = false this.donateTitleBox.visable = false this.donateBox.visable = false - this.pageTitle.setText("§5"+name) + this.pageTitle.setText("§5" + name) this.tickMenu(true) - + this.itemsBox.dirtyFrameBuffer() } } } - keyPress(key, keyId){ - if(keyId === 1){ //escape key + keyPress(key, keyId) { + if (keyId === 1) { //escape key this.isInMuseum = false // this.dontOpen = 1 Client.currentGui.close() } } - tick(){ - if(this.isInMuseum){ - if(this.soopyGui.ctGui.isOpen() || this.guiOpenTickThing){ + tick() { + if (this.isInMuseum) { + if (this.soopyGui.ctGui.isOpen() || this.guiOpenTickThing) { this.tickMenu() - + this.guiOpenTickThing = false - }else{ + } else { // Client.currentGui.close() this.isInMuseum = false - + this.lastClosed = Date.now() } } - if(!(this.soopyGui.ctGui.isOpen() || this.guiOpenTickThing) && Date.now()-this.lastClosed > 1000){ + if (!(this.soopyGui.ctGui.isOpen() || this.guiOpenTickThing) && Date.now() - this.lastClosed > 1000) { this.weaponsProgressBar.setProgress(0) this.armourProgressBar.setProgress(0) this.raritiesProgressBar.setProgress(0) } - if(this.dontOpen > 0){ + if (this.dontOpen > 0) { Client.currentGui.close() } } diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js index 77fd00b..6280002 100644 --- a/features/dungeonMap/index.js +++ b/features/dungeonMap/index.js @@ -31,8 +31,10 @@ class DungeonMap extends Feature { this.initVariables() this.renderMap = new ToggleSetting("Render Map", "Toggles Rendering the map on the hud", false, "dmap_render", this) - this.mapLocation = new ImageLocationSetting("Map Location", "Sets the location of the map on the hud", "dmap_location", this, [10, 10, 1], new Image(javax.imageio.ImageIO.read(new java.io.File("./config/ChatTriggers/modules/SoopyV2/features/dungeonMap/map.png"))), 100, 100) - this.mapBackground = new ToggleSetting("Map Background And Border", "Puts a grey background behind the map + Black border", false, "dmap_background", this) + this.mapLocation = new ImageLocationSetting("Map Location", "Sets the location of the map on the hud", "dmap_location", this, [10, 10, 1], new Image(javax.imageio.ImageIO.read(new java.io.File("./config/ChatTriggers/modules/SoopyV2/features/dungeonMap/map.png"))), 100, 100).requires(this.renderMap) + this.mapBackground = new ToggleSetting("Map Background And Border", "Puts a grey background behind the map + Black border", true, "dmap_background", this) + this.showMapInBoss = new ToggleSetting("Keep showing the map in the dungeon boss room", "This will center the map when in boss to still be usefull", true, "dmap_enable_boss", this) + this.borderedHeads = new ToggleSetting("Add a black border around heads on map", "", false, "dmap_border_head", this) this.brBox = new ToggleSetting("Box around doors in br", "In map category because it uses map to find location (no esp)", true, "dmap_door", this) this.brBoxDisableWhenBloodOpened = new ToggleSetting("Disable blood rush box when blood open", "", true, "dmap_door_disable", this).requires(this.brBox) this.spiritLeapOverlay = new ToggleSetting("Spirit leap overlay", "Cool overlay for the spirit leap menu", true, "spirit_leap_overlay", this) @@ -122,6 +124,9 @@ class DungeonMap extends Feature { this.registerChat("&r&aDungeon starts in 1 second.&r", () => { this.boringMap = false }) + this.registerChat("&r&aDungeon starts in 1 second. Get ready!&r", () => { + this.boringMap = false + }) this.running = true this.registerEvent("gameUnload", () => { @@ -169,13 +174,18 @@ class DungeonMap extends Feature { drawMap(x, y, size, scale) { if (this.mapImage) { - if (this.mapBackground.getValue()) Renderer.drawRect(Renderer.color(0, 0, 0, 100), x, y, size, size) - + if (this.FeatureManager.features["dataLoader"].class.stats.Time === "Soon!" && Player.getInventory().getStackInSlot(8).getID() !== 358) return if (this.boringMap) { + if (this.mapBackground.getValue()) Renderer.drawRect(Renderer.color(0, 0, 0, 100), x, y, size, size) + this.mapImage.draw(x, y, size, size) + + if (this.mapBackground.getValue()) Renderer.drawRect(Renderer.color(0, 0, 0), x, y, size, 2) + if (this.mapBackground.getValue()) Renderer.drawRect(Renderer.color(0, 0, 0), x, y, 2, size) + if (this.mapBackground.getValue()) Renderer.drawRect(Renderer.color(0, 0, 0), x + size - 2, y, 2, size) + if (this.mapBackground.getValue()) Renderer.drawRect(Renderer.color(0, 0, 0), x, y + size - 2, size, 2) return } - renderLibs.scizzor(x, y, size, size) World.getAllPlayers().forEach(player => { if (player.getPing() === -1) return @@ -188,12 +198,20 @@ class DungeonMap extends Feature { uuid: player.getUUID().toString() } }) + this.mapDataPlayers[Player.getUUID().toString()] = { + x: Player.getX(), + y: Player.getZ(), + rot: Player.getYaw() + 180, + username: Player.getName(), + uuid: Player.getUUID().toString() + } let uuid = Player.getUUID().toString() let renderX let renderY let xOff = 0 let yOff = 0 + let disableMap = false if (this.mapDataPlayers[uuid]) { if (this.currDungeonBossImage) { @@ -208,9 +226,16 @@ class DungeonMap extends Feature { || renderY < 0 || renderY > size) { xOff = size / 2 - renderX yOff = size / 2 - renderY + + if (!this.showMapInBoss.getValue()) { + disableMap = true + } } } + if (disableMap) return + if (this.mapBackground.getValue()) Renderer.drawRect(Renderer.color(0, 0, 0, 100), x, y, size, size) + renderLibs.scizzor(x, y, size, size) this.mapImage.draw(x + xOff, y + yOff, size, size) this.drawOtherMisc(x + xOff, y + yOff, size, scale) @@ -267,7 +292,12 @@ class DungeonMap extends Feature { renderY = this.mapDataPlayers[uuid].y / this.mapScale / 128 * size + this.offset[1] / 128 * size//*16/this.roomWidth } - + if (this.borderedHeads.getValue()) { + Renderer.translate(renderX + x, renderY + y, 1000) + Renderer.scale(scale * 1.5, scale * 1.5) + Renderer.rotate(this.mapDataPlayers[uuid].rot) + Renderer.drawRect(Renderer.color(0, 0, 0), -6, -6, 12, 12) + } Renderer.translate(renderX + x, renderY + y, 1000) Renderer.scale(scale * 1.5, scale * 1.5) Renderer.rotate(this.mapDataPlayers[uuid].rot) @@ -288,6 +318,12 @@ class DungeonMap extends Feature { } + if (this.borderedHeads.getValue()) { + Renderer.translate(renderX + x, renderY + y, 1000) + Renderer.scale(scale * 1.5, scale * 1.5) + Renderer.rotate(this.mapDataPlayers[uuid].rot) + Renderer.drawRect(Renderer.color(0, 0, 0), -6, -6, 12, 12) + } Renderer.translate(renderX + x, renderY + y, 1000) Renderer.scale(scale * 1.5, scale * 1.5) Renderer.rotate(this.mapDataPlayers[uuid].rot) @@ -562,7 +598,7 @@ class DungeonMap extends Feature { // console.log(bytes[Math.floor(Player.getX()/this.mapScale+this.offset[0])+Math.floor(Player.getZ()/this.mapScale + this.offset[1])*128]) this.roomWidth = roomWidth - this.mortLocationOnMap = this.mortLocationOnMap + this.mortLocationOnMap = mortLocationOnMap if (this.mortLocation && mortLocationOnMap && roomWidth) { let deco = mapData[f.mapDecorations] @@ -651,7 +687,10 @@ class DungeonMap extends Feature { } getImageForPlayer(uuid) { - return renderLibs.getImage("https://crafatar.com/avatars/" + uuid.replace(/-/g, "") + "?size=8") || this.defaultPlayerImage + let img = renderLibs.getImage("https://crafatar.com/avatars/" + uuid.replace(/-/g, "") + "?size=8&overlay") + if (!img) return this.defaultPlayerImage + + return img } initVariables() { diff --git a/features/dungeonSolvers/index.js b/features/dungeonSolvers/index.js index bf51bc2..23e45b9 100644 --- a/features/dungeonSolvers/index.js +++ b/features/dungeonSolvers/index.js @@ -196,6 +196,14 @@ class DungeonSolvers extends Feature { this.firstDeathHadSpirit = false }) + this.registerChat("&r&aDungeon starts in 1 second. Get ready!&r", () => { + this.goneInBonus = false; + this.bloodOpenedBonus = false; + + this.firstDeath = false + this.firstDeathHadSpirit = false + }) + this.firstDeath = false this.firstDeathHadSpirit = false @@ -341,9 +349,9 @@ class DungeonSolvers extends Feature { if (latestProfile[1]) { this.firstDeathHadSpirit = true - ChatLib.chat(this.FeatureManager.messagePrefix + username + " has spirit pet!") + if (this.scoreCalculation.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + username + " has spirit pet!") } else { - ChatLib.chat(this.FeatureManager.messagePrefix + username + " does not have spirit pet!") + if (this.scoreCalculation.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + username + " does not have spirit pet!") } }) } else { @@ -352,9 +360,9 @@ class DungeonSolvers extends Feature { if (data.data.profiles[data2.data.stats.currentProfileId].members[uuid].pets.some(pet => pet.type === "SPIRIT" && pet.tier === "LEGENDARY")) { this.firstDeathHadSpirit = true - ChatLib.chat(this.FeatureManager.messagePrefix + username + " has spirit pet!") + if (this.scoreCalculation.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + username + " has spirit pet!") } else { - ChatLib.chat(this.FeatureManager.messagePrefix + username + " does not have spirit pet!") + if (this.scoreCalculation.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + username + " does not have spirit pet!") } }) } |