summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/event
diff options
context:
space:
mode:
authorHiZe <super@hize.be>2024-05-30 13:18:05 +0200
committerGitHub <noreply@github.com>2024-05-30 13:18:05 +0200
commita6133f8ff76b2e8ed00ff707c2e4bd7f75112c8f (patch)
tree02f9f3278f314229c0f4e3b96be193be5e301574 /src/main/java/at/hannibal2/skyhanni/features/event
parent5d89d56e1a480ae26f325c995a66a4b40a436638 (diff)
downloadskyhanni-a6133f8ff76b2e8ed00ff707c2e4bd7f75112c8f.tar.gz
skyhanni-a6133f8ff76b2e8ed00ff707c2e4bd7f75112c8f.tar.bz2
skyhanni-a6133f8ff76b2e8ed00ff707c2e4bd7f75112c8f.zip
Feature: Highlight rabbits with requirement (#1874)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt36
1 files changed, 36 insertions, 0 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 f8ef5ac62..b570ae373 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,13 +1,16 @@
package at.hannibal2.skyhanni.features.event.hoppity
import at.hannibal2.skyhanni.data.ProfileStorageData
+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.features.inventory.chocolatefactory.ChocolateFactoryAPI
import at.hannibal2.skyhanni.utils.ChatUtils
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
@@ -15,8 +18,10 @@ 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.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
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
@@ -49,6 +54,22 @@ object HoppityCollectionStats {
"rabbits.found",
"§.§l§m[ §a-z]+§r §.(?<current>[0-9]+)§./§.(?<total>[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.*",
+ )
private var display = emptyList<Renderable>()
private val loggedRabbits
@@ -82,6 +103,21 @@ object HoppityCollectionStats {
)
}
+ // TODO cache with inventory update event
+ @SubscribeEvent
+ fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ if (!config.highlightRabbitsWithRequirement) return
+ if (!inInventory) return
+
+ for (slot in InventoryUtils.getItemsInOpenChest()) {
+ val lore = slot.stack.getLore()
+ if (lore.any { requirementMet.find(it) } && !config.onlyHighlightRequirementNotMet)
+ slot highlight LorenzColor.GREEN
+ if (lore.any { requirementNotMet.find(it) })
+ slot highlight LorenzColor.RED
+ }
+ }
+
private fun buildDisplay(event: InventoryFullyOpenedEvent): MutableList<Renderable> {
logRabbits(event)