mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Fix trait serialization. Fixes #342
This commit is contained in:
parent
89196c1adc
commit
f0b57a2bbf
2 changed files with 6 additions and 2 deletions
|
@ -319,7 +319,7 @@ public final class SpellTraits implements Iterable<Map.Entry<Trait, Float>> {
|
||||||
|
|
||||||
public static Stream<Map.Entry<Trait, Float>> streamFromJson(JsonObject traits) {
|
public static Stream<Map.Entry<Trait, Float>> streamFromJson(JsonObject traits) {
|
||||||
return traits.entrySet().stream().map(entry -> {
|
return traits.entrySet().stream().map(entry -> {
|
||||||
Trait trait = Trait.fromName(entry.getKey()).orElse(null);
|
Trait trait = Trait.fromId(entry.getKey()).orElse(null);
|
||||||
if (trait == null || !entry.getValue().isJsonPrimitive() && !entry.getValue().getAsJsonPrimitive().isNumber()) {
|
if (trait == null || !entry.getValue().isJsonPrimitive() && !entry.getValue().getAsJsonPrimitive().isNumber()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,11 @@ public enum Trait implements CommandArgumentEnum<Trait> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<Trait> fromName(String name) {
|
public static Optional<Trait> fromName(String name) {
|
||||||
return Optional.ofNullable(REGISTRY.getOrDefault(name.toUpperCase(), null));
|
Trait trait = REGISTRY.getOrDefault(name.toUpperCase(), null);
|
||||||
|
if (trait == null) {
|
||||||
|
Unicopia.LOGGER.error("Unknown trait: " + name);
|
||||||
|
}
|
||||||
|
return Optional.ofNullable(trait);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnumArgumentType<Trait> argument() {
|
public static EnumArgumentType<Trait> argument() {
|
||||||
|
|
Loading…
Reference in a new issue