blob: f8cd19191ad8b575138277ea4469f5d289a64798 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
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.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor
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("_bronze") -> "bronze"
rawName.endsWith("_silver") -> "silver"
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")) {
var displayName = if (message.contains(" a §r")) message.between(" a §r", "§r §r") else message.between(" an §r", "§r §r")
if (displayName.contains("§k")) {
displayName = displayName.replace("§k", "")
displayName = displayName.replace("Obfuscated", "Obfuscated Fish")
}
val rarity = message.between("§r §r", "§b.").lowercase().replace("§l", "")
val name = (rarity + "_" + displayName).removeColor().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")
}
}
}
|