aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2024-06-01 21:57:59 +1000
committerGitHub <noreply@github.com>2024-06-01 13:57:59 +0200
commitc74ff62d3fb211d4cd7fc3df18b16fb0cbcc978c (patch)
tree81191dbd83ffa644db557328b800b805e1fc95f6 /src
parentc20969ccecc09dc74792f3348c3061a2c5a3fa1a (diff)
downloadNotEnoughUpdates-c74ff62d3fb211d4cd7fc3df18b16fb0cbcc978c.tar.gz
NotEnoughUpdates-c74ff62d3fb211d4cd7fc3df18b16fb0cbcc978c.tar.bz2
NotEnoughUpdates-c74ff62d3fb211d4cd7fc3df18b16fb0cbcc978c.zip
meta: Fix game crashing if invalid roman numeral (#1192)
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/util/KotlinNumberUtils.kt8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/KotlinNumberUtils.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/KotlinNumberUtils.kt
index 97d0aa1b..ae8479f4 100644
--- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/KotlinNumberUtils.kt
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/KotlinNumberUtils.kt
@@ -19,6 +19,8 @@
package io.github.moulberry.notenoughupdates.util
+import net.minecraft.util.EnumChatFormatting.RED
+import net.minecraft.util.EnumChatFormatting.YELLOW
import java.util.*
import kotlin.math.pow
import kotlin.math.round
@@ -47,7 +49,11 @@ private val romanSymbols = TreeMap(
)
fun Int.toRoman(): String {
- if (this <= 0) error("$this must be positive!")
+ if (this <= 0) {
+ Utils.addChatMessage("$YELLOW[NEU] ${RED}Invalid number roman numeral conversion: $this")
+ Utils.addChatMessage("$YELLOW[NEU] ${RED}Please report this to discord.gg/moulberry")
+ return "?"
+ }
val l = romanSymbols.floorKey(this)
return if (this == l) {
romanSymbols[this]!!