summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/fishing
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-21 11:16:34 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-21 11:16:34 +0200
commit830fdb7022ac173b421daeddfbc7e67c0d9f891b (patch)
treea9e4397add1cc121e9cea0a35500de5ccd66f5a9 /src/main/java/at/hannibal2/skyhanni/features/fishing
parent020c278b3c6cdff38449e0fe67bb36bf196ed045 (diff)
downloadskyhanni-830fdb7022ac173b421daeddfbc7e67c0d9f891b.tar.gz
skyhanni-830fdb7022ac173b421daeddfbc7e67c0d9f891b.tar.bz2
skyhanni-830fdb7022ac173b421daeddfbc7e67c0d9f891b.zip
better repo error handling
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt39
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt15
2 files changed, 21 insertions, 33 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
index 9e54fef06..c41129c5f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
@@ -35,31 +35,26 @@ class SeaCreatureManager {
allFishingMobs.clear()
var counter = 0
- try {
- val data = event.getConstant<Map<String, SeaCreatureJson.Variant>>("SeaCreatures", SeaCreatureJson.TYPE) ?: return
- val allFishingMobs = mutableMapOf<String,SeaCreature>()
+ val data = event.getConstant<Map<String, SeaCreatureJson.Variant>>("SeaCreatures", SeaCreatureJson.TYPE)
+ val allFishingMobs = mutableMapOf<String, SeaCreature>()
- for (variant in data.values) {
- val chatColor = variant.chat_color
- for ((displayName, seaCreature) in variant.sea_creatures) {
- val chatMessage = seaCreature.chat_message
- val fishingExperience = seaCreature.fishing_experience
- val rarity = seaCreature.rarity
- val rare = seaCreature.rare ?: false
+ for (variant in data.values) {
+ val chatColor = variant.chat_color
+ for ((displayName, seaCreature) in variant.sea_creatures) {
+ val chatMessage = seaCreature.chat_message
+ val fishingExperience = seaCreature.fishing_experience
+ val rarity = seaCreature.rarity
+ val rare = seaCreature.rare ?: false
- val creature = SeaCreature(displayName, fishingExperience, chatColor, rare, rarity)
- seaCreatureMap[chatMessage] = creature
- allFishingMobs[displayName] = creature
- counter++
- }
+ val creature = SeaCreature(displayName, fishingExperience, chatColor, rare, rarity)
+ seaCreatureMap[chatMessage] = creature
+ allFishingMobs[displayName] = creature
+ counter++
}
- SeaCreatureManager.allFishingMobs = allFishingMobs
- LorenzUtils.debug("Loaded $counter sea creatures from repo")
-
- } catch (e: Exception) {
- e.printStackTrace()
- LorenzUtils.error("error in RepositoryReloadEvent")
}
+ SeaCreatureManager.allFishingMobs = allFishingMobs
+ LorenzUtils.debug("Loaded $counter sea creatures from repo")
+
}
companion object {
@@ -75,4 +70,4 @@ class SeaCreatureManager {
return seaCreatureMap.getOrDefault(message, null)
}
}
-} \ No newline at end of file
+}
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 c2f4e64fe..4d8b547a4 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
@@ -6,20 +6,13 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.jsonobjects.TrophyFishJson
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
class TrophyFishManager {
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
- try {
- val json = event.getConstant<TrophyFishJson>("TrophyFish")
- ?: error("Could not read repo data from TrophyFish.json")
- trophyFishInfo = json.trophy_fish
- LorenzUtils.debug("Loaded trophy fish from repo")
- } catch (e: Exception) {
- e.printStackTrace()
- LorenzUtils.error("error in RepositoryReloadEvent")
- }
+ val json = event.getConstant<TrophyFishJson>("TrophyFish")
+ trophyFishInfo = json.trophy_fish
+ LorenzUtils.debug("Loaded trophy fish from repo")
}
companion object {
@@ -32,4 +25,4 @@ class TrophyFishManager {
fun getInfoByName(name: String) = trophyFishInfo.values.find { it.displayName == name }
}
-} \ No newline at end of file
+}