diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-06-14 15:48:37 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-06-14 15:48:37 +0200 |
commit | a996d8150ef2367e7c839f3565d60bdb68d2125d (patch) | |
tree | 4da38c50d07b3e2cfa0352694d254225a715715e /src/main/java/at/hannibal2/skyhanni/utils | |
parent | 9f55fd15544e187491d78e2c5ecf2f2ed8ac76f1 (diff) | |
download | skyhanni-a996d8150ef2367e7c839f3565d60bdb68d2125d.tar.gz skyhanni-a996d8150ef2367e7c839f3565d60bdb68d2125d.tar.bz2 skyhanni-a996d8150ef2367e7c839f3565d60bdb68d2125d.zip |
Revert "creating and using Number.format()"
This reverts commit 9f55fd15544e187491d78e2c5ecf2f2ed8ac76f1.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 16 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt | 6 |
2 files changed, 8 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index c5ce8cea0..742bc3654 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -36,25 +36,19 @@ object NumberUtil { ) ) - @Deprecated("outdated", ReplaceWith("value.format(preciseBillions)")) - fun format(value: Number, preciseBillions: Boolean = false): String = value.format(preciseBillions) - - // 1234 -> 1.2k - fun Number.format(preciseBillions: Boolean = false): String { - return compactFormat(this, preciseBillions) - } - /** * This code was modified and taken under CC BY-SA 3.0 license * @link https://stackoverflow.com/a/30661479 * @author assylias */ - private fun compactFormat(value: Number, preciseBillions: Boolean = false): String { + + @JvmStatic + fun format(value: Number, preciseBillions: Boolean = false): String { @Suppress("NAME_SHADOWING") val value = value.toLong() // Long.MIN_VALUE == -Long.MIN_VALUE, so we need an adjustment here - if (value == Long.MIN_VALUE) return compactFormat(Long.MIN_VALUE + 1, preciseBillions) - if (value < 0) return "-" + compactFormat(-value, preciseBillions) + if (value == Long.MIN_VALUE) return format(Long.MIN_VALUE + 1, preciseBillions) + if (value < 0) return "-" + format(-value, preciseBillions) if (value < 1000) return value.toString() // deal with small numbers diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index 2e8b990a9..57595c1c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -13,8 +13,8 @@ import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.renderables.Renderable import kotlin.time.Duration.Companion.seconds @@ -106,7 +106,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( internalName.itemName } - val priceFormat = price.format() + val priceFormat = NumberUtil.format(price) val hidden = itemProfit.hidden val newDrop = itemProfit.lastTimeUpdated.passedSince() < 10.seconds && config.showRecentDrops val numberColor = if (newDrop) "§a§l" else "§7" @@ -183,7 +183,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( val tips = if (totalAmount > 0) { val profitPerCatch = profit / totalAmount - val profitPerCatchFormat = profitPerCatch.format() + val profitPerCatchFormat = NumberUtil.format(profitPerCatch) listOf("§7Profit per $action: $profitPrefix$profitPerCatchFormat") } else emptyList() |