summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/fishing
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-15 00:58:03 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-15 00:58:03 +0200
commit3667f62465316ecca134de519700045834d4676f (patch)
treea2885fe7b3ecc20a0983fea4df2ca82658159db5 /src/main/java/at/hannibal2/skyhanni/fishing
parent6a05417e4c0cea8c8bcb9a64d41635c961227e0e (diff)
downloadskyhanni-3667f62465316ecca134de519700045834d4676f.tar.gz
skyhanni-3667f62465316ecca134de519700045834d4676f.tar.bz2
skyhanni-3667f62465316ecca134de519700045834d4676f.zip
add trophy fishing feature
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/fishing')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt
new file mode 100644
index 000000000..1c2160009
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt
@@ -0,0 +1,68 @@
+package at.hannibal2.skyhanni.fishing
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
+import at.hannibal2.skyhanni.utils.LorenzDebug
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.between
+import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class TrophyFishMessages {
+
+ private val map = mutableMapOf<String, Int>()
+
+ @SubscribeEvent
+ fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) {
+ val profileData = event.profileData
+
+ map.clear()
+ val trophyFishes = profileData["trophy_fish"].asJsonObject
+ for ((rawName, value) in trophyFishes.entrySet()) {
+ val rarity = when {
+ rawName.endsWith("_silver") -> "silver"
+ rawName.endsWith("_bronze") -> "bronze"
+ rawName.endsWith("_gold") -> "gold"
+ rawName.endsWith("_diamond") -> "diamond"
+ else -> continue
+ }
+ val text = rawName.replace("_", "")
+ val displayName = text.substring(0, text.length - rarity.length)
+
+ val amount = value.asInt
+
+// LorenzDebug.log("$rarity: $displayName: $amount")
+ val name = rarity + "_" + displayName
+ map[name] = amount
+// LorenzDebug.log("loaded trophy: $name = $amount")
+ }
+ }
+
+ @SubscribeEvent
+ fun onStatusBar(event: LorenzChatEvent) {
+ if (!LorenzUtils.inSkyblock) return
+ if (!SkyHanniMod.feature.fishing.trophyCounter) return
+
+ val message = event.message
+ if (message.startsWith("§6§lTROPHY FISH! §r§bYou caught a §r")) {
+ val displayName = message.between(" a §r", "§r §r")
+ val rarity = message.between("§r §r", "§b.").lowercase().replace("§l", "")
+
+ val name = (rarity + "_" + displayName).removeColorCodes().lowercase().replace(" ", "")
+ val amount = map.getOrDefault(name, 0) + 1
+ map[name] = amount
+ event.blockedReason = "trophy_fish"
+
+ if (amount == 1) {
+ LorenzUtils.chat("§6TROPHY FISH! §c§lFIRST §r$rarity $displayName")
+ } else {
+ if (rarity.contains("bronze")) {
+ if (SkyHanniMod.feature.fishing.trophyFishBronzeHider) return
+ }
+ LorenzUtils.chat("§6TROPHY FISH! §7$amount. §r$rarity $displayName")
+ }
+// LorenzDebug.log("new trophy: $name = $amount")
+ }
+ }
+} \ No newline at end of file