diff options
Diffstat (limited to 'src/main/java')
4 files changed, 42 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 2c47822cc..75a8ca20f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -58,6 +58,7 @@ import at.hannibal2.skyhanni.features.bingo.BingoCardTips import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper import at.hannibal2.skyhanni.features.bingo.CompactBingoChat import at.hannibal2.skyhanni.features.bingo.MinionCraftHelper +import at.hannibal2.skyhanni.features.bingo.card.BingoCardReader import at.hannibal2.skyhanni.features.chat.ArachneChatMessageHider import at.hannibal2.skyhanni.features.chat.ChatFilter import at.hannibal2.skyhanni.features.chat.CompactBestiaryChatMessage @@ -400,6 +401,7 @@ class SkyHanniMod { loadModule(KeyboardManager) loadModule(AdvancedPlayerList) loadModule(ItemAddManager()) + loadModule(BingoCardReader()) // APIs loadModule(BazaarApi()) diff --git a/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoGoalReachedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoGoalReachedEvent.kt new file mode 100644 index 000000000..46f0f3722 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoGoalReachedEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.bingo + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.features.bingo.card.BingoGoal + +class BingoGoalReachedEvent(val goal: BingoGoal) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt index dc09ace95..95e01c058 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt @@ -6,8 +6,8 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson.BingoTip import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.bingo.BingoGoalReachedEvent import at.hannibal2.skyhanni.features.bingo.card.BingoGoal import at.hannibal2.skyhanni.features.bingo.card.GoalType import at.hannibal2.skyhanni.utils.InventoryUtils @@ -32,9 +32,6 @@ class BingoCardDisplay { private var display = emptyList<String>() - // TODO USE SH-REPO - private val goalCompletePattern = "§6§lBINGO GOAL COMPLETE! §r§e(?<name>.*)".toPattern() - private var lastBingoCardOpenTime = SimpleTimeMark.farPast() private var hasHiddenPersonalGoals = false @@ -265,18 +262,10 @@ class BingoCardDisplay { } @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (!LorenzUtils.isBingoProfile) return + fun onBingoGoalReached(event: BingoGoalReachedEvent) { if (!config.enabled) return - - goalCompletePattern.matchMatcher(event.message) { - val name = group("name") - BingoAPI.personalGoals.filter { it.displayName == name } - .forEach { - it.done = true - update() - } - } + event.goal.done = true + update() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt new file mode 100644 index 000000000..9db12c72f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt @@ -0,0 +1,30 @@ +package at.hannibal2.skyhanni.features.bingo.card + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.bingo.BingoGoalReachedEvent +import at.hannibal2.skyhanni.features.bingo.BingoAPI +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class BingoCardReader { + private val config get() = SkyHanniMod.feature.event.bingo.bingoCard + + // TODO USE SH-REPO + private val goalCompletePattern = "§6§lBINGO GOAL COMPLETE! §r§e(?<name>.*)".toPattern() + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!LorenzUtils.isBingoProfile) return + if (!config.enabled) return + + val name = goalCompletePattern.matchMatcher(event.message) { + group("name") + } ?: return + + val goal = BingoAPI.personalGoals.firstOrNull { it.displayName == name } ?: return + + BingoGoalReachedEvent(goal).postAndCatch() + } +} |