mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-20 03:44:23 +01:00
Catch exceptions when deserialising spell nbt
This commit is contained in:
parent
4a73cae094
commit
fc792c930e
1 changed files with 11 additions and 6 deletions
|
@ -7,6 +7,7 @@ import java.util.stream.Stream;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.include.com.google.common.base.Objects;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.magic.Affine;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||
|
@ -107,6 +108,7 @@ public interface Spell extends NbtSerialisable, Affine {
|
|||
|
||||
@Nullable
|
||||
static Spell readNbt(@Nullable NbtCompound compound) {
|
||||
try {
|
||||
if (compound != null && compound.contains("effect_id")) {
|
||||
Spell effect = SpellType.getKey(compound).withTraits().create();
|
||||
|
||||
|
@ -116,6 +118,9 @@ public interface Spell extends NbtSerialisable, Affine {
|
|||
|
||||
return effect;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Unicopia.LOGGER.fatal("Invalid spell nbt {}", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue