diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-03-22 18:16:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-22 18:16:49 +0100 |
commit | a8138b0aa20d2b2fd266b1352eaf075999365bb6 (patch) | |
tree | a9c15556e699c00869bae2fe811e309727b204c8 /src/main/java/at/hannibal2/skyhanni/features/fishing | |
parent | 788adb59f20e01c83f4e030fa077a70275c00074 (diff) | |
download | skyhanni-a8138b0aa20d2b2fd266b1352eaf075999365bb6.tar.gz skyhanni-a8138b0aa20d2b2fd266b1352eaf075999365bb6.tar.bz2 skyhanni-a8138b0aa20d2b2fd266b1352eaf075999365bb6.zip |
Backend: ChatClickActionManager (#1128)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt index 78fbf6731..9bff45019 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt @@ -37,27 +37,45 @@ object TrophyFishManager { loadedNeu = true - val savedFish = fish ?: return + val savedFishes = fish ?: return var changed = false + val neuData = mutableListOf<Triple<String, TrophyRarity, Int>>() for ((fishName, apiAmount) in caughtTrophyFish) { val rarity = TrophyRarity.getByName(fishName) ?: continue val name = fishName.split("_").dropLast(1).joinToString("") - val savedFishData = savedFish.getOrPut(name) { mutableMapOf() } + val savedFishData = savedFishes.getOrPut(name) { mutableMapOf() } val currentSavedAmount = savedFishData[rarity] ?: 0 + neuData.add(Triple(name, rarity, apiAmount)) if (apiAmount > currentSavedAmount) { - savedFishData[rarity] = apiAmount - ChatUtils.debug("Updated trophy fishing data from NEU PV: $name $rarity: $currentSavedAmount -> $apiAmount") changed = true } } if (changed) { - ChatUtils.chat("Updated Trophy Fishing data via NEU PV!") + ChatUtils.clickableChat("Click here to load data from NEU PV!", onClick = { + updateFromNeuPv(savedFishes, neuData) + }) } } + private fun updateFromNeuPv( + savedFishes: MutableMap<String, MutableMap<TrophyRarity, Int>>, + neuData: MutableList<Triple<String, TrophyRarity, Int>>, + ) { + for ((name, rarity, newValue) in neuData) { + val saved = savedFishes[name] ?: continue + + val current = saved[rarity] ?: 0 + if (newValue > current) { + saved[rarity] = newValue + ChatUtils.debug("Updated trophy fishing data from NEU PV: $name $rarity: $current -> $newValue") + } + } + ChatUtils.chat("Updated Trophy Fishing data via NEU PV!") + } + private var trophyFishInfo = mapOf<String, TrophyFishInfo>() fun getInfo(internalName: String) = trophyFishInfo[internalName] |