diff options
author | appable <enzospiacitelli@gmail.com> | 2023-08-10 09:17:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 18:17:25 +0200 |
commit | 3f7202d1d5c56d84947959b4f05682a704d781f2 (patch) | |
tree | 0c7bc706a7060ab94ea35917b948f4c5af3754e2 | |
parent | 77ffcdd576b4dfdae5ad41826964bbee8db0ca1a (diff) | |
download | skyhanni-3f7202d1d5c56d84947959b4f05682a704d781f2.tar.gz skyhanni-3f7202d1d5c56d84947959b4f05682a704d781f2.tar.bz2 skyhanni-3f7202d1d5c56d84947959b4f05682a704d781f2.zip |
Merge pull request #373
Shark fish counter now counts twice for Double hook.
5 files changed, 34 insertions, 31 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 6b42f9397..8fcd342da 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -142,14 +142,6 @@ object ChatManager { return false } - @SubscribeEvent - fun onChatMessage(chatEvent: LorenzChatEvent) { - if (!LorenzUtils.inSkyBlock) return - - val seaCreature = SeaCreatureManager.getSeaCreature(chatEvent.message) ?: return - SeaCreatureFishEvent(seaCreature, chatEvent).postAndCatch() - } - fun openChatFilterGUI() { SkyHanniMod.screenToOpen = ChatFilterGui(getRecentMessageHistory()) } diff --git a/src/main/java/at/hannibal2/skyhanni/events/SeaCreatureFishEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SeaCreatureFishEvent.kt index 545b282ce..6d3d39299 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/SeaCreatureFishEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/SeaCreatureFishEvent.kt @@ -2,4 +2,8 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.features.fishing.SeaCreature -class SeaCreatureFishEvent(val seaCreature: SeaCreature, val chatEvent: LorenzChatEvent) : LorenzEvent()
\ No newline at end of file +class SeaCreatureFishEvent( + val seaCreature: SeaCreature, + val chatEvent: LorenzChatEvent, + val doubleHook: Boolean +) : LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt index 73a358e69..ede9cd568 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt @@ -1,11 +1,33 @@ package at.hannibal2.skyhanni.features.fishing +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class SeaCreatureManager { + private var doubleHook = false + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!LorenzUtils.inSkyBlock) return + if (doubleHookMessages.contains(event.message)) { + if (SkyHanniMod.feature.fishing.compactDoubleHook) { + event.blockedReason = "double_hook" + } + doubleHook = true + } else { + val seaCreature = getSeaCreature(event.message) + if (seaCreature != null) { + SeaCreatureFishEvent(seaCreature, event, doubleHook).postAndCatch() + } + doubleHook = false + } + } + @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { seaCreatureMap.clear() @@ -44,6 +66,11 @@ class SeaCreatureManager { private val seaCreatureMap = mutableMapOf<String, SeaCreature>() var allFishingMobNames = emptyList<String>() + private val doubleHookMessages = setOf( + "§eIt's a §r§aDouble Hook§r§e! Woot woot!", + "§eIt's a §r§aDouble Hook§r§e!" + ) + fun getSeaCreature(message: String): SeaCreature? { return seaCreatureMap.getOrDefault(message, null) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt index 848601751..5880d357c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt @@ -8,20 +8,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class SeaCreatureMessageShortener { - private var nextIsDoubleHook: Boolean = false - private val config get() = SkyHanniMod.feature.fishing - @SubscribeEvent(priority = EventPriority.LOW) - fun onChatMessage(event: LorenzChatEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!config.shortenFishingMessage && !config.compactDoubleHook) return - if (doubleHookMessages.contains(event.message)) { - event.blockedReason = "double_hook" - nextIsDoubleHook = true - } - } - @SubscribeEvent fun onSeaCreatureFish(event: SeaCreatureFishEvent) { if (!LorenzUtils.inSkyBlock) return @@ -33,8 +21,7 @@ class SeaCreatureMessageShortener { "§9You caught a $seaCreature§9!" } else event.chatEvent.message - if (config.compactDoubleHook && nextIsDoubleHook) { - nextIsDoubleHook = false + if (config.compactDoubleHook && event.doubleHook) { message = "§e§lDOUBLE HOOK! $message" } LorenzUtils.chat(message) @@ -43,11 +30,4 @@ class SeaCreatureMessageShortener { LorenzUtils.debug("no fishing exp set for " + seaCreature.displayName) } } - - companion object { - private val doubleHookMessages = setOf( - "§eIt's a §r§aDouble Hook§r§e! Woot woot!", - "§eIt's a §r§aDouble Hook§r§e!" - ) - } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt index 57395fdc3..c550f11ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt @@ -24,7 +24,7 @@ class SharkFishCounter { val displayName = event.seaCreature.displayName if (displayName.contains("Shark")) { - counter++ + counter += if (event.doubleHook) 2 else 1 display = "§7Sharks caught: §e${counter.addSeparators()}" } } |