From a0ee43c10fa0e3e1d411b07bc39fddd9b197e2d2 Mon Sep 17 00:00:00 2001 From: superhize Date: Fri, 24 May 2024 05:25:55 +0200 Subject: [PATCH 1/3] highlight rabbit with requirement --- .../ChocolateFactoryConfig.java | 8 ++++++++ .../event/hoppity/HoppityCollectionStats.kt | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index 3f86dfefe044..37bdc2282497 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -171,6 +171,14 @@ public class ChocolateFactoryConfig { @FeatureToggle public boolean hoppityMenuShortcut = true; + @Expose + @ConfigOption(name = "Highlight Collection", + desc = "Highlight rabbits with a requirement in the collection menu. " + + "Green if you meet the requirement, red if you don't.") + @ConfigEditorBoolean + @FeatureToggle + public boolean collectionHighlight = true; + @Expose @ConfigOption(name = "Chocolate Shop Price", desc = "") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt index e632bf12ee97..14b6aba1199f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt @@ -1,17 +1,21 @@ package at.hannibal2.skyhanni.features.event.hoppity +import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.utils.DisplayTableEntry +import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -83,6 +87,20 @@ object HoppityCollectionStats { ) } + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!config.collectionHighlight) return + if (!inInventory) return + + for (slot in InventoryUtils.getItemsInOpenChest()) { + val lore = slot.stack.getLore() + if (lore.any { it.contains("§a✔ §7Requirement") }) + slot highlight LorenzColor.GREEN + if (lore.any { it.contains("§c✖ §7Requirement") }) + slot highlight LorenzColor.RED + } + } + private fun buildDisplay(event: InventoryFullyOpenedEvent): MutableList { val totalAmount = logRabbits(event) From c85d7988288314db1e6df3ef21f6073be74fa245 Mon Sep 17 00:00:00 2001 From: superhize Date: Tue, 28 May 2024 18:25:53 +0200 Subject: [PATCH 2/3] changes --- .../chocolatefactory/ChocolateFactoryConfig.java | 14 ++++++++++---- .../event/hoppity/HoppityCollectionStats.kt | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index 37bdc2282497..5f59c6fc58da 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -172,12 +172,18 @@ public class ChocolateFactoryConfig { public boolean hoppityMenuShortcut = true; @Expose - @ConfigOption(name = "Highlight Collection", - desc = "Highlight rabbits with a requirement in the collection menu. " + - "Green if you meet the requirement, red if you don't.") + @ConfigOption(name = "Highlight Requirement Rabbits", desc = "Highlight rabbits that have requirements.\n" + + "§cRed: Requirement not met.\n" + + "§aGreen: Requirement met.") @ConfigEditorBoolean @FeatureToggle - public boolean collectionHighlight = true; + public boolean highlightRabbitsWithRequirement = false; + + @Expose + @ConfigOption(name = "Only Requirement Not Met", desc = "Only highlight the rabbits you don't have the requirement for.") + @ConfigEditorBoolean + @FeatureToggle + public boolean onlyHighlightRequirementNotMet = true; @Expose @ConfigOption(name = "Chocolate Shop Price", desc = "") diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt index 14b6aba1199f..e47a0b0f02ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables +import at.hannibal2.skyhanni.utils.StringUtils.find import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -47,6 +48,14 @@ object HoppityCollectionStats { "rabbits.found", "§.§l§m[ §a-z]+§r §.(?[0-9]+)§./§.(?[0-9]+)" ) + private val requirementMet by patternGroup.pattern( + "rabbit.requirement.met", + "§a✔ §7Requirement" + ) + private val requirementNotMet by patternGroup.pattern( + "rabbit.requirement.notmet", + "§c✖ §7Requirement.*", + ) private var display = emptyList() private val loggedRabbits = mutableMapOf() @@ -89,14 +98,14 @@ object HoppityCollectionStats { @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { - if (!config.collectionHighlight) return + if (!config.highlightRabbitsWithRequirement) return if (!inInventory) return for (slot in InventoryUtils.getItemsInOpenChest()) { val lore = slot.stack.getLore() - if (lore.any { it.contains("§a✔ §7Requirement") }) + if (lore.any { requirementMet.find(it) } && !config.onlyHighlightRequirementNotMet) slot highlight LorenzColor.GREEN - if (lore.any { it.contains("§c✖ §7Requirement") }) + if (lore.any { requirementNotMet.find(it) }) slot highlight LorenzColor.RED } } From 915021b7eaa8ca944def6693dec512ca3c61bb2b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 30 May 2024 13:16:21 +0200 Subject: [PATCH 3/3] added regex test and toto --- .../event/hoppity/HoppityCollectionStats.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt index 7738f7e4ebe0..b570ae37338d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt @@ -17,8 +17,8 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.RegexUtils.find import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches +import at.hannibal2.skyhanni.utils.RegexUtils.find import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.highlight @@ -54,10 +54,18 @@ object HoppityCollectionStats { "rabbits.found", "§.§l§m[ §a-z]+§r §.(?[0-9]+)§./§.(?[0-9]+)" ) + /** + * REGEX-TEST: §a✔ §7Requirement + */ private val requirementMet by patternGroup.pattern( "rabbit.requirement.met", "§a✔ §7Requirement" ) + /** + * REGEX-TEST: §c✖ §7Requirement §e0§7/§a15 + * REGEX-TEST: §c✖ §7Requirement §e6§7/§a20 + * REGEX-TEST: §c✖ §7Requirement §e651§7/§a1,000 + */ private val requirementNotMet by patternGroup.pattern( "rabbit.requirement.notmet", "§c✖ §7Requirement.*", @@ -95,6 +103,7 @@ object HoppityCollectionStats { ) } + // TODO cache with inventory update event @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { if (!config.highlightRabbitsWithRequirement) return @@ -106,8 +115,6 @@ object HoppityCollectionStats { slot highlight LorenzColor.GREEN if (lore.any { requirementNotMet.find(it) }) slot highlight LorenzColor.RED - - } }