diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-26 12:11:09 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-26 12:11:09 +0200 |
commit | 7fc421dc3e81d0cf60387516c74768db2bde9658 (patch) | |
tree | 46233f8b9b0b278057f98caa13b9e001a0c61d17 /src/main/java/at/hannibal2/skyhanni/features | |
parent | aadd38cde3f8f0abb9ad11b1aac273d840bfb069 (diff) | |
download | skyhanni-7fc421dc3e81d0cf60387516c74768db2bde9658.tar.gz skyhanni-7fc421dc3e81d0cf60387516c74768db2bde9658.tar.bz2 skyhanni-7fc421dc3e81d0cf60387516c74768db2bde9658.zip |
Fixed bug in ghost counter if bestiaryNextLevel or hidden is null
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt index 95432ef82..154349dcf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt @@ -92,13 +92,20 @@ object GhostUtil { } fun String.formatBestiary(currentKill: Int, killNeeded: Int): String { + val bestiaryNextLevel = GhostCounter.hidden?.bestiaryNextLevel + val currentLevel = + bestiaryNextLevel?.let { if (it.toInt() < 0) "46" else "${it.toInt() - 1}" } ?: "§cNo Bestiary Level Data!" + val nextLevel = bestiaryNextLevel?.let { if (GhostCounter.config.showMax) "46" else "${it.toInt()}" } + ?: "§cNo Bestiary Level data!" + return Utils.chromaStringByColourCode( this.replace("%currentKill%", if (GhostCounter.config.showMax) GhostCounter.bestiaryCurrentKill.addSeparators() else currentKill.addSeparators()) .replace("%percentNumber%", percent(GhostCounter.bestiaryCurrentKill.toDouble())) .replace("%killNeeded%", NumberUtil.format(killNeeded)) - .replace("%currentLevel%", if (GhostCounter.hidden?.bestiaryNextLevel?.toInt()!! < 0) "46" else "${GhostCounter.hidden?.bestiaryNextLevel?.toInt()!! - 1}") - .replace("%nextLevel%", if (GhostCounter.config.showMax) "46" else "${GhostCounter.hidden?.bestiaryNextLevel?.toInt()!!}") - .replace("&", "§")) + .replace("%currentLevel%", currentLevel) + .replace("%nextLevel%", nextLevel) + .replace("&", "§") + ) } private fun percent(number: Double): String { |