From e90e7b37934003a9490d14e435a5a0d26fcc91cf Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 17 Aug 2022 19:57:47 +0700 Subject: [PATCH] Fix no suffix being concated to formatted text --- src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt index fba3f11ea..4e0fe98c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt @@ -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) }