From 98ee1143de725f33db04c68f557dc99d199b4a8a Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 20 Oct 2024 17:02:28 -0400 Subject: [PATCH 1/7] Fix item stash compacting, block empty line in messages --- .../skyhanni/features/chat/StashCompact.kt | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt index bcb4f61945bc..6ad2eae578f8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt @@ -23,10 +23,11 @@ object StashCompact { /** * REGEX-TEST: §f §7You have §3226 §7materials stashed away! * REGEX-TEST: §f §7You have §31,000 §7items stashed away! + * REGEX-TEST: §f §7You have §a2 §7items stashed away! */ private val materialCountPattern by patternGroup.pattern( "material.count", - "§f *§7You have §3(?[\\d,]+) (?:§.)+(?item|material)s? stashed away!.*", + "§f *§7You have §.(?[\\d,]+) (?:§.)+(?item|material)s? stashed away!.*", ) /** @@ -42,10 +43,11 @@ object StashCompact { /** * REGEX-TEST: §f §3§l>>> §3§lCLICK HERE§b to pick them up! §3§l<<< + * REGEX-TEST: §f §6§l>>> §6§lCLICK HERE§e to pick them up! §6§l<<< */ private val pickupStashPattern by patternGroup.pattern( "pickup.stash", - "§f *§3§l>>> §3§lCLICK HERE§b to pick (?:them|it) up! §3§l<<<.*", + "§f *§.§l>>> §.§lCLICK HERE§b to pick (?:them|it) up! §.§l<<<.*", ) /** @@ -68,12 +70,17 @@ object StashCompact { private var lastSentMaterialCount = 0 private var lastSentType = "" + private var openMessage = false + @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return + if(event.message.isEmpty() && openMessage) event.blockedReason = "stash_compact" + genericAddedToStashPattern.matchMatcher(event.message) { event.blockedReason = "stash_compact" + openMessage = true } materialCountPattern.matchMatcher(event.message) { @@ -97,6 +104,7 @@ object StashCompact { event.blockedReason = "stash_compact" if (lastMaterialCount <= config.hideLowWarningsThreshold) return if (config.hideDuplicateCounts && lastMaterialCount == lastSentMaterialCount && lastType == lastSentType) return + openMessage = false sendCompactedStashMessage() } @@ -104,10 +112,12 @@ object StashCompact { private fun sendCompactedStashMessage() { val typeNameFormat = StringUtils.pluralize(lastMaterialCount, lastType) - val typeFormat = StringUtils.pluralize(lastDifferingMaterialsCount, "type") + val typeStringExtra = + if (lastDifferingMaterialsCount == 0) "." + else ", §etotalling §6$lastDifferingMaterialsCount ${StringUtils.pluralize(lastDifferingMaterialsCount, "type")}§6." + ChatUtils.clickableChat( - "§eYou have §6$lastMaterialCount §e$typeNameFormat in stash§6, " + - "§etotalling §6$lastDifferingMaterialsCount $typeFormat§6. " + + "§eYou have §6$lastMaterialCount §e$typeNameFormat in stash§6${typeStringExtra} " + "§eClick to ${if (config.useViewStash) "§6view" else "§6pickup"} §estash§6.", onClick = { if (config.useViewStash) HypixelCommands.viewStash(lastType) @@ -116,6 +126,9 @@ object StashCompact { ) lastSentMaterialCount = lastMaterialCount lastSentType = lastType + // Dirty, but item stash doesn't always have differing materials count, + // and we don't compare this value to the last one, so we can reset it here + lastDifferingMaterialsCount = 0 } private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled From 35a4758fdbeb5a54d212d3f5855181f53e24c346 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 20 Oct 2024 17:06:04 -0400 Subject: [PATCH 2/7] One more --- .../java/at/hannibal2/skyhanni/features/chat/StashCompact.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt index 6ad2eae578f8..b334c7b1719c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt @@ -47,7 +47,7 @@ object StashCompact { */ private val pickupStashPattern by patternGroup.pattern( "pickup.stash", - "§f *§.§l>>> §.§lCLICK HERE§b to pick (?:them|it) up! §.§l<<<.*", + "§f *§.§l>>> §.§lCLICK HERE§. to pick (?:them|it) up! §.§l<<<.*", ) /** From 07b470af8ecf0f94414d3702f8f6599c15085756 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 20 Oct 2024 17:18:02 -0400 Subject: [PATCH 3/7] Empty lines are in stupid spots :3 --- .../at/hannibal2/skyhanni/features/chat/StashCompact.kt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt index b334c7b1719c..f358a55a9f90 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt @@ -70,17 +70,12 @@ object StashCompact { private var lastSentMaterialCount = 0 private var lastSentType = "" - private var openMessage = false - @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return - if(event.message.isEmpty() && openMessage) event.blockedReason = "stash_compact" - genericAddedToStashPattern.matchMatcher(event.message) { event.blockedReason = "stash_compact" - openMessage = true } materialCountPattern.matchMatcher(event.message) { @@ -104,7 +99,6 @@ object StashCompact { event.blockedReason = "stash_compact" if (lastMaterialCount <= config.hideLowWarningsThreshold) return if (config.hideDuplicateCounts && lastMaterialCount == lastSentMaterialCount && lastType == lastSentType) return - openMessage = false sendCompactedStashMessage() } @@ -126,9 +120,6 @@ object StashCompact { ) lastSentMaterialCount = lastMaterialCount lastSentType = lastType - // Dirty, but item stash doesn't always have differing materials count, - // and we don't compare this value to the last one, so we can reset it here - lastDifferingMaterialsCount = 0 } private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled From be8057e6b050e23754418b666547d3f333e77b07 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 20 Oct 2024 17:22:13 -0400 Subject: [PATCH 4/7] notice --- .../skyhanni/config/features/chat/StashConfig.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/StashConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/StashConfig.java index 92fdd8c4405d..225c81302a10 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/StashConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/StashConfig.java @@ -3,6 +3,7 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; @@ -14,6 +15,14 @@ public class StashConfig { @FeatureToggle public boolean enabled = true; + @ConfigOption( + name = "§cNotice", + desc = "Due to Hypixel sending empty messages before and after the stash message, " + + "you may see empty lines still. Turn on `/sh empty messages` to solve for this." + ) + @ConfigEditorInfoText + public String notice = ""; + @Expose @ConfigOption(name = "Hide Duplicate Warnings", desc = "Hide duplicate warnings for previously reported stash counts.") @ConfigEditorBoolean From e6abb1d7626fca45ab72ca4113f0bb61ee960791 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 20 Oct 2024 17:23:55 -0400 Subject: [PATCH 5/7] I did actually need that --- .../java/at/hannibal2/skyhanni/features/chat/StashCompact.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt index f358a55a9f90..b764f9bcfe12 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt @@ -120,6 +120,9 @@ object StashCompact { ) lastSentMaterialCount = lastMaterialCount lastSentType = lastType + // Dirty, but item stash doesn't always have differing materials count, + // and we don't compare this value to the last one, so we can reset it here + lastDifferingMaterialsCount = 0 } private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled From 94e8fb42c6b327a1c7060520c51c528b7f963f7a Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 20 Oct 2024 17:26:56 -0400 Subject: [PATCH 6/7] Better wording --- .../hannibal2/skyhanni/config/features/chat/StashConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/StashConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/StashConfig.java index 225c81302a10..738f24c93193 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/StashConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/StashConfig.java @@ -17,8 +17,8 @@ public class StashConfig { @ConfigOption( name = "§cNotice", - desc = "Due to Hypixel sending empty messages before and after the stash message, " + - "you may see empty lines still. Turn on `/sh empty messages` to solve for this." + desc = "Hypixel sends un-detectable empty messages wrapping the stash message. " + + "Enable §e§l/sh empty messages §r§7to hide them." ) @ConfigEditorInfoText public String notice = ""; From db7778b2eb0375cb8a6b32ce79fecae39c0916c9 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 20 Oct 2024 23:53:04 +0200 Subject: [PATCH 7/7] code cleanup --- .../at/hannibal2/skyhanni/features/chat/StashCompact.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt index b764f9bcfe12..c33aac59176d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt @@ -106,9 +106,9 @@ object StashCompact { private fun sendCompactedStashMessage() { val typeNameFormat = StringUtils.pluralize(lastMaterialCount, lastType) - val typeStringExtra = - if (lastDifferingMaterialsCount == 0) "." - else ", §etotalling §6$lastDifferingMaterialsCount ${StringUtils.pluralize(lastDifferingMaterialsCount, "type")}§6." + val typeStringExtra = lastDifferingMaterialsCount.let { + if (it == 0) "." else ", §etotalling §6$it ${StringUtils.pluralize(it, "type")}§6." + } ChatUtils.clickableChat( "§eYou have §6$lastMaterialCount §e$typeNameFormat in stash§6${typeStringExtra} " +