diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt | 36 |
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 |