Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename AutoLog module to AutoDisconnect #450

Merged
merged 2 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiDisconnected.kt
Original file line number Diff line number Diff line change
@@ -1,53 +1,61 @@
package com.lambda.client.gui.mc

import com.lambda.client.module.modules.combat.AutoLog
import com.lambda.client.module.modules.combat.AutoDisconnect
import com.lambda.client.util.threads.mainScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.minecraft.client.gui.GuiButton
import net.minecraft.client.gui.GuiScreen
import java.time.LocalTime

class LambdaGuiDisconnected(private val reason: Array<String>, private val screen: GuiScreen, private val disable: Boolean, private val logoutTime: LocalTime) : GuiScreen() {
class LambdaGuiDisconnected(
private val reason: Array<String>,
private val screen: GuiScreen,
private val disable: Boolean,
private val logoutTime: LocalTime
) : GuiScreen() {

override fun initGui() {
super.initGui()

buttonList.add(GuiButton(0, width / 2 - 100, 200, "Okay"))
if (!disable) {
buttonList.add(GuiButton(1, width / 2 - 100, 220, "Disable AutoLog"))
buttonList.add(GuiButton(1, width / 2 - 100, 220, "Disable AutoDisconnect"))
} else {
disable()
}
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {
drawBackground(0)
drawCenteredString(fontRenderer, "[AutoLog] Logged because:", width / 2, 80, 0x9B90FF)
for ((index, reason) in reason.withIndex()) {
drawCenteredString(fontRenderer, "[AutoDisconnect] Disconnected because:", width / 2, 80, 0x9B90FF)

reason.forEachIndexed { index, reason ->
drawCenteredString(fontRenderer, reason, width / 2, 94 + (14 * index), 0xFFFFFF)
}

drawCenteredString(fontRenderer, "Logged out at: $logoutTime", width / 2, 140, 0xFFFFFFF)

if (!disable) drawCenteredString(fontRenderer, "Disabled AutoLog", width / 2, 224, 0xDE413C)
if (!disable) drawCenteredString(fontRenderer, "Disabled AutoDisconnect", width / 2, 224, 0xDE413C)
super.drawScreen(mouseX, mouseY, partialTicks)
}

override fun keyTyped(typedChar: Char, keyCode: Int) {}

override fun actionPerformed(button: GuiButton) {
if (button.id == 0) mc.displayGuiScreen(screen)
if (button.id == 1) {
disable()
buttonList.remove(button)
when (button.id) {
0 -> mc.displayGuiScreen(screen)
1 -> {
disable()
buttonList.remove(button)
}
}
}

private fun disable() {
mainScope.launch {
delay(250L)
AutoLog.disable()
AutoDisconnect.disable()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.lambda.client.manager.managers.CombatManager
import com.lambda.client.manager.managers.FriendManager
import com.lambda.client.module.Category
import com.lambda.client.module.Module
import com.lambda.client.module.modules.combat.AutoLog.Reasons.*
import com.lambda.client.module.modules.combat.AutoDisconnect.Reasons.*
import com.lambda.client.util.EntityUtils.isFakeOrSelf
import com.lambda.client.util.combat.CombatUtils.scaledHealth
import com.lambda.client.util.items.allSlots
Expand All @@ -25,9 +25,9 @@ import net.minecraft.util.text.TextComponentString
import net.minecraftforge.fml.common.gameevent.TickEvent
import java.time.LocalTime

object AutoLog : Module(
name = "AutoLog",
description = "Automatically log when in danger or on low health",
object AutoDisconnect : Module(
name = "AutoDisconnect",
description = "Automatically disconnects when in danger or on low health",
category = Category.COMBAT,
alwaysListening = true
) {
Expand Down