aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureManager.kt
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-23 10:00:06 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-23 10:00:06 +0200
commita9f7b8ec04cb356cbf6512228bfc1cb3623dccf0 (patch)
tree4f57beab139004fb9fc5d2b4631696c563d1c16d /src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureManager.kt
parent62efc12ae194f8aee0bac3991ed584f9e426e549 (diff)
downloadskyhanni-a9f7b8ec04cb356cbf6512228bfc1cb3623dccf0.tar.gz
skyhanni-a9f7b8ec04cb356cbf6512228bfc1cb3623dccf0.tar.bz2
skyhanni-a9f7b8ec04cb356cbf6512228bfc1cb3623dccf0.zip
adding sea creature message shortener feature
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureManager.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureManager.kt61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureManager.kt
new file mode 100644
index 000000000..d901abe5d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureManager.kt
@@ -0,0 +1,61 @@
+package at.hannibal2.skyhanni.fishing
+
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class SeaCreatureManager {
+
+ @SubscribeEvent
+ fun onRepoReload(event: RepositoryReloadEvent) {
+ seaCreatureMap.clear()
+ var counter = 0
+
+ try {
+ val data = event.getConstant("SeaCreatures")!!
+
+ for (variant in data.entrySet().map { it.value.asJsonObject }) {
+ val chatColor = variant["chat_color"].asString
+ for (seaCreature in variant["sea_creatures"].asJsonArray.map { it.asJsonObject }) {
+ val displayName = seaCreature["display_name"].asString
+ val chatMessage = seaCreature["chat_message"].asString
+ val fishingExperience = seaCreature["fishing_experience"].asInt
+ val special = seaCreature["special"].asBoolean
+
+ seaCreatureMap[chatMessage] = SeaCreature(displayName, fishingExperience, chatColor, special)
+ counter++
+ }
+ }
+ LorenzUtils.debug("loaded $counter sea creatures from repo")
+
+// seaCreatures.asJsonArray.map { it.asJsonObject }.forEach {
+// val displayName = it["display_name"].asString
+// val chatMessage = it["chat_message"].asString
+// val fishingExperience = it["fishing_experience"].asInt
+// val variantName = it["variant"].asString
+// val special = it["special"].asBoolean
+//
+// val variant = try {
+// FishingVariant.fromString(variantName)
+// } catch (e: FishingVariantNotFoundException) {
+// LorenzUtils.error("Error loading Sea Creature '$displayName': " + e.message)
+// return
+// }
+//
+// seaCreatureMap[chatMessage] = SeaCreature(displayName, fishingExperience, variant, special)
+// }
+
+ } catch (e: Exception) {
+ e.printStackTrace()
+ LorenzUtils.error("error in RepositoryReloadEvent")
+ }
+ }
+
+ companion object {
+ val seaCreatureMap = mutableMapOf<String, SeaCreature>()
+
+ fun getSeaCreature(message: String): SeaCreature? {
+ return seaCreatureMap.getOrDefault(message, null)
+ }
+ }
+} \ No newline at end of file