From b382b06b3ab0423dfa832a86e52ca33c3dee018e Mon Sep 17 00:00:00 2001 From: Obsidianninja11 Date: Tue, 28 May 2024 19:09:22 -0800 Subject: [PATCH 1/9] Jyrre and truffle held time in lore + truffle stack size --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 ++ .../features/inventory/InventoryConfig.java | 7 ++++ .../features/inventory/HeldTimeInLore.kt | 34 +++++++++++++++++++ .../inventory/ItemDisplayOverlayFeatures.kt | 7 ++++ .../utils/SkyBlockItemModifierUtils.kt | 2 ++ 5 files changed, 52 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 8258a58dd513..5e1924b2d8c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -257,6 +257,7 @@ import at.hannibal2.skyhanni.features.inventory.AuctionsHighlighter import at.hannibal2.skyhanni.features.inventory.ChestValue import at.hannibal2.skyhanni.features.inventory.DojoRankDisplay import at.hannibal2.skyhanni.features.inventory.HarpFeatures +import at.hannibal2.skyhanni.features.inventory.HeldTimeInLore import at.hannibal2.skyhanni.features.inventory.HideNotClickableItems import at.hannibal2.skyhanni.features.inventory.HighlightBonzoMasks import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures @@ -934,6 +935,7 @@ class SkyHanniMod { loadModule(SkillTooltip()) loadModule(MaxPurseItems()) loadModule(SuperCraftFeatures) + loadModule(HeldTimeInLore()) loadModule(InfernoMinionFeatures()) loadModule(LimboPlaytime) loadModule(CopyPlaytime) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 86403f24afe3..8035eac095dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -127,6 +127,7 @@ public enum ItemNumberEntry implements HasLegacyId { DUNGEON_POTION_LEVEL("§bDungeon Potion Level", 13), VACUUM_GARDEN("§bVacuum (Garden)", 14), BOTTLE_OF_JYRRE("§bBottle Of Jyrre", 15), + DARK_CACAO_TRUFFLE("§bDark Cacao Truffle"), EDITION_NUMBER("§bEdition Number", 16), BINGO_GOAL_RANK("§bBingo Goal Rank"), ; @@ -228,4 +229,10 @@ public String toString() { @ConfigEditorBoolean @FeatureToggle public boolean shiftClickBrewing = false; + + @Expose + @ConfigOption(name = "Held Time in Lore", desc = "Shows the held time for Bottle of Jyrre and Dark Cacao Truffle in lore.") + @ConfigEditorBoolean + @FeatureToggle + public boolean heldTimeInLore = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt new file mode 100644 index 000000000000..ba66ab04264b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -0,0 +1,34 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSeconds +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getSecondsHeld +import at.hannibal2.skyhanni.utils.TimeUtils +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class HeldTimeInLore { + private val config get() = SkyHanniMod.feature.inventory + + private val jyrreBottle by lazy { "NEW_BOTTLE_OF_JYRRE".asInternalName() } + private val cacaoTruffle by lazy { "DARK_CACAO_TRUFFLE".asInternalName() } + + @SubscribeEvent + fun onTooltip(event: LorenzToolTipEvent) { + if (!config.heldTimeInLore) return + if (event.toolTip.size < 10) return // to fix when tooltip isn't fully loaded + + val stack = event.itemStack + val internalName = stack.getInternalName() + val timeHeld = TimeUtils.formatDuration( + when (internalName) { + jyrreBottle -> stack.getBottleOfJyrreSeconds() ?: return + cacaoTruffle -> stack.getSecondsHeld() ?: return + else -> return + }.toLong() * 1000 - 999 + ) + event.toolTip.add(10, "§7Time Held: §b$timeHeld") + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index 08dec7a4aa85..9d1df7abdd6a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumbe import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BINGO_GOAL_RANK import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BOTTLE_OF_JYRRE import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.COLLECTION_LEVEL +import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DARK_CACAO_TRUFFLE import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DUNGEON_HEAD_FLOOR_NUMBER import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DUNGEON_POTION_LEVEL import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.EDITION_NUMBER @@ -48,6 +49,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEdition import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getNewYearCake import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetLevel import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getRanchersSpeed +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getSecondsHeld import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonArray @@ -243,6 +245,11 @@ object ItemDisplayOverlayFeatures { return "§a${(seconds / 3600)}" } + if (DARK_CACAO_TRUFFLE.isSelected() && internalName == "DARK_CACAO_TRUFFLE".asInternalName()) { + val seconds = item.getSecondsHeld() ?: 0 + return "§a${(seconds / 3600)}" + } + if (EDITION_NUMBER.isSelected()) { item.getEdition()?.let { edition -> if (edition < 1_000) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index b6cb3a3302af..08c50948034f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -179,6 +179,8 @@ object SkyBlockItemModifierUtils { fun ItemStack.getLivingMetalProgress() = getAttributeInt("lm_evo") + + fun ItemStack.getSecondsHeld() = getAttributeInt("seconds_held") fun ItemStack.getBottleOfJyrreSeconds() = getAttributeInt("bottle_of_jyrre_seconds") fun ItemStack.getEdition() = getAttributeInt("edition") From 49b85525378f2a7b431c4aa233d036db231016c3 Mon Sep 17 00:00:00 2001 From: Obsidianninja11 Date: Tue, 28 May 2024 20:40:43 -0800 Subject: [PATCH 2/9] Fixes --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- .../features/inventory/InventoryConfig.java | 4 ++-- .../features/inventory/HeldTimeInLore.kt | 20 +++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 5e1924b2d8c7..24cf594d8e52 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -935,7 +935,7 @@ class SkyHanniMod { loadModule(SkillTooltip()) loadModule(MaxPurseItems()) loadModule(SuperCraftFeatures) - loadModule(HeldTimeInLore()) + loadModule(HeldTimeInLore) loadModule(InfernoMinionFeatures()) loadModule(LimboPlaytime) loadModule(CopyPlaytime) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 8035eac095dd..872fb8ad6ba1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -231,8 +231,8 @@ public String toString() { public boolean shiftClickBrewing = false; @Expose - @ConfigOption(name = "Held Time in Lore", desc = "Shows the held time for Bottle of Jyrre and Dark Cacao Truffle in lore.") + @ConfigOption(name = "Time Held in Lore", desc = "Shows time held for Bottle of Jyrre and Dark Cacao Truffle in the lore.") @ConfigEditorBoolean @FeatureToggle - public boolean heldTimeInLore = false; + public boolean timeHeldInLore = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index ba66ab04264b..067675297f80 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -3,13 +3,16 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSeconds import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getSecondsHeld -import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.DurationUnit +import kotlin.time.toDuration -class HeldTimeInLore { +object HeldTimeInLore { private val config get() = SkyHanniMod.feature.inventory private val jyrreBottle by lazy { "NEW_BOTTLE_OF_JYRRE".asInternalName() } @@ -17,18 +20,19 @@ class HeldTimeInLore { @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { - if (!config.heldTimeInLore) return - if (event.toolTip.size < 10) return // to fix when tooltip isn't fully loaded - + if (!config.timeHeldInLore) return + if (!LorenzUtils.inSkyBlock) return + if (event.toolTip.size < 10) return // Fixes conflict with NEU's sort warning val stack = event.itemStack val internalName = stack.getInternalName() - val timeHeld = TimeUtils.formatDuration( + val timeHeld = ( when (internalName) { jyrreBottle -> stack.getBottleOfJyrreSeconds() ?: return cacaoTruffle -> stack.getSecondsHeld() ?: return else -> return - }.toLong() * 1000 - 999 - ) + } + ).toDuration(DurationUnit.SECONDS).format() + event.toolTip.add(10, "§7Time Held: §b$timeHeld") } } From bbc1c3d7896c68231379a1eed067d96af0fe7535 Mon Sep 17 00:00:00 2001 From: Obsidianninja11 Date: Wed, 29 May 2024 00:26:22 -0800 Subject: [PATCH 3/9] Remove neu ah thing fix bc cal made better fix --- .../at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index 067675297f80..cc11c8a12271 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -22,7 +22,6 @@ object HeldTimeInLore { fun onTooltip(event: LorenzToolTipEvent) { if (!config.timeHeldInLore) return if (!LorenzUtils.inSkyBlock) return - if (event.toolTip.size < 10) return // Fixes conflict with NEU's sort warning val stack = event.itemStack val internalName = stack.getInternalName() val timeHeld = ( From d53667c359e9742794175ef98c89b6b945f2ed9e Mon Sep 17 00:00:00 2001 From: Obsidian <108832807+Obsidianninja11@users.noreply.github.com> Date: Wed, 29 May 2024 14:58:39 -0800 Subject: [PATCH 4/9] Cals suggestion Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../features/inventory/HeldTimeInLore.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index cc11c8a12271..d41f91f4fb92 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -24,14 +24,13 @@ object HeldTimeInLore { if (!LorenzUtils.inSkyBlock) return val stack = event.itemStack val internalName = stack.getInternalName() - val timeHeld = ( - when (internalName) { - jyrreBottle -> stack.getBottleOfJyrreSeconds() ?: return - cacaoTruffle -> stack.getSecondsHeld() ?: return - else -> return - } - ).toDuration(DurationUnit.SECONDS).format() - - event.toolTip.add(10, "§7Time Held: §b$timeHeld") + val timeHeld = when (internalName) { + jyrreBottle -> stack.getBottleOfJyrreSeconds() + cacaoTruffle -> stack.getSecondsHeld() + else -> return + } ?: return + val formatted = timeHeld.seconds.format() + + event.toolTip.add(10, "§7Time Held: §b$formatted") } } From 80bfecbf16407bffae717dbe3c01f8555b4a91ae Mon Sep 17 00:00:00 2001 From: Obsidianninja11 Date: Wed, 29 May 2024 15:14:00 -0800 Subject: [PATCH 5/9] smh cal didn't import --- .../at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index d41f91f4fb92..47ec6e7ee16e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -9,8 +9,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSec import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getSecondsHeld import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.DurationUnit -import kotlin.time.toDuration +import kotlin.time.Duration.Companion.seconds object HeldTimeInLore { private val config get() = SkyHanniMod.feature.inventory From b2737fdf0faa1348149ce4c3caa3037c6ea46427 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 30 May 2024 11:26:07 +0200 Subject: [PATCH 6/9] code cleanup --- .../skyhanni/utils/SkyBlockItemModifierUtils.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index 08c50948034f..1780764cdfcc 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -179,18 +179,20 @@ object SkyBlockItemModifierUtils { fun ItemStack.getLivingMetalProgress() = getAttributeInt("lm_evo") - fun ItemStack.getSecondsHeld() = getAttributeInt("seconds_held") + fun ItemStack.getBottleOfJyrreSeconds() = getAttributeInt("bottle_of_jyrre_seconds") fun ItemStack.getEdition() = getAttributeInt("edition") fun ItemStack.getNewYearCake() = getAttributeInt("new_years_cake") - fun ItemStack.getEnchantments(): Map? = getExtraAttributes()?.takeIf { it.hasKey("enchantments") }?.run { - val enchantments = this.getCompoundTag("enchantments") - enchantments.keySet.associateWith { enchantments.getInteger(it) } - } + fun ItemStack.getEnchantments(): Map? = getExtraAttributes() + ?.takeIf { it.hasKey("enchantments") } + ?.run { + val enchantments = this.getCompoundTag("enchantments") + enchantments.keySet.associateWith { enchantments.getInteger(it) } + } fun ItemStack.getAppliedPocketSackInASack(): Int? { val data = cachedData From f1c676798f8c4c9cac59021aa6bb76ef589fde1c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 30 May 2024 11:26:20 +0200 Subject: [PATCH 7/9] fixed potential config crash --- .../at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index 47ec6e7ee16e..674428a059a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -19,8 +19,8 @@ object HeldTimeInLore { @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { - if (!config.timeHeldInLore) return if (!LorenzUtils.inSkyBlock) return + if (!config.timeHeldInLore) return val stack = event.itemStack val internalName = stack.getInternalName() val timeHeld = when (internalName) { From a38e96bd5d70f7476439bfbdbd8eaf519f91e013 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 30 May 2024 11:28:02 +0200 Subject: [PATCH 8/9] code cleanup --- .../hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index 674428a059a4..4d5592d9bfc6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -21,13 +21,14 @@ object HeldTimeInLore { fun onTooltip(event: LorenzToolTipEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.timeHeldInLore) return + val stack = event.itemStack - val internalName = stack.getInternalName() - val timeHeld = when (internalName) { + val timeHeld = when (stack.getInternalName()) { jyrreBottle -> stack.getBottleOfJyrreSeconds() cacaoTruffle -> stack.getSecondsHeld() else -> return } ?: return + val formatted = timeHeld.seconds.format() event.toolTip.add(10, "§7Time Held: §b$formatted") From 7a0b8a1fdecd041a34846706fc97ec4947d5be64 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 30 May 2024 11:32:42 +0200 Subject: [PATCH 9/9] extract function --- .../features/inventory/HeldTimeInLore.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index 4d5592d9bfc6..99801a3224c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSeconds import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getSecondsHeld import at.hannibal2.skyhanni.utils.TimeUtils.format +import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -22,15 +23,15 @@ object HeldTimeInLore { if (!LorenzUtils.inSkyBlock) return if (!config.timeHeldInLore) return - val stack = event.itemStack - val timeHeld = when (stack.getInternalName()) { - jyrreBottle -> stack.getBottleOfJyrreSeconds() - cacaoTruffle -> stack.getSecondsHeld() - else -> return - } ?: return + val seconds = event.itemStack.getSeconds() ?: return + val formatted = seconds.seconds.format() - val formatted = timeHeld.seconds.format() - event.toolTip.add(10, "§7Time Held: §b$formatted") } + + private fun ItemStack.getSeconds(): Int? = when (getInternalName()) { + jyrreBottle -> getBottleOfJyrreSeconds() + cacaoTruffle -> getSecondsHeld() + else -> null + } }