Fixed exception when encountering unknown traits whilst loading from json

This commit is contained in:
Sollace 2021-11-13 23:27:57 +02:00
parent aed4efcbbe
commit 0beaaa4603

View file

@ -201,7 +201,7 @@ public final class SpellTraits implements Iterable<Map.Entry<Trait, Float>> {
public static Stream<Map.Entry<Trait, Float>> streamFromJson(JsonObject traits) {
return traits.entrySet().stream().map(entry -> {
Trait trait = Trait.REGISTRY.get(entry.getKey().toUpperCase());
if (trait == null && !entry.getValue().isJsonPrimitive() && !entry.getValue().getAsJsonPrimitive().isNumber()) {
if (trait == null || !entry.getValue().isJsonPrimitive() && !entry.getValue().getAsJsonPrimitive().isNumber()) {
return null;
}
return Map.entry(trait, entry.getValue().getAsJsonPrimitive().getAsFloat());