diff options
Diffstat (limited to 'src/main/java')
5 files changed, 108 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 2e5aa8cff..855a3870f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -10,6 +10,8 @@ import at.hannibal2.skyhanni.config.Features; import at.hannibal2.skyhanni.config.gui.commands.Commands; import at.hannibal2.skyhanni.dungeon.*; import at.hannibal2.skyhanni.dungeon.damageindicator.DungeonBossDamageIndicator; +import at.hannibal2.skyhanni.fishing.SeaCreatureManager; +import at.hannibal2.skyhanni.fishing.SeaCreatureMessageShortener; import at.hannibal2.skyhanni.fishing.TrophyFishMessages; import at.hannibal2.skyhanni.inventory.anvil.AnvilCombineHelper; import at.hannibal2.skyhanni.items.HideNotClickableItems; @@ -54,6 +56,7 @@ public class SkyHanniMod { MinecraftForge.EVENT_BUS.register(new DungeonData()); MinecraftForge.EVENT_BUS.register(new ScoreboardData()); MinecraftForge.EVENT_BUS.register(new ApiData()); + MinecraftForge.EVENT_BUS.register(new SeaCreatureManager()); MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper()); MinecraftForge.EVENT_BUS.register(new ChatFilter()); @@ -73,6 +76,7 @@ public class SkyHanniMod { MinecraftForge.EVENT_BUS.register(new TrophyFishMessages()); MinecraftForge.EVENT_BUS.register(new BazaarBestSellMethod()); MinecraftForge.EVENT_BUS.register(new AnvilCombineHelper()); + MinecraftForge.EVENT_BUS.register(new SeaCreatureMessageShortener()); Commands.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java b/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java index d4f99afb5..18adebc90 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java @@ -15,4 +15,9 @@ public class Fishing { @ConfigOption(name = "Hide Bronze Duplicates", desc = "Hide duplicate messages for bronze trophy fishes from chat.") @ConfigEditorBoolean public boolean trophyFishBronzeHider = false; + + @Expose + @ConfigOption(name = "Shorten Fishing Message", desc = "Shorten the message what type of sea creature you have fished") + @ConfigEditorBoolean + public boolean shortenFishingMessage = false; }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreature.kt b/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreature.kt new file mode 100644 index 000000000..887d703e4 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreature.kt @@ -0,0 +1,14 @@ +package at.hannibal2.skyhanni.fishing + +data class SeaCreature( + val displayName: String, + val fishingExperience: Int, + val chatColor: String, + val special: Boolean, +) { + + override fun toString(): String { + return chatColor + displayName + } +} + 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 diff --git a/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureMessageShortener.kt b/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureMessageShortener.kt new file mode 100644 index 000000000..4fc3a1f12 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/fishing/SeaCreatureMessageShortener.kt @@ -0,0 +1,24 @@ +package at.hannibal2.skyhanni.fishing + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class SeaCreatureMessageShortener { + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!LorenzUtils.inSkyblock) return + if (!SkyHanniMod.feature.fishing.shortenFishingMessage) return + + val seaCreature = SeaCreatureManager.getSeaCreature(event.message) + if (seaCreature != null) { + event.blockedReason = "sea_create_caught" + LorenzUtils.chat("§9You caught a $seaCreature§9!") + if (seaCreature.fishingExperience == 0) { + LorenzUtils.debug("no fishing exp set for " + seaCreature.displayName) + } + } + } +}
\ No newline at end of file |