diff options
| author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-07-31 13:10:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-31 13:10:25 -0400 |
| commit | 77cf96065343badf2e5478b51616296e507416a9 (patch) | |
| tree | 41c80d3d8a70a6cd6d1afd5311b9c478088755e9 /src/main/java/de | |
| parent | 4326f83dfef63eaa1541b4c559289f1d82e8d1e2 (diff) | |
| download | Skyblocker-77cf96065343badf2e5478b51616296e507416a9.tar.gz Skyblocker-77cf96065343badf2e5478b51616296e507416a9.tar.bz2 Skyblocker-77cf96065343badf2e5478b51616296e507416a9.zip | |
Fix Roman Numeral parsing crash (#882)
Diffstat (limited to 'src/main/java/de')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/RomanNumerals.java | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/RomanNumerals.java b/src/main/java/de/hysky/skyblocker/utils/RomanNumerals.java index ce2e6067..d6291d75 100644 --- a/src/main/java/de/hysky/skyblocker/utils/RomanNumerals.java +++ b/src/main/java/de/hysky/skyblocker/utils/RomanNumerals.java @@ -35,8 +35,7 @@ public class RomanNumerals { * Converts a roman numeral to a decimal number. * * @param romanNumeral The roman numeral to convert. - * @return The decimal number, or 0 if the string is empty or null. - * @throws IllegalArgumentException If the roman numeral is malformed. + * @return The decimal number, or 0 if the string is empty, null, or malformed. */ public static int romanToDecimal(String romanNumeral) { if (romanNumeral == null || romanNumeral.isEmpty()) return 0; @@ -46,7 +45,7 @@ public class RomanNumerals { for (int i = romanNumeral.length() - 1; i >= 0; i--) { char ch = romanNumeral.charAt(i); int number = getDecimalValue(ch); - if (number == 0) throw new IllegalArgumentException("Malformed roman numeral: " + romanNumeral); + if (number == 0) return 0; //Malformed roman numeral decimal = number >= lastNumber ? decimal + number : decimal - number; lastNumber = number; } |
