aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authormartimavocado <39881008+martimavocado@users.noreply.github.com>2024-09-21 22:13:15 +0100
committerGitHub <noreply@github.com>2024-09-21 23:13:15 +0200
commitd2072b83949b90bd7c2f5bfa6bd0c08941953879 (patch)
tree32f1fa9d30a77fff003d60db0b1fe02e393ccd70 /src/main/java/at/hannibal2/skyhanni
parent9db106b981b827ea254ca7dbe8cd924dc90375eb (diff)
downloadskyhanni-d2072b83949b90bd7c2f5bfa6bd0c08941953879.tar.gz
skyhanni-d2072b83949b90bd7c2f5bfa6bd0c08941953879.tar.bz2
skyhanni-d2072b83949b90bd7c2f5bfa6bd0c08941953879.zip
Feature: Force locale for Number Formatting (#2563)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt9
2 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java
index b62c88efc..6daf37cfd 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java
@@ -109,6 +109,13 @@ public class DevConfig {
public boolean fancySbaContributors = false;
@Expose
+ @ConfigOption(
+ name = "Number Format Override",
+ desc = "Forces the number format to use the en_US locale.")
+ @ConfigEditorBoolean
+ public boolean numberFormatOverride = false;
+
+ @Expose
@Category(name = "Minecraft Console", desc = "Minecraft Console Settings")
public MinecraftConsoleConfig minecraftConsoles = new MinecraftConsoleConfig();
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index b97298ce4..4d5fe0a1d 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -1,14 +1,18 @@
package at.hannibal2.skyhanni.utils
+import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import java.text.NumberFormat
+import java.util.Locale
import java.util.TreeMap
import kotlin.math.pow
import kotlin.math.roundToInt
object NumberUtil {
+ private val config get() = SkyHanniMod.feature
+
private val suffixes = TreeMap<Long, String>().apply {
this[1000L] = "k"
this[1000000L] = "M"
@@ -109,7 +113,10 @@ object NumberUtil {
return this.toString() + this.ordinal()
}
- fun Number.addSeparators() = NumberFormat.getNumberInstance().format(this)
+ fun Number.addSeparators(): String {
+ return if (!config.dev.numberFormatOverride) NumberFormat.getNumberInstance().format(this)
+ else NumberFormat.getNumberInstance(Locale.US).format(this)
+ }
fun String.romanToDecimalIfNecessary() = toIntOrNull() ?: romanToDecimal()