From 8347d2a3e44f59de1f1598ce96560b037bf90d15 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:03:59 +0100 Subject: [PATCH] Fix: Skill progress NumberFormatException (#3105) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/skillprogress/SkillProgress.kt | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt index 658cac0120c7..e46d7ab8841a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt @@ -463,20 +463,28 @@ object SkillProgress { } if (config.showActionLeft.get() && percent != 100f) { - append(" - ") - val gain = skill.lastGain.formatDouble() - val actionLeft = (ceil(currentXpMax.toDouble() - currentXp) / gain).toLong().plus(1).addSeparators() - if (skill.lastGain != "" && !actionLeft.contains("-")) { - append("§6$actionLeft Left") - } else { - append("§6∞ Left") - } + append(" - " + addActionsLeft(skill, currentXpMax, currentXp)) } }, ), ) } + private fun addActionsLeft( + skill: SkillAPI.SkillInfo, + currentXpMax: Long, + currentXp: Long, + ): String { + if (skill.lastGain != "") { + val gain = skill.lastGain.formatDouble() + val actionLeft = (ceil(currentXpMax.toDouble() - currentXp) / gain).toLong().plus(1).addSeparators() + if (skill.lastGain != "" && !actionLeft.contains("-")) { + return "§6$actionLeft Left" + } + } + return "§6∞ Left" + } + private fun updateSkillInfo() { val activeSkill = activeSkill ?: return val xpInfo = skillXPInfoMap.getOrPut(activeSkill) { SkillAPI.SkillXPInfo() }