diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-05-04 23:23:43 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-04 15:23:43 +0200 |
commit | eaaacb33b7164c6304add968d9a442dea1059fd2 (patch) | |
tree | 6e41afaaba09216f6f69fc979ea3db9fe5d4fd06 /src/main | |
parent | 248258f556c2f76ce8939e1eb1a57e356961c079 (diff) | |
download | skyhanni-eaaacb33b7164c6304add968d9a442dea1059fd2.tar.gz skyhanni-eaaacb33b7164c6304add968d9a442dea1059fd2.tar.bz2 skyhanni-eaaacb33b7164c6304add968d9a442dea1059fd2.zip |
Fix: Pluralize negative changes (#1686)
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt | 3 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 3 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt index fc0a66786..f71a4b341 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.TimeUtils.format object ChocolatePositionChange { @@ -23,7 +24,7 @@ object ChocolatePositionChange { var message = "§b$lastLb §c-> §b$leaderboard" val change = lastPosition - position val color = if (change > 0) "§a+" else "§c" - message += "\n §7Changed by $color${change.addSeparators()} spots" + message += "\n §7Changed by $color${change.addSeparators()} ${StringUtils.pluralize(change, "spot")}" lastTime?.let { message += " §7in §b${it.passedSince().format(maxUnits = 2)}" diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 4feb0ba13..c52927291 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -4,7 +4,6 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.mixins.transformers.AccessorChatComponentText import at.hannibal2.skyhanni.utils.GuiRenderUtils.darkenColor import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.StringUtils.width import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiUtilRenderComponents import net.minecraft.util.ChatComponentText @@ -209,7 +208,7 @@ object StringUtils { fun pluralize(number: Int, singular: String, plural: String? = null, withNumber: Boolean = false): String { val pluralForm = plural ?: "${singular}s" - var str = if (number == 1) singular else pluralForm + var str = if (number == 1 || number == -1) singular else pluralForm if (withNumber) str = "${number.addSeparators()} $str" return str } |