Fix NPE when printing Null value enchantment (Rollbar#156)

This commit is contained in:
sandtechnology committed 2021-05-17 11:11:19 +08:00
1 parent 693c91db55
commit 2a8159bc4a
1 file changed
+3 -1
@@ -905,7 +905,9 @@ public class MsgUtil {
private static void printEnchantment(ChatSheetPrinter chatSheetPrinter, Map<Enchantment, Integer> enchs) {
for (Entry<Enchantment, Integer> entries : enchs.entrySet()) {
chatSheetPrinter.printLine(ChatColor.YELLOW + MsgUtil.getEnchi18n(entries.getKey()) + " " + RomanNumber.toRoman(entries.getValue()));
//Use boxed object to avoid NPE
Integer level = entries.getValue();
chatSheetPrinter.printLine(ChatColor.YELLOW + MsgUtil.getEnchi18n(entries.getKey()) + " " + RomanNumber.toRoman(level == null ? 1 : level));
}
}