Fix possible NPE when loading material sets from config

This commit is contained in:
Phoenix616 2021-07-09 11:26:30 +01:00
parent 129663650f
commit 13b727c779
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 4 additions and 3 deletions

View File

@ -43,9 +43,10 @@ public class Properties {
if (o instanceof Material) { if (o instanceof Material) {
set.add((Material) o); set.add((Material) o);
} else if (o instanceof String) { } else if (o instanceof String) {
try { Material m = Material.getMaterial(((String) o).toUpperCase(Locale.ROOT));
set.add(Material.getMaterial(((String) o).toUpperCase(Locale.ROOT))); if (m != null) {
} catch (IllegalArgumentException e) { set.add(m);
} else {
ChestShop.getBukkitLogger().log(Level.WARNING, o + " is not a valid Material name in the config!"); ChestShop.getBukkitLogger().log(Level.WARNING, o + " is not a valid Material name in the config!");
} }
} }