aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-11 20:47:35 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-11 20:47:35 +0100
commit5938c9a1220a390d930adf9067c606c7f0d1c667 (patch)
treec4e7d94936cc34a5749259d52091d582c29467c3 /src/main/java/at/hannibal2/skyhanni
parent1a78f938c11be89a82db8221324826dfa614668b (diff)
downloadskyhanni-5938c9a1220a390d930adf9067c606c7f0d1c667.tar.gz
skyhanni-5938c9a1220a390d930adf9067c606c7f0d1c667.tar.bz2
skyhanni-5938c9a1220a390d930adf9067c606c7f0d1c667.zip
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt66
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()