diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt index e68c065b8..fd59f8276 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt @@ -5,6 +5,7 @@ import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.LambdaEventBus import com.lambda.client.gui.rgui.windows.BasicWindow +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.module.modules.client.Hud import com.lambda.client.setting.GuiConfig @@ -16,7 +17,6 @@ import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.Vec2f -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.opengl.GL11.glScalef @@ -97,7 +97,7 @@ abstract class AbstractHudElement( if (it) { settingList.filter { it != visibleSetting && it != default }.forEach { it.resetValue() } default.value = false - MessageSendHelper.sendChatMessage("$name Set to defaults!") + NotificationManager.registerNotification("$name Set to defaults!") } } diff --git a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt index 027acfcf3..fd4e8c168 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt @@ -1,23 +1,30 @@ package com.lambda.client.manager.managers import com.lambda.client.manager.Manager -import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.module.modules.client.Notifications +import com.lambda.client.util.notifications.Notification +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.threads.safeListener import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.* object NotificationManager : Manager { - private val pendingNotifications: Queue = LinkedList() + private val pendingNotifications: Queue = LinkedList() init { safeListener { while (pendingNotifications.isNotEmpty()) { - MessageSendHelper.sendErrorMessage(pendingNotifications.poll()) + val notification = pendingNotifications.poll() + Notifications.addNotification(notification) } } } fun registerNotification(message: String) { - pendingNotifications.add(message) + pendingNotifications.add(Notification(message, NotificationType.INFO)) + } + + fun registerNotification(message: String, type: NotificationType) { + pendingNotifications.add(Notification(message, type)) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt index 98801b158..6474679a5 100644 --- a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt +++ b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt @@ -5,6 +5,7 @@ import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.ModuleToggleEvent import com.lambda.client.gui.clickgui.LambdaClickGui +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.setting.configs.NameableConfig import com.lambda.client.setting.settings.AbstractSetting @@ -13,7 +14,7 @@ import com.lambda.client.setting.settings.impl.number.IntegerSetting import com.lambda.client.setting.settings.impl.other.BindSetting import com.lambda.client.setting.settings.impl.primitive.BooleanSetting import com.lambda.client.util.Bind -import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.notifications.NotificationType import net.minecraft.client.Minecraft @Suppress("UNCHECKED_CAST") @@ -59,6 +60,10 @@ abstract class AbstractModule( enabled.value = !enabled.value isPaused = false if (enabled.value) clicks.value++ + + if (this.category != Category.CLIENT) { + NotificationManager.registerNotification("$name ${if (enabled.value) "Enabled" else "Disabled"}", NotificationType.INFO) + } } fun enable() { @@ -131,7 +136,7 @@ abstract class AbstractModule( if (it) { settingList.forEach { it.resetValue() } default.value = false - MessageSendHelper.sendChatMessage("$chatName Set to defaults!") + NotificationManager.registerNotification("$chatName Set to defaults!") } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt index 0501eb9df..7d15a8eef 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt @@ -4,6 +4,7 @@ import com.lambda.client.LambdaMod import com.lambda.client.commons.extension.synchronized import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.FolderUtils @@ -115,7 +116,7 @@ object AutoExcuse : Module( try { file.forEachLine { if (it.isNotBlank()) loadedExcuses.add(it.trim()) } - MessageSendHelper.sendChatMessage("$chatName Loaded excuse messages!") + NotificationManager.registerNotification("$chatName Loaded excuse messages!") } catch (e: Exception) { MessageSendHelper.sendErrorMessage("$chatName Failed loading excuses, $e") disable() diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt index 74861e861..c24ac8d09 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt @@ -1,9 +1,11 @@ package com.lambda.client.module.modules.chat import com.lambda.client.event.listener.listener +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.FolderUtils +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue @@ -26,7 +28,7 @@ object ChatFilter : Module( init { onEnable { try { - MessageSendHelper.sendChatMessage("$chatName Trying to find '&7chat_filter.txt&f'") + NotificationManager.registerNotification("$chatName Trying to find '&7chat_filter.txt&f'") chatFilter.clear() file.bufferedReader().forEachLine { @@ -41,9 +43,9 @@ object ChatFilter : Module( } } - MessageSendHelper.sendChatMessage("$chatName Loaded '&7chat_filter.txt&f'!") + NotificationManager.registerNotification("$chatName Loaded '&7chat_filter.txt&f'!") } catch (exception: FileNotFoundException) { - MessageSendHelper.sendErrorMessage("$chatName Couldn't find a file called '&7chat_filter.txt&f' inside your '&7.minecraft/lambda&f' folder, disabling") + NotificationManager.registerNotification("$chatName Couldn't find a file called '&7chat_filter.txt&f' inside your '&7.minecraft/lambda&f' folder, disabling", NotificationType.ERROR) disable() } catch (exception: Exception) { MessageSendHelper.sendErrorMessage(exception.toString()) diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt index 7f86ab631..d1f91bc84 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt @@ -2,10 +2,12 @@ package com.lambda.client.module.modules.chat import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.listener.listener +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.FolderUtils import com.lambda.client.util.MovementUtils.isMoving +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage @@ -39,9 +41,10 @@ object LoginMessage : Module( file.forEachLine { if (it.isNotBlank()) loginMessages.add(it.trim()) } - MessageSendHelper.sendChatMessage("$chatName Loaded ${loginMessages.size} login messages!") + NotificationManager.registerNotification("$chatName Loaded ${loginMessages.size} login messages!") } catch (e: Exception) { - MessageSendHelper.sendErrorMessage("$chatName Failed loading login messages, $e") + NotificationManager.registerNotification("$chatName Failed loading login messages, $e", + NotificationType.ERROR) disable() } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt index 202476242..30bc23809 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt @@ -1,11 +1,13 @@ package com.lambda.client.module.modules.chat import com.lambda.client.commons.extension.synchronized +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.FolderUtils import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage @@ -59,9 +61,10 @@ object Spammer : Module( val text = URL(url).readText() spammer.addAll(text.split("\n")) - MessageSendHelper.sendChatMessage("$chatName Loaded remote spammer messages!") + NotificationManager.registerNotification("$chatName Loaded remote spammer messages!") } catch (e: Exception) { - MessageSendHelper.sendErrorMessage("$chatName Failed loading remote spammer, $e") + NotificationManager.registerNotification("$chatName Failed loading remote spammer, $e", + NotificationType.ERROR) disable() } } @@ -71,9 +74,10 @@ object Spammer : Module( if (file.exists()) { try { file.forEachLine { if (it.isNotBlank()) spammer.add(it.trim()) } - MessageSendHelper.sendChatMessage("$chatName Loaded spammer messages!") + NotificationManager.registerNotification("$chatName Loaded spammer messages!") } catch (e: Exception) { - MessageSendHelper.sendErrorMessage("$chatName Failed loading spammer, $e") + NotificationManager.registerNotification("$chatName Failed loading remote spammer, $e", + NotificationType.ERROR) disable() } } else { diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt index b0d50a839..1c96e5aa5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt @@ -5,6 +5,7 @@ import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.listener.listener import com.lambda.client.gui.AbstractLambdaGui +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.AbstractModule import com.lambda.client.module.Category import com.lambda.client.setting.ConfigManager @@ -17,6 +18,7 @@ import com.lambda.client.setting.settings.impl.primitive.StringSetting import com.lambda.client.util.ConfigUtils import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue import com.lambda.client.util.threads.BackgroundScope @@ -55,7 +57,7 @@ internal object Configurations : AbstractModule( init { BackgroundScope.launchLooping("Config Auto Saving", 60000L) { if (autoSaving && mc.currentScreen !is AbstractLambdaGui<*, *> && timer.tick(savingInterval.toLong())) { - if (savingFeedBack) MessageSendHelper.sendChatMessage("Auto saving settings...") + if (savingFeedBack) NotificationManager.registerNotification("Auto saving settings...") else LambdaMod.LOG.info("Auto saving settings...") ConfigUtils.saveAll() } @@ -85,7 +87,8 @@ internal object Configurations : AbstractModule( val nameWithExtension = "$nameWithoutExtension.json" return if (!ConfigUtils.isPathValid(nameWithExtension)) { - MessageSendHelper.sendChatMessage("${formatValue(nameWithoutExtension)} is not a valid preset name") + NotificationManager.registerNotification("${formatValue(nameWithoutExtension)} is not a valid preset name", + NotificationType.ERROR) false } else { true @@ -174,7 +177,7 @@ internal object Configurations : AbstractModule( var loaded = ConfigManager.load(GenericConfig) loaded = ConfigManager.load(config) || loaded - if (loaded) MessageSendHelper.sendChatMessage("${formatValue(config.name)} config reloaded!") + if (loaded) NotificationManager.registerNotification("${formatValue(config.name)} config reloaded!") else MessageSendHelper.sendErrorMessage("Failed to load ${formatValue(config.name)} config!") } } @@ -184,7 +187,7 @@ internal object Configurations : AbstractModule( var saved = ConfigManager.save(GenericConfig) saved = ConfigManager.save(config) || saved - if (saved) MessageSendHelper.sendChatMessage("${formatValue(config.name)} config saved!") + if (saved) NotificationManager.registerNotification("${formatValue(config.name)} config saved!") else MessageSendHelper.sendErrorMessage("Failed to load ${formatValue(config.name)} config!") } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt new file mode 100644 index 000000000..920854e03 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -0,0 +1,187 @@ +package com.lambda.client.module.modules.client + +import com.lambda.client.event.events.RenderOverlayEvent +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.AnimationUtils +import com.lambda.client.util.graphics.GlStateUtils +import com.lambda.client.util.graphics.RenderUtils2D +import com.lambda.client.util.graphics.VertexHelper +import com.lambda.client.util.graphics.font.FontRenderAdapter +import com.lambda.client.util.math.Vec2d +import com.lambda.client.util.notifications.Notification +import com.lambda.client.util.notifications.NotificationType +import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.threads.safeListener +import net.minecraft.client.gui.ScaledResolution +import net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.fml.common.gameevent.TickEvent +import org.lwjgl.opengl.GL11 + +object Notifications : Module( + name = "Notifications", + category = Category.CLIENT, + description = "Shows notifications", + alwaysListening = true, + showOnArray = false, + enabledByDefault = true +) { + private val page by setting("Page", Page.GENERAL) + + // General settings + private val mode by setting("Mode", NotificationMode.RENDER, { page == Page.GENERAL }) + private val notificationHeight by setting("Notification Height", 15.0, 13.0..25.0, 1.0, { page == Page.GENERAL }) + private val renderLocation by setting("Render Location", RenderLocation.BOTTOM_RIGHT, { page == Page.GENERAL }) + private val horizontalPadding by setting("W Padding", 6f, 0f..40f, 1f, { page == Page.GENERAL }) + private val verticalPadding by setting("H Padding", 15f, 0f..40f, 1f, { page == Page.GENERAL }) + + // Timeout settings + private val infoTimeout by setting("Info Timeout", 3000, 1000..10000, 100, { page == Page.TIMEOUT }) + private val warningTimeout by setting("Warning Timeout", 4000, 1000..10000, 100, { page == Page.TIMEOUT }) + private val errorTimeout by setting("Error Timeout", 7000, 1000..10000, 100, { page == Page.TIMEOUT }) + + enum class RenderLocation(val xValue:Int, val yValue: Int) { + BOTTOM_RIGHT(1,-1), BOTTOM_LEFT(-1,-1), TOP_RIGHT(1,1), TOP_LEFT(-1,1) + } + + enum class NotificationMode { + RENDER, CHAT, RENDER_AND_CHAT + } + + private enum class Page { + GENERAL, TIMEOUT + } + + private val notifications = mutableListOf() + + init { + safeListener { event -> + if (event.phase != TickEvent.Phase.END) return@safeListener + + val removalList = notifications.filter { notification -> + notification.startTime + notification.duration < System.currentTimeMillis() + } + notifications.removeAll(removalList) + } + + safeListener { + val scaledResolution = ScaledResolution(mc) + val vertexHelper = VertexHelper(GlStateUtils.useVbo()) + + var y = 0.0 + notifications.forEach { notification -> + GlStateManager.pushMatrix() + when (renderLocation) { + RenderLocation.BOTTOM_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), (scaledResolution.scaledHeight_double - verticalPadding - notificationHeight).toFloat(), 0f) + RenderLocation.BOTTOM_LEFT -> GL11.glTranslatef(horizontalPadding, (scaledResolution.scaledHeight_double - verticalPadding - notificationHeight).toFloat(), 0f) + RenderLocation.TOP_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), verticalPadding, 0f) + RenderLocation.TOP_LEFT -> GL11.glTranslatef(horizontalPadding, verticalPadding, 0f) + } + y += renderLocation.yValue * ((notificationHeight + 3.0) * notification.animate()) + GlStateManager.translate(0.0, y, 0.0) + drawNotification(vertexHelper, notification) + GlStateManager.popMatrix() + } + } + } + + private fun drawNotification(vertexHelper: VertexHelper, notification: Notification) { + + val startTime = notification.startTime + val duration = notification.duration + + val currentTime = System.currentTimeMillis() + val elapsedTime = currentTime - startTime + + val textScale = (notificationHeight / 32f).toFloat().coerceAtMost(1.0f) + val textWidth = FontRenderAdapter.getStringWidth(notification.text, textScale, CustomFont.isEnabled) + val textHeight = FontRenderAdapter.getFontHeight(textScale, CustomFont.isEnabled) + val textPosY = ((notificationHeight / 2.5) - (textHeight / 2)).toFloat() + + val width: Double = if (textWidth > 88) textWidth + 25.0 else 90.0 + val clearWidth = width - 2 + + val timeout = (clearWidth * elapsedTime) / duration + val timeoutBarWidth = if (timeout > clearWidth) clearWidth else if (timeout < 0) 0 else timeout + + val borderPosBegin = if (renderLocation.name.contains("RIGHT")) Vec2d(width, 0.0) else Vec2d(0.0, 0.0) + val borderPosEnd = if (renderLocation.name.contains("RIGHT")) Vec2d(clearWidth, notificationHeight) else Vec2d(2.0, notificationHeight) + + val timeoutBarPosBegin = if (renderLocation.name.contains("RIGHT")) Vec2d(timeoutBarWidth.toDouble(), notificationHeight) + else Vec2d(2.0, notificationHeight) + val timeoutBarPosEnd = if (renderLocation.name.contains("RIGHT")) Vec2d(clearWidth, notificationHeight - 1) + else Vec2d(clearWidth - timeoutBarWidth.toDouble(), notificationHeight - 1) + + val alpha: Int = when (elapsedTime) { + // "Fade in" alpha + in 0..duration - 200 -> + ((255 * elapsedTime) / 200).toInt().coerceAtMost(255).coerceAtLeast(0) + + // "Fade out" alpha + in duration - 200..duration -> { + val timeLeft = duration - elapsedTime + ((255 * timeLeft) / 200).toInt().coerceAtMost(255).coerceAtLeast(0) + } + + else -> 0 + } + + val color = colorFromType(notification.type, alpha) + val backgroundColor: ColorHolder = when (alpha) { + in 0..GuiColors.backGround.a -> ColorHolder(GuiColors.backGround.r, GuiColors.backGround.g, + GuiColors.backGround.b, alpha) + + else -> GuiColors.backGround + } + + GlStateManager.pushMatrix() + val animatedPercent = notification.animate() + val animationXOffset = textWidth * renderLocation.xValue *(1.0f - animatedPercent) + GlStateManager.translate(animationXOffset,0.0f,0.0f) + + + // Draw background + RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(width, notificationHeight), backgroundColor) + + // Draw timeout bar + RenderUtils2D.drawRectFilled(vertexHelper, timeoutBarPosBegin, timeoutBarPosEnd, color) + + // Draw border + RenderUtils2D.drawRectFilled(vertexHelper, borderPosBegin, borderPosEnd, color) + + // Draw text + FontRenderAdapter.drawString(notification.text, 4.0f, textPosY, true, + ColorHolder(255, 255, 255, alpha), textScale, CustomFont.isEnabled) + + GlStateManager.popMatrix() + } + + fun addNotification(notification: Notification) { + if (notification.duration == 0) when (notification.type) { + NotificationType.INFO -> notification.duration = infoTimeout + NotificationType.WARNING -> notification.duration = warningTimeout + NotificationType.ERROR -> notification.duration = errorTimeout + } + + if (mode == NotificationMode.CHAT || mode == NotificationMode.RENDER_AND_CHAT) { + MessageSendHelper.sendChatMessage(notification.text) + } + if (mode == NotificationMode.RENDER || mode == NotificationMode.RENDER_AND_CHAT) { + notifications.add(notification) + } + } + + private fun colorFromType(notificationType: NotificationType, alpha: Int = 255): ColorHolder = when (notificationType) { + NotificationType.INFO -> ColorHolder(3, 169, 244, alpha) + NotificationType.WARNING -> ColorHolder(255, 255, 0, alpha) + NotificationType.ERROR -> ColorHolder(255, 0, 0, alpha) + } + private fun Notification.animate() : Float{ + return if ((System.currentTimeMillis() - startTime) < (duration.toLong() / 2)){ + AnimationUtils.exponentInc(AnimationUtils.toDeltaTimeFloat(startTime), 200.0f) + }else{ + AnimationUtils.exponentDec(AnimationUtils.toDeltaTimeFloat(startTime + duration - 200), 200.0f) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index 441782e46..c49eb37df 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -3,6 +3,7 @@ package com.lambda.client.module.modules.combat import com.lambda.client.commons.extension.next import com.lambda.client.event.SafeClientEvent import com.lambda.client.manager.managers.CombatManager +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.Bind @@ -10,7 +11,6 @@ import com.lambda.client.util.combat.CombatUtils.calcDamageFromMob import com.lambda.client.util.combat.CombatUtils.calcDamageFromPlayer import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.* -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener import net.minecraft.entity.item.EntityEnderCrystal import net.minecraft.entity.monster.EntityMob @@ -145,7 +145,7 @@ object AutoOffhand : Module( moveToSlot(this@AutoOffhand, slot, player.offhandSlot) - if (switchMessage) MessageSendHelper.sendChatMessage("$chatName Offhand now has a ${typeAlt.toString().lowercase()}") + if (switchMessage) NotificationManager.registerNotification("$chatName Offhand now has a ${typeAlt.toString().lowercase()}") } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt index a3809183d..e2f1ffec8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt @@ -13,6 +13,7 @@ import com.lambda.client.manager.managers.HotbarManager import com.lambda.client.manager.managers.HotbarManager.resetHotbar import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.manager.managers.PlayerPacketManager import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.useEntityAction @@ -36,7 +37,6 @@ import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.math.VectorUtils.toBlockPos import com.lambda.client.util.math.VectorUtils.toVec3d import com.lambda.client.util.math.VectorUtils.toVec3dCenter -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.getClosestVisibleSide @@ -192,7 +192,7 @@ object CrystalAura : Module( listener { if (bindForcePlace.isDown(Keyboard.getEventKey())) { forcePlacing = !forcePlacing - MessageSendHelper.sendChatMessage("$chatName Force placing" + if (forcePlacing) " &aenabled" else " &cdisabled") + NotificationManager.registerNotification("$chatName Force placing" + if (forcePlacing) " &aenabled" else " &cdisabled") } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt index 71ca05d76..14a3fffb5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt @@ -6,10 +6,10 @@ import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.FriendManager +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.color.EnumTextColor -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.text.format import com.lambda.client.util.threads.safeListener @@ -117,7 +117,7 @@ object TotemPopCounter : Module( if (public) { sendServerMessage(TextFormatting.getTextWithoutFormattingCodes(message)) } else { - MessageSendHelper.sendChatMessage("$chatName $message") + NotificationManager.registerNotification(message) } } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/VisualRange.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/VisualRange.kt index 6245636ca..b735b2841 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/VisualRange.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/VisualRange.kt @@ -1,6 +1,7 @@ package com.lambda.client.module.modules.combat import com.lambda.client.manager.managers.FriendManager +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.manager.managers.WaypointManager import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -8,7 +9,7 @@ import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.EntityUtils.isFakeOrSelf import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.text.format import com.lambda.client.util.threads.safeListener @@ -91,6 +92,6 @@ object VisualRange : Module( private fun sendNotification(message: String) { if (playSound) mc.soundHandler.playSound(PositionedSoundRecord.getRecord(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f)) - MessageSendHelper.sendChatMessage(message) + NotificationManager.registerNotification(message, NotificationType.WARNING) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt b/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt new file mode 100644 index 000000000..cd793c970 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt @@ -0,0 +1,8 @@ +package com.lambda.client.util.notifications + +data class Notification( + val text: String, + val type: NotificationType, + var duration: Int = 0, + val startTime: Long = System.currentTimeMillis(), +) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/notifications/NotificationType.kt b/src/main/kotlin/com/lambda/client/util/notifications/NotificationType.kt new file mode 100644 index 000000000..4a4cb8d04 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/util/notifications/NotificationType.kt @@ -0,0 +1,7 @@ +package com.lambda.client.util.notifications + +enum class NotificationType { + INFO, + WARNING, + ERROR +} \ No newline at end of file