aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-02-28 20:16:26 +0100
committerGitHub <noreply@github.com>2024-02-28 20:16:26 +0100
commitfbadabdb0ddb0bba18aa7421ffb09795463ea07f (patch)
tree573f429859724163658bf70c2a3a4cbb2dae55d2 /src
parent2be485fee5a537159f936061b2ee3b3847e198b9 (diff)
downloadskyhanni-fbadabdb0ddb0bba18aa7421ffb09795463ea07f.tar.gz
skyhanni-fbadabdb0ddb0bba18aa7421ffb09795463ea07f.tar.bz2
skyhanni-fbadabdb0ddb0bba18aa7421ffb09795463ea07f.zip
Fixed rare error reading and rendering Bingo Card Tips in Bingo inventory. (#983)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
index 6148848b6..fd3312519 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
@@ -6,10 +6,13 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.features.bingo.BingoAPI
import at.hannibal2.skyhanni.features.bingo.BingoAPI.getData
import at.hannibal2.skyhanni.features.bingo.card.goals.GoalType
+import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
+import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.inventory.ContainerChest
@@ -19,10 +22,24 @@ class BingoCardTips {
private val config get() = SkyHanniMod.feature.event.bingo.bingoCard
+ private val patternGroup = RepoPattern.group("bingo.card.tips")
+ private val inventoryPattern by patternGroup.pattern(
+ "card",
+ "Bingo Card"
+ )
+ private val rewardPattern by patternGroup.pattern(
+ "reward",
+ "§.§.§7Reward"
+ )
+ private val contributionRewardsPattern by patternGroup.pattern(
+ "reward.contribution",
+ "§.§.§7Contribution Rewards.*"
+ )
+
@SubscribeEvent
fun onItemTooltipLow(event: LorenzToolTipEvent) {
if (!isEnabled()) return
- if (InventoryUtils.openInventoryName() != "Bingo Card") return
+ if (!inventoryPattern.matches(InventoryUtils.openInventoryName())) return
val gui = Minecraft.getMinecraft().currentScreen as? GuiContainer ?: return
val slot = gui.slotUnderMouse
@@ -36,11 +53,22 @@ class BingoCardTips {
toolTip[0] = toolTip[0] + " §7(" + difficulty.displayName + "§7)"
var index = if (!communityGoal) {
- toolTip.indexOf("§5§o§7Reward")
+ toolTip.indexOfFirst { rewardPattern.matches(it) }
} else {
- toolTip.indexOfFirst { it.startsWith("§5§o§7Contribution Rewards") }
+ toolTip.indexOfFirst { contributionRewardsPattern.matches(it) }
} - 1
+ if (index == -2) {
+ ErrorManager.logErrorWithData(
+ IndexOutOfBoundsException(),
+ "BingoCardTips reward line not found",
+ "goal displayName" to goal.displayName,
+ "slot slotNumber" to slot.slotNumber,
+ "toolTip" to toolTip
+ )
+ return
+ }
+
toolTip.add(index++, "")
toolTip.add(index++, "§eGuide:")
for (line in bingoTip.guide) {
@@ -54,7 +82,7 @@ class BingoCardTips {
@SubscribeEvent
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!isEnabled()) return
- if (InventoryUtils.openInventoryName() != "Bingo Card") return
+ if (!inventoryPattern.matches(InventoryUtils.openInventoryName())) return
val guiChest = event.gui
val chest = guiChest.inventorySlots as ContainerChest