GUICloser module

GUICloser: Minecraft 26.3 cheat module, full source for every implementation (1 client: LiquidBounce (Kotlin)).

1 implementationMISC

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

LiquidBounce (Kotlin)MISCsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleGUICloser.ktKotlin · 77 lines · 2.8 KB
SettingsModeFilterPrintScreenTitle
ModuleGUICloser.ktKotlin · Minecraft 26.2 · 77 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.features.module.modules.misc
21
22
import net.ccbluex.liquidbounce.config.ConfigSystem
23
import net.ccbluex.liquidbounce.config.types.list.Tagged
24
import net.ccbluex.liquidbounce.event.events.ScreenEvent
25
import net.ccbluex.liquidbounce.event.handler
26
import net.ccbluex.liquidbounce.features.module.ClientModule
27
import net.ccbluex.liquidbounce.features.module.ModuleCategories
28
import net.ccbluex.liquidbounce.utils.client.chat
29
import net.ccbluex.liquidbounce.utils.client.copyable
30
import net.ccbluex.liquidbounce.utils.client.highlight
31
import net.ccbluex.liquidbounce.utils.client.regular
32
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
33
import net.minecraft.network.chat.Component
34
35
/**
36
 * Closes HandledScreen with its title contains specified words
37
 */
38
object ModuleGUICloser : ClientModule(
39
    "GUICloser",
40
    ModuleCategories.MISC,
41
    aliases = listOf("AutoClose", "ContainerCloser")
42
) {
43
44
    override val baseKey: String
45
        get() = "${ConfigSystem.KEY_PREFIX}.module.guiCloser"
46
47
    private val mode by enumChoice("Mode", Mode.MATCHES)
48
    private val filters by regexList("Filter", mutableListOf(Regex("^Vote$")))
49
50
    private enum class Mode(override val tag: String) : Tagged {
51
        MATCHES("Matches"),
52
        CONTAINS("Contains");
53
54
        fun test(regex: Regex, text: Component): Boolean = when (this) {
55
            MATCHES -> regex.matches(text.string)
56
            CONTAINS -> regex.containsMatchIn(text.string)
57
        }
58
    }
59
60
    private val printScreenTitle by boolean("PrintScreenTitle", false).doNotIncludeAlways()
61
62
    private fun isInFilter(entry: Component) = filters.any { regex ->
63
        mode.test(regex, entry)
64
    }
65
66
    @Suppress("unused")
67
    private val openScreenHandler = handler<ScreenEvent> {
68
        val screen = it.screen as? AbstractContainerScreen<*> ?: return@handler
69
70
        if (isInFilter(screen.title)) {
71
            it.cancelEvent()
72
        } else if (printScreenTitle) {
73
            chat(regular("GUICloser: container screen title: "), highlight(screen.title.string).copyable())
74
        }
75
    }
76
}
77