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.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.include.com.google.common.base.Objects;
|
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.Affine;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||||
|
@ -107,14 +108,18 @@ public interface Spell extends NbtSerialisable, Affine {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
static Spell readNbt(@Nullable NbtCompound compound) {
|
static Spell readNbt(@Nullable NbtCompound compound) {
|
||||||
if (compound != null && compound.contains("effect_id")) {
|
try {
|
||||||
Spell effect = SpellType.getKey(compound).withTraits().create();
|
if (compound != null && compound.contains("effect_id")) {
|
||||||
|
Spell effect = SpellType.getKey(compound).withTraits().create();
|
||||||
|
|
||||||
if (effect != null) {
|
if (effect != null) {
|
||||||
effect.fromNBT(compound);
|
effect.fromNBT(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return effect;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
return effect;
|
Unicopia.LOGGER.fatal("Invalid spell nbt {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue