Fix no suffix being concated to formatted text

This commit is contained in:
DBotThePony 2022-08-17 19:57:47 +07:00
parent b6e57632a6
commit e90e7b3793
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -240,7 +240,7 @@ fun BigInteger.formatSi(decimalPlaces: Int = 2): String {
fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component {
require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" }
val prefix = determineSiPrefix() ?: return TextComponent(toString())
val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent(toString(decimalPlaces) + suffix.string) else TextComponent(toString(decimalPlaces) + suffix)
val isNegative = isNegative
val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer)
val divided = arr[0].toString()
@ -320,7 +320,7 @@ fun ImpreciseFraction.formatSi(decimalPlaces: Int = 2): String {
fun ImpreciseFraction.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component {
require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" }
val prefix = determineSiPrefix() ?: return TextComponent(toString(decimalPlaces))
val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent(toString(decimalPlaces) + " " + suffix.string) else TextComponent(toString(decimalPlaces) + " " + suffix)
return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.impreciseFraction).toString(decimalPlaces), suffix)
}