aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-10-07 01:32:30 +0200
committerGitHub <noreply@github.com>2024-10-07 01:32:30 +0200
commitedbbe1e61afe600b9d111c7bf74db70f07befd2f (patch)
treef32f104bf512abec5a25fd8aedc332fff179bd90 /src/main/java/at/hannibal2
parent71f6d7e18627a04e5d80d8f5951cdb3b2bc5d44d (diff)
downloadskyhanni-edbbe1e61afe600b9d111c7bf74db70f07befd2f.tar.gz
skyhanni-edbbe1e61afe600b9d111c7bf74db70f07befd2f.tar.bz2
skyhanni-edbbe1e61afe600b9d111c7bf74db70f07befd2f.zip
Backend: Migrate Plhlegblast (#2684)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
index ca8a73ce9..e10685801 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
@@ -4,11 +4,13 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.FishingBobberCastEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.events.SeaCreatureFishEvent
import at.hannibal2.skyhanni.features.fishing.FishingAPI
import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
+import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString
import at.hannibal2.skyhanni.utils.CollectionUtils.sumAllValues
@@ -25,6 +27,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object SeaCreatureTracker {
+ private var needMigration = true
private val config get() = SkyHanniMod.feature.fishing.seaCreatureTracker
@@ -72,7 +75,15 @@ object SeaCreatureTracker {
return map
}
+ @SubscribeEvent
+ fun onProfileJoin(event: ProfileJoinEvent) {
+ needMigration = true
+ }
+
private fun drawDisplay(data: Data): List<Searchable> = buildList {
+ // manually migrating from "Phlhlegblast" to "Plhlegblast" when the new name is in the repo
+ tryToMigrate(data.amount)
+
addSearchString("§7Sea Creature Tracker:")
val filter: (String) -> Boolean = addCategories(data)
@@ -85,7 +96,7 @@ object SeaCreatureTracker {
"Sea Creature Tracker can not display a name correctly",
"Could not find sea creature by name",
"SeaCreatureManager.allFishingMobs.keys" to SeaCreatureManager.allFishingMobs.keys,
- "name" to name
+ "name" to name,
)
name
}
@@ -100,6 +111,25 @@ object SeaCreatureTracker {
addSearchString(" §7- §e${total.addSeparators()} §7Total Sea Creatures")
}
+ private fun tryToMigrate(
+ data: MutableMap<String, Int>,
+ ) {
+ if (!needMigration) return
+ needMigration = false
+
+ val oldName = "Phlhlegblast"
+ val newName = "Plhlegblast"
+
+ // only migrate once the repo contains the new name
+ if (SeaCreatureManager.allFishingMobs.containsKey(newName)) {
+ data[oldName]?.let {
+ ChatUtils.debug("Sea Creature Tracker migrated $it $oldName to $newName")
+ data[newName] = it
+ data.remove(oldName)
+ }
+ }
+ }
+
private fun MutableList<Searchable>.addCategories(data: Data): (String) -> Boolean {
val amounts = getCurrentCategories(data)
val list = amounts.keys.toList()
@@ -115,7 +145,7 @@ object SeaCreatureTracker {
val id = list.indexOf(currentCategory)
currentCategory = list[(id + 1) % list.size]
tracker.update()
- }
+ },
)
}
@@ -161,6 +191,5 @@ object SeaCreatureTracker {
tracker.resetCommand()
}
- private fun isEnabled() =
- LorenzUtils.inSkyBlock && config.enabled && !FishingAPI.wearingTrophyArmor && !LorenzUtils.inKuudraFight
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && !FishingAPI.wearingTrophyArmor && !LorenzUtils.inKuudraFight
}