aboutsummaryrefslogtreecommitdiff
path: root/features/betterGuis/index.js
blob: f2af866b1f15048b509ea45df44ce8a755bac5ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/// <reference types="../../../CTAutocomplete" />
/// <reference lib="es2015" />
import Feature from "../../featureClass/class";
import logger from "../../logger";
import { f } from "../../../mappings/mappings";
import ToggleSetting from "../settings/settingThings/toggle";
import MuseumGui from "./museumGui.js";
import DungeonReadyGui from "./dungeonReadyGui";

class BetterGuis extends Feature {
    constructor() {
        super()
    }

    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 (UNFINISHED)", "Custom gui for the dungeon ready up menu", false, "custom_dungeon_ready_enabled", 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) })
    }

    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

            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()) {
            if (Player.getContainer() && Player.getContainer().getName() === "SkyBlock Menu") {
                if (this.lastWindowId === 0) {
                    this.lastWindowId = Player.getContainer().getWindowId()
                    return;
                }
                if (Player.getContainer().getWindowId() !== this.lastWindowId) {
                    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
                    }
                } else {
                    this.shouldHold--
                }
            } else {
                this.lastWindowId = 0
            }
        }
    }

    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()
    }
}

module.exports = {
    class: new BetterGuis()
}