From aa0e27f12d7a2063e82611872cfd3b7dea26b462 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:23:32 +0100 Subject: marked more number formatting code as deprecated. --- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index cd71efe65..fe4725b86 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign import at.hannibal2.skyhanni.test.TestBingo import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.StringUtils.capAtMinecraftLength import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID @@ -34,7 +35,6 @@ import java.lang.reflect.Constructor import java.lang.reflect.Field import java.lang.reflect.Modifier import java.text.DecimalFormat -import java.text.NumberFormat import java.text.SimpleDateFormat import java.util.Collections import java.util.LinkedList @@ -227,14 +227,15 @@ object LorenzUtils { fun formatPercentage(percentage: Double, format: String?): String = DecimalFormat(format).format(percentage * 100).replace(',', '.') + "%" - fun formatInteger(i: Int): String = formatInteger(i.toLong()) + @Deprecated("old code", ReplaceWith("addSeparator()")) + fun formatInteger(i: Int): String = i.addSeparators() - fun formatInteger(l: Long): String = NumberFormat.getIntegerInstance().format(l) + @Deprecated("old code", ReplaceWith("addSeparator()")) + fun formatInteger(l: Long): String = l.addSeparators() + @Deprecated("old code", ReplaceWith("round() and addSeparator()")) fun formatDouble(d: Double, round: Int = 1): String { - val numberInstance = NumberFormat.getNumberInstance() - numberInstance.maximumFractionDigits = round - return numberInstance.format(d.round(round)) + return d.round(round).addSeparators() } fun consoleLog(text: String) { @@ -706,7 +707,7 @@ object LorenzUtils { while (true) list.add(this.poll() ?: break) } - + // Let garbage collector handle the removal of entries in this list fun weakReferenceList(): MutableSet = Collections.newSetFromMap(WeakHashMap()) -- cgit