From 4d7ab85967f40c897699d67ec2eef59826a4341b Mon Sep 17 00:00:00 2001 From: Baitinq Date: Fri, 6 Jan 2023 23:21:48 +0100 Subject: [PATCH 1/2] AutoOffhand: Add "Show Remaining" option This option shows the remaining number of items of type AutoOffhandType in the inventory next to the module name in the HUD. --- .../client/module/modules/combat/AutoOffhand.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 1d027b275..c10e75b24 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 @@ -66,6 +66,11 @@ object AutoOffhand : Module( // General private val priority by setting("Priority", Priority.HOTBAR) private val switchMessage by setting("Switch Message", true) + private val showRemaining by setting("Show Remaining", true); + + + // Represents the remaining number of items of type AutoOffhandType in the inventory + private var hudInfo = "" private enum class Type(val filter: (ItemStack) -> Boolean) { TOTEM({ it.item.id == 449 }), @@ -98,9 +103,16 @@ object AutoOffhand : Module( updateDamage() switchToType(getType(), true) + + + hudInfo = if (showRemaining) player.allSlots.asSequence().filter {it.hasStack}.map{it.stack}.filter(type.filter).map{it.count}.fold(0) { acc, i -> acc + i }.toString() else "" } } + override fun getHudInfo(): String { + return hudInfo + } + private fun SafeClientEvent.getType() = when { checkTotem() -> Type.TOTEM checkStrength() -> Type.STRENGTH From 2ed8fce3bac07497f4ec7ffbc3acd6eadc02fb3f Mon Sep 17 00:00:00 2001 From: Constructor Date: Sun, 8 Jan 2023 19:08:48 +0100 Subject: [PATCH 2/2] Cleanup --- .../lambda/client/module/modules/combat/AutoOffhand.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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 c10e75b24..8e75e5a81 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 @@ -66,8 +66,6 @@ object AutoOffhand : Module( // General private val priority by setting("Priority", Priority.HOTBAR) private val switchMessage by setting("Switch Message", true) - private val showRemaining by setting("Show Remaining", true); - // Represents the remaining number of items of type AutoOffhandType in the inventory private var hudInfo = "" @@ -104,14 +102,11 @@ object AutoOffhand : Module( switchToType(getType(), true) - - hudInfo = if (showRemaining) player.allSlots.asSequence().filter {it.hasStack}.map{it.stack}.filter(type.filter).map{it.count}.fold(0) { acc, i -> acc + i }.toString() else "" + hudInfo = player.allSlots.countByStack { type.filter(it) }.toString() } } - override fun getHudInfo(): String { - return hudInfo - } + override fun getHudInfo() = hudInfo private fun SafeClientEvent.getType() = when { checkTotem() -> Type.TOTEM