aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorappable <enzospiacitelli@gmail.com>2023-07-27 02:31:02 -0700
committerGitHub <noreply@github.com>2023-07-27 11:31:02 +0200
commit8c317b7b1905cb886fd3af50caa0d3b3149d1d86 (patch)
treeae8b9277a846f1a26bb58fc47dcf489b16ad7a35 /src/main/java
parentb01b49fd741d4d87b3ced3503e93408e26af18e5 (diff)
downloadskyhanni-8c317b7b1905cb886fd3af50caa0d3b3149d1d86.tar.gz
skyhanni-8c317b7b1905cb886fd3af50caa0d3b3149d1d86.tar.bz2
skyhanni-8c317b7b1905cb886fd3af50caa0d3b3149d1d86.zip
Merge pull request #337
* trophy fillet tooltip; trophy info tooltip in chat * add new config options for trophy * fix up some settings * Merge remote-tracking branch 'upstream/beta' into trophy-data * using TrophyFishJson to load repo data * fixed missing separators for total number * fixed trophy fish sack display
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishFillet.kt34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishInfo.kt48
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishManager.kt62
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishMessages.kt66
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyRarity.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt37
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TrophyFishJson.java11
11 files changed, 238 insertions, 78 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index e79f89452..07ac3c422 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -191,6 +191,8 @@ class SkyHanniMod {
loadModule(DungeonCleanEnd())
loadModule(DungeonBossMessages())
loadModule(DungeonBossHideDamageSplash())
+ loadModule(TrophyFishManager())
+ loadModule(TrophyFishFillet())
loadModule(TrophyFishMessages())
loadModule(BazaarBestSellMethod())
loadModule(AnvilCombineHelper())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index 44044fa48..da971355d 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.config
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.features.fishing.TrophyRarity
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.misc.update.UpdateManager
import at.hannibal2.skyhanni.utils.LorenzLogger
@@ -45,6 +46,16 @@ class ConfigManager {
return LorenzVec(x, y, z)
}
}.nullSafe())
+ .registerTypeAdapter(TrophyRarity::class.java, object : TypeAdapter<TrophyRarity>() {
+ override fun write(out: JsonWriter, value: TrophyRarity) {
+ value.run { out.value(value.name) }
+ }
+
+ override fun read(reader: JsonReader): TrophyRarity {
+ val text = reader.nextString()
+ return TrophyRarity.getByName(text) ?: error("Could not parse TrophyRarity from '$text'")
+ }
+ }.nullSafe())
.registerTypeAdapter(ItemStack::class.java, object : TypeAdapter<ItemStack>() {
override fun write(out: JsonWriter, value: ItemStack) {
out.value(NEUItems.saveNBTData(value))
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 e7fcff1ff..2374a9e2f 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java
@@ -44,6 +44,12 @@ public class Fishing {
public boolean trophyFishTotalAmount = false;
@Expose
+ @ConfigOption(name = "Trophy Fish Info", desc = "Show information and stats about a trophy fish when hovering over a catch message in chat.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean trophyFishTooltip = true;
+
+ @Expose
@ConfigOption(name = "Bronze Duplicates", desc = "Hide duplicate messages for bronze trophy fishes from chat.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
@@ -56,6 +62,12 @@ public class Fishing {
public boolean trophyFishSilverHider = false;
@Expose
+ @ConfigOption(name = "Fillet Tooltip", desc = "Show fillet value of trophy fish in tooltip.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean trophyFilletTooltip = true;
+
+ @Expose
@ConfigOption(name = "Odger Waypoint", desc = "Show the Odger waypoint when trophy fishes are in the inventory and no lava rod in hand.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishFillet.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishFillet.kt
new file mode 100644
index 000000000..32d31595b
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishFillet.kt
@@ -0,0 +1,34 @@
+package at.hannibal2.skyhanni.features.fishing
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUItems
+import at.hannibal2.skyhanni.utils.NumberUtil
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import org.lwjgl.input.Keyboard
+
+class TrophyFishFillet {
+
+ @SubscribeEvent
+ fun onTooltip(event: LorenzToolTipEvent) {
+ if (!isEnabled()) return
+ if (event.slot.inventory.name.contains("Sack")) return
+ val internalName = event.itemStack.getInternalName()
+ val trophyFishName = internalName.substringBeforeLast("_")
+ .replace("_", "").lowercase()
+ val trophyRarityName = internalName.substringAfterLast("_")
+ val info = TrophyFishManager.getInfo(trophyFishName) ?: return
+ val rarity = TrophyRarity.getByName(trophyRarityName) ?: return
+ val multiplier = if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) event.itemStack.stackSize else 1
+ val filletValue = info.getFilletValue(rarity) * multiplier
+ val filletPrice = filletValue * NEUItems.getPrice("MAGMA_FISH")
+ event.toolTip.add("§7Fillet: §8${filletValue.addSeparators()} Magmafish §7(§6${NumberUtil.format(filletPrice)}§7)")
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.fishing.trophyFilletTooltip
+
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishInfo.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishInfo.kt
new file mode 100644
index 000000000..104a71a07
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishInfo.kt
@@ -0,0 +1,48 @@
+package at.hannibal2.skyhanni.features.fishing
+
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.StringUtils.splitLines
+import com.google.gson.annotations.Expose
+import net.minecraft.event.HoverEvent
+import net.minecraft.util.ChatComponentText
+import net.minecraft.util.ChatStyle
+
+data class TrophyFishInfo(
+ @Expose
+ val displayName: String,
+ @Expose
+ private val description: String,
+ @Expose
+ private val rate: Int?,
+ @Expose
+ private val fillet: Map<TrophyRarity, Int>
+) {
+
+ // Credit to NotEnoughUpdates (Trophy Fish profile viewer page) for the format.
+ fun getTooltip(counts: Map<TrophyRarity, Int>): ChatStyle {
+ val bestFishObtained = counts.keys.maxOrNull() ?: TrophyRarity.BRONZE
+ val display = """
+ |$displayName §8[§7$rate%§8]
+ |${description.splitLines(150)}
+ |
+ |${TrophyRarity.DIAMOND.formattedString}: ${formatCount(counts, TrophyRarity.DIAMOND)}
+ |${TrophyRarity.GOLD.formattedString}: ${formatCount(counts, TrophyRarity.GOLD)}
+ |${TrophyRarity.SILVER.formattedString}: ${formatCount(counts, TrophyRarity.SILVER)}
+ |${TrophyRarity.BRONZE.formattedString}: ${formatCount(counts, TrophyRarity.BRONZE)}
+ |
+ |§7Total: ${bestFishObtained.formatCode}${counts.values.sum().addSeparators()}
+ """.trimMargin()
+ return ChatStyle().setChatHoverEvent(
+ HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText(display))
+ )
+ }
+
+ fun getFilletValue(rarity: TrophyRarity): Int {
+ return fillet.getOrDefault(rarity, -1)
+ }
+
+ private fun formatCount(counts: Map<TrophyRarity, Int>, rarity: TrophyRarity): String {
+ val count = counts.getOrDefault(rarity, 0)
+ return if (count > 0) "§6${count.addSeparators()}" else "§c✖"
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishManager.kt
new file mode 100644
index 000000000..df8c95d57
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishManager.kt
@@ -0,0 +1,62 @@
+package at.hannibal2.skyhanni.features.fishing
+
+import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
+import at.hannibal2.skyhanni.events.ProfileJoinEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.jsonobjects.TrophyFishJson
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+
+class TrophyFishManager {
+
+ @SubscribeEvent
+ fun onProfileJoin(event: ProfileJoinEvent) {
+ hasLoadedTrophyFish = false
+ }
+
+ @SubscribeEvent
+ fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) {
+ if (hasLoadedTrophyFish) return
+ val trophyFishes = fishes ?: return
+ val profileData = event.profileData
+ trophyFishes.clear()
+ for ((rawName, value) in profileData["trophy_fish"].asJsonObject.entrySet()) {
+ val rarity = TrophyRarity.getByName(rawName) ?: continue
+ val text = rawName.replace("_", "")
+ val displayName = text.substring(0, text.length - rarity.name.length)
+
+ val amount = value.asInt
+ val rarities = trophyFishes.getOrPut(displayName) { mutableMapOf() }
+ rarities[rarity] = amount
+ hasLoadedTrophyFish = true
+ }
+ }
+
+ @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")
+ }
+ }
+
+ companion object {
+ private var hasLoadedTrophyFish = false
+
+ val fishes: MutableMap<String, MutableMap<TrophyRarity, Int>>?
+ get() = ProfileStorageData.profileSpecific?.crimsonIsle?.trophyFishes
+
+ private var trophyFishInfo = mapOf<String, TrophyFishInfo>()
+
+ fun getInfo(internalName: String) = trophyFishInfo[internalName]
+
+ fun getInfoByName(name: String) = trophyFishInfo.values.find { it.displayName == name }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishMessages.kt
index bdefdebf6..b655c9893 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishMessages.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyFishMessages.kt
@@ -1,10 +1,8 @@
package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
-import at.hannibal2.skyhanni.events.ProfileJoinEvent
+import at.hannibal2.skyhanni.features.fishing.TrophyFishManager.Companion.fishes
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut
import at.hannibal2.skyhanni.utils.LorenzUtils.sumAllValues
@@ -16,54 +14,29 @@ import net.minecraft.util.ChatComponentText
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class TrophyFishMessages {
- private var hasLoadedTrophyFish = false
- private val fishes get() = ProfileStorageData.profileSpecific?.crimsonIsle?.trophyFishes
private val trophyFishPattern =
Regex("§6§lTROPHY FISH! §r§bYou caught an? §r(?<displayName>§[0-9a-f](?:§k)?[\\w -]+)§r§r§r §r§l§r(?<displayRarity>§[0-9a-f]§l\\w+)§r§b\\.")
private val config get() = SkyHanniMod.feature.fishing
@SubscribeEvent
- fun onProfileJoin(event: ProfileJoinEvent) {
- hasLoadedTrophyFish = false
- }
-
- @SubscribeEvent
- fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) {
- if (hasLoadedTrophyFish) return
- val trophyFishes = fishes ?: return
- val profileData = event.profileData
- trophyFishes.clear()
- for ((rawName, value) in profileData["trophy_fish"].asJsonObject.entrySet()) {
- val rarity = getByName(rawName) ?: continue
- val text = rawName.replace("_", "")
- val displayName = text.substring(0, text.length - rarity.name.length)
-
- val amount = value.asInt
- val rarities = trophyFishes.getOrPut(displayName) { mutableMapOf() }
- rarities[rarity] = amount
- hasLoadedTrophyFish = true
- }
- }
-
- @SubscribeEvent
fun onStatusBar(event: LorenzChatEvent) {
- if (!LorenzUtils.inSkyBlock || !config.trophyCounter) return
+ if (!LorenzUtils.inSkyBlock) return
val match = trophyFishPattern.matchEntire(event.message)?.groups ?: return
val displayName = match["displayName"]!!.value.replace("§k", "")
val displayRarity = match["displayRarity"]!!.value
- val fishName = displayName.replace("Obfuscated", "Obfuscated Fish")
+ val internalName = displayName.replace("Obfuscated", "Obfuscated Fish")
.replace("[- ]".toRegex(), "").lowercase().removeColor()
val rawRarity = displayRarity.lowercase().removeColor()
- val rarity = getByName(rawRarity) ?: return
+ val rarity = TrophyRarity.getByName(rawRarity) ?: return
val trophyFishes = fishes ?: return
- val rarities = trophyFishes.getOrPut(fishName) { mutableMapOf() }
- val amount = rarities.addOrPut(rarity, 1)
+ val trophyFishCounts = trophyFishes.getOrPut(internalName) { mutableMapOf() }
+ val amount = trophyFishCounts.addOrPut(rarity, 1)
event.blockedReason = "trophy_fish"
- if (config.trophyDesign == 0 && amount == 1) {
+ if (config.trophyCounter && config.trophyDesign == 0 && amount == 1) {
LorenzUtils.chat("§6§lTROPHY FISH! §c§lFIRST §r$displayRarity $displayName")
return
}
@@ -71,23 +44,26 @@ class TrophyFishMessages {
if (config.trophyFishBronzeHider && rarity == TrophyRarity.BRONZE && amount != 1) return
if (config.trophyFishSilverHider && rarity == TrophyRarity.SILVER && amount != 1) return
val totalText = if (config.trophyFishTotalAmount) {
- val total = rarities.sumAllValues()
+ val total = trophyFishCounts.sumAllValues()
" §7(${total.addSeparators()}. total)"
} else ""
- val trophyMessage = "§6§lTROPHY FISH! " + when (config.trophyDesign) {
- 0 -> "§7$amount. §r$displayRarity $displayName$totalText"
- 1 -> "§bYou caught a $displayName $displayRarity§b. §7(${amount.addSeparators()})$totalText"
- else -> "§bYou caught your ${amount.addSeparators()}${amount.ordinal()} $displayRarity $displayName§b.$totalText"
+ val component = ChatComponentText(if (config.trophyCounter) {
+ "§6§lTROPHY FISH! " + when (config.trophyDesign) {
+ 0 -> "§7$amount. §r$displayRarity $displayName$totalText"
+ 1 -> "§bYou caught a $displayName $displayRarity§b. §7(${amount.addSeparators()})$totalText"
+ else -> "§bYou caught your ${amount.addSeparators()}${amount.ordinal()} $displayRarity $displayName§b.$totalText"
+ }
+ } else event.message)
+
+ if (config.trophyFishTooltip) {
+ TrophyFishManager.getInfo(internalName)?.let {
+ component.chatStyle = it.getTooltip(trophyFishCounts)
+ }
}
Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessageWithOptionalDeletion(
- ChatComponentText(trophyMessage),
- if (config.trophyFishDuplicateHider) (fishName + rarity).hashCode() else 0
+ component, if (config.trophyFishDuplicateHider) (internalName + rarity).hashCode() else 0
)
}
-
- fun getByName(rawName: String) = TrophyRarity.values().firstOrNull { rawName.uppercase().endsWith(it.name) }
-
- data class TrophyFish(val rarities: MutableMap<TrophyRarity, Int> = mutableMapOf())
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyRarity.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyRarity.kt
index b87d3d60e..d4df5f2eb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyRarity.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TrophyRarity.kt
@@ -1,5 +1,16 @@
package at.hannibal2.skyhanni.features.fishing
-enum class TrophyRarity {
- BRONZE, SILVER, GOLD, DIAMOND;
+import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
+
+enum class TrophyRarity(val formatCode: String) {
+ BRONZE("§8"),
+ SILVER("§7"),
+ GOLD("§6"),
+ DIAMOND("§b");
+
+ val formattedString get() = "$formatCode${name.firstLetterUppercase()}"
+
+ companion object {
+ fun getByName(rawName: String) = values().firstOrNull { rawName.uppercase().endsWith(it.name) }
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt
index 5f66d3ea6..346e51c93 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarApi
+import at.hannibal2.skyhanni.features.fishing.TrophyFishManager
import at.hannibal2.skyhanni.features.fishing.TrophyRarity
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
@@ -124,8 +125,11 @@ class SackDisplay {
item.stored = stored
item.total = total
if (isTrophySack) {
- val trophyName = name.removeColor().uppercase().replace(" ", "_").replace("-", "_")
- item.price = calculatePrice("MAGMA_FISH", Trophy.valueOf(trophyName).convert(sackRarity, stored))
+ val trophyName = internalName.lowercase()
+ .substringBeforeLast("_").replace("_", "")
+ val filletValue = TrophyFishManager.getInfoByName(trophyName)?.getFilletValue(sackRarity!!) ?: 0
+ val storedNumber = stored.formatNumber().toInt()
+ item.price = calculatePrice("MAGMA_FISH", (filletValue * storedNumber).toString())
} else {
item.price = if (calculatePrice(internalName, stored) < 0) 0 else calculatePrice(internalName, stored)
}
@@ -327,35 +331,6 @@ class SackDisplay {
var price: Int = 0,
)
- enum class Trophy(private val bronzeValue: Int, private val silverValue: Int) {
- BLOBFISH(4, 5),
- FLYFISH(32, 48),
- GOLDEN_FISH(400, 700),
- GUSHER(32, 48),
- KARATE_FISH(40, 60),
- LAVAHORSE(12, 16),
- MANA_RAY(40, 60),
- MOLDFIN(32, 48),
- SKELETON_FISH(32, 48),
- SLUGFISH(40, 60),
- SOUL_FISH(32, 48),
- STEAMING_HOT_FLOUNDER(20, 28),
- SULPHUR_SKITTER(40, 60),
- VANILLE(80, 120),
- VOLCANIC_STONEFISH(20, 28),
- OBFUSCATED_1(16, 24),
- OBFUSCATED_2(40, 60),
- OBFUSCATED_3(400, 700);
-
- fun convert(rarity: TrophyRarity?, stored: String): String {
- return when (rarity) {
- TrophyRarity.BRONZE -> (this.bronzeValue * stored.formatNumber().toInt()).toString()
- TrophyRarity.SILVER -> (this.silverValue * stored.formatNumber().toInt()).toString()
- else -> "0"
- }
- }
- }
-
private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
private fun isRuneDisplayEnabled() = config.showRunes
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index 917ec5c88..aaff447a9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -2,6 +2,8 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.GuiRenderUtils.darkenColor
import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.GuiUtilRenderComponents
+import net.minecraft.util.ChatComponentText
import org.intellij.lang.annotations.Language
import java.util.*
import java.util.regex.Matcher
@@ -106,5 +108,21 @@ object StringUtils {
}
}
+
+
fun String.removeWordsAtEnd(i: Int) = split(" ").dropLast(i).joinToString(" ")
+
+ fun String.splitLines(width: Int): String {
+ val fr = Minecraft.getMinecraft().fontRendererObj
+ return GuiUtilRenderComponents.splitText(
+ ChatComponentText(this), width, fr, false, false
+ ).joinToString("\n") {
+ val text = it.formattedText
+ val formatCode = Regex("(?:§[a-f0-9l-or]|\\s)*")
+ formatCode.matchAt(text, 0)?.let { matcher ->
+ val codes = matcher.value.replace("\\s".toRegex(), "")
+ codes + text.removeRange(matcher.range)
+ } ?: text
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TrophyFishJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TrophyFishJson.java
new file mode 100644
index 000000000..48d0908a9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TrophyFishJson.java
@@ -0,0 +1,11 @@
+package at.hannibal2.skyhanni.utils.jsonobjects;
+
+import at.hannibal2.skyhanni.features.fishing.TrophyFishInfo;
+import com.google.gson.annotations.Expose;
+
+import java.util.Map;
+
+public class TrophyFishJson {
+ @Expose
+ public Map<String, TrophyFishInfo> trophy_fish;
+}