diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-04 12:55:23 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-04 12:55:23 +0100 |
commit | df852759ff8a183e65b58e14aeaf99155fad563c (patch) | |
tree | 2c3caec466f3e2c2fddd098d9d1bdcdb4b6316fc /src/main/java/at/hannibal2/skyhanni/features/bingo | |
parent | f61770ac53e7599b31433536a6313dd94d438e71 (diff) | |
download | skyhanni-df852759ff8a183e65b58e14aeaf99155fad563c.tar.gz skyhanni-df852759ff8a183e65b58e14aeaf99155fad563c.tar.bz2 skyhanni-df852759ff8a183e65b58e14aeaf99155fad563c.zip |
Created BingoGoalReachedEvent.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/bingo')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt | 19 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt | 30 |
2 files changed, 34 insertions, 15 deletions
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() + } +} |