diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt | 66 |
1 files changed, 36 insertions, 30 deletions
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 1721661e0..f64af8291 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt @@ -19,20 +19,19 @@ class SharkFishCounter { fun onSeaCreatureFish(event: SeaCreatureFishEvent) { if (!SkyHanniMod.feature.fishing.sharkFishCounter) return - if (event.seaCreature.name.contains("Shark")) { - val index = - if (event.seaCreature.name.contains("Blue")) { - 1 - } else if (event.seaCreature.name.contains("Tiger")) { - 2 - } else if (event.seaCreature.name.contains("Great")) { - 3 - } else { - 0 - } - counter[index] += if (event.doubleHook) 2 else 1 - display = "§7Sharks caught: §e${counter.sum().addSeparators()} §7(§a${counter[0]} §9${counter[1]} §5${counter[2]} §6${counter[3]}§7)" - } + val name = event.seaCreature.name + if (!name.contains("Shark")) return + counter[sharkIndex(name)] += if (event.doubleHook) 2 else 1 + display = "§7Sharks caught: §e${ + counter.sum().addSeparators() + } §7(§a${counter[0]} §9${counter[1]} §5${counter[2]} §6${counter[3]}§7)" + } + + private fun sharkIndex(name: String): Int = when { + name.contains("Blue") -> 1 + name.contains("Tiger") -> 2 + name.contains("Great") -> 3 + else -> 0 } @SubscribeEvent @@ -47,22 +46,29 @@ class SharkFishCounter { @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { - if (event.message == "§b§lFISHING FESTIVAL §r§eThe festival has concluded! Time to dry off and repair your rods!") { - val count = counter.sum() - val funnyComment = when { - count == 0 -> return - count < 50 -> "Well done!" - count < 100 -> "Nice!" - count < 150 -> "Really nice!" - count < 200 -> "Super cool!" - count < 250 -> "Mega cool!" - count < 350 -> "Like a pro!" - else -> "How???" - } - LorenzUtils.chat("You caught ${count.addSeparators()} §f(§a${counter[0]} §9${counter[1]} §5${counter[2]} §6${counter[3]}§f) sharks during this fishing contest. $funnyComment") - counter = mutableListOf(0, 0, 0, 0) - display = "" - } + if (event.message != "§b§lFISHING FESTIVAL §r§eThe festival has concluded! Time to dry off and repair your rods!") return + val count = counter.sum() + if (count == 0) return + + val n = counter[0] // Nurse + val b = counter[1] // Blue + val t = counter[2] // Tiger + val g = counter[3] // Great White + val total = count.addSeparators() + val funnyComment = funnyComment(count) + LorenzUtils.chat("You caught $total §f(§a$n §9$b §5$t §6$g§f) sharks during this fishing contest. $funnyComment") + counter = mutableListOf(0, 0, 0, 0) + display = "" + } + + private fun funnyComment(count: Int): String = when { + count < 50 -> "Well done!" + count < 100 -> "Nice!" + count < 150 -> "Really nice!" + count < 200 -> "Super cool!" + count < 250 -> "Mega cool!" + count < 350 -> "Like a pro!" + else -> "How???" } private fun isWaterFishingRod() = FishingAPI.hasFishingRodInHand() && !FishingAPI.isLavaRod() |