forked from CCBlueX/LiquidBounce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LEGACY: Added AutoDisable Module (CCBlueX#2047)
- Loading branch information
1 parent
98743a0
commit ace50e0
Showing
5 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/main/java/net/ccbluex/liquidbounce/features/command/commands/AutoDisableCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* LiquidBounce Hacked Client | ||
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge. | ||
* https://github.com/CCBlueX/LiquidBounce/ | ||
*/ | ||
package net.ccbluex.liquidbounce.features.command.commands | ||
|
||
import net.ccbluex.liquidbounce.features.command.Command | ||
import net.ccbluex.liquidbounce.features.module.ModuleManager | ||
import net.ccbluex.liquidbounce.features.module.modules.misc.AutoDisable | ||
|
||
object AutoDisableCommand : Command("autodisable") { | ||
|
||
/** | ||
* Execute commands with provided [args] | ||
*/ | ||
override fun execute(args: Array<String>) { | ||
if (args.size < 2) { | ||
chatSyntax("autodisable <add/remove/list>") | ||
return | ||
} | ||
|
||
when (args[1].lowercase()) { | ||
"add" -> { | ||
if (args.size < 3) { | ||
chatSyntax("autodisable add <module>") | ||
return | ||
} | ||
|
||
val moduleName = args[2] | ||
val module = ModuleManager.getModule(moduleName) | ||
|
||
if (module != null) { | ||
if (AutoDisable.getModules().contains(module)) { | ||
chat("§cModule §b$moduleName §cis already in the auto-disable list.") | ||
} else { | ||
AutoDisable.addModule(module) | ||
chat("§b$moduleName §ahas been added to the auto-disable list.") | ||
} | ||
} else { | ||
chat("§cModule §b$moduleName §cnot found.") | ||
} | ||
} | ||
"remove" -> { | ||
if (args.size < 3) { | ||
chatSyntax("autodisable remove <module>") | ||
return | ||
} | ||
|
||
val moduleName = args[2] | ||
val module = ModuleManager.getModule(moduleName) | ||
|
||
if (module != null) { | ||
if (AutoDisable.getModules().contains(module)) { | ||
AutoDisable.removeModule(module) | ||
chat("§b$moduleName §6has been removed from the auto-disable list.") | ||
} else { | ||
chat("§cModule §b$moduleName §cis not in the auto-disable list.") | ||
} | ||
} else { | ||
chat("§cModule §b$moduleName §cnot found.") | ||
} | ||
} | ||
"list" -> { | ||
val modules = AutoDisable.getModules() | ||
chat("Modules in the auto-disable list:") | ||
modules.forEach { chat(it.name) } | ||
} | ||
else -> chatSyntax("autodisable <add/remove/list>") | ||
} | ||
} | ||
|
||
override fun tabComplete(args: Array<String>): List<String> { | ||
if (args.isEmpty()) { | ||
return emptyList() | ||
} | ||
|
||
return when (args.size) { | ||
1 -> listOf("add", "remove", "list").filter { it.startsWith(args[0], true) } | ||
2 -> { | ||
when (args[0].lowercase()) { | ||
"add" -> { | ||
val input = args[1].lowercase() | ||
ModuleManager.modules.filter { it.name.lowercase().startsWith(input) }.map { it.name } | ||
} | ||
"remove" -> { | ||
val input = args[1].lowercase() | ||
AutoDisable.getModules().filter { it.name.lowercase().startsWith(input) }.map { it.name } | ||
} | ||
else -> emptyList() | ||
} | ||
} | ||
else -> emptyList() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/main/java/net/ccbluex/liquidbounce/features/module/modules/misc/AutoDisable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* LiquidBounce Hacked Client | ||
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge. | ||
* https://github.com/CCBlueX/LiquidBounce/ | ||
*/ | ||
package net.ccbluex.liquidbounce.features.module.modules.misc | ||
|
||
import net.ccbluex.liquidbounce.LiquidBounce.hud | ||
import net.ccbluex.liquidbounce.event.EventTarget | ||
import net.ccbluex.liquidbounce.event.PacketEvent | ||
import net.ccbluex.liquidbounce.event.UpdateEvent | ||
import net.ccbluex.liquidbounce.event.WorldEvent | ||
import net.ccbluex.liquidbounce.features.module.Module | ||
import net.ccbluex.liquidbounce.features.module.ModuleCategory | ||
import net.ccbluex.liquidbounce.features.module.modules.combat.KillAura | ||
import net.ccbluex.liquidbounce.features.module.modules.combat.Velocity | ||
import net.ccbluex.liquidbounce.features.module.modules.movement.Fly | ||
import net.ccbluex.liquidbounce.features.module.modules.movement.Speed | ||
import net.ccbluex.liquidbounce.features.module.modules.world.Scaffold | ||
import net.ccbluex.liquidbounce.script.api.global.Chat | ||
import net.ccbluex.liquidbounce.ui.client.hud.element.elements.Notification | ||
import net.ccbluex.liquidbounce.value.BoolValue | ||
import net.ccbluex.liquidbounce.value.ListValue | ||
import net.minecraft.network.play.server.S08PacketPlayerPosLook | ||
|
||
object AutoDisable : Module("AutoDisable", ModuleCategory.MISC, gameDetecting = false) { | ||
val modulesList = arrayListOf(KillAura, Velocity, Scaffold, Fly, Speed) | ||
|
||
private val onFlagged by BoolValue("onFlag", true) | ||
private val onWorldChange by BoolValue("onWorldChange", false) | ||
private val onDeath by BoolValue("onDeath", false) | ||
|
||
private val warn by ListValue("Warn", arrayOf("Chat", "Notification"), "Chat") | ||
|
||
@EventTarget | ||
fun onPacket(event: PacketEvent) { | ||
val packet = event.packet | ||
|
||
if (packet is S08PacketPlayerPosLook && onFlagged) { | ||
disabled("flagged") | ||
} | ||
} | ||
|
||
@EventTarget | ||
fun onUpdate(event: UpdateEvent) { | ||
val player = mc.thePlayer ?: return | ||
|
||
if (onDeath && player.isDead) { | ||
disabled("deaths") | ||
} | ||
} | ||
|
||
@EventTarget | ||
fun onWorld(event: WorldEvent) { | ||
if (mc.thePlayer == null) { | ||
return | ||
} | ||
|
||
if (onWorldChange) { | ||
disabled("world changed") | ||
} | ||
} | ||
|
||
private fun disabled(reason: String) { | ||
val anyModuleEnabled = modulesList.any { it.state } | ||
|
||
if (anyModuleEnabled) { | ||
modulesList.forEach { module -> | ||
if (module.state) { | ||
module.state = false | ||
module.onDisable() | ||
} | ||
} | ||
|
||
if (warn == "Chat") { | ||
Chat.print("§eModules have been disabled due to §c$reason") | ||
} else { | ||
hud.addNotification(Notification("Modules have been disabled due to $reason", 2000F)) | ||
} | ||
} | ||
} | ||
|
||
fun addModule(module: Module) { | ||
if (!modulesList.contains(module)) { | ||
modulesList.add(module) | ||
} | ||
} | ||
|
||
fun removeModule(module: Module) { | ||
modulesList.remove(module) | ||
} | ||
|
||
fun getModules(): List<Module> { | ||
return modulesList.toList() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters