From c74ff62d3fb211d4cd7fc3df18b16fb0cbcc978c Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:57:59 +1000 Subject: meta: Fix game crashing if invalid roman numeral (#1192) --- .../github/moulberry/notenoughupdates/util/KotlinNumberUtils.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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]!! -- cgit