From 4576147103128546bf75d0889f7e52e873717da5 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 6 Mar 2025 11:14:25 -0500 Subject: [PATCH] v3.0.1: added safety checks to loading for sandals and spellbook --- .../items/artifacts/SandalsOfNature.java | 6 ++++-- .../items/artifacts/UnstableSpellbook.java | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java index 811b09aa0..09b200b51 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java @@ -65,7 +65,6 @@ import com.watabou.utils.Random; import com.watabou.utils.Reflection; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; public class SandalsOfNature extends Artifact { @@ -256,8 +255,11 @@ public class SandalsOfNature extends Artifact { @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); + seeds.clear(); if (bundle.contains(SEEDS) && bundle.getClassArray(SEEDS) != null) { - Collections.addAll(seeds, bundle.getClassArray(SEEDS)); + for (Class seed : bundle.getClassArray(SEEDS)) { + if (seed != null) seeds.add(seed); + } } curSeedEffect = bundle.getClass(CUR_SEED_EFFECT); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java index 8f7fcdf5e..0afa42419 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java @@ -61,7 +61,6 @@ import com.watabou.utils.Random; import com.watabou.utils.Reflection; import java.util.ArrayList; -import java.util.Collections; public class UnstableSpellbook extends Artifact { @@ -330,8 +329,10 @@ public class UnstableSpellbook extends Artifact { public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); scrolls.clear(); - if (bundle.contains(SCROLLS)) { - Collections.addAll(scrolls, bundle.getClassArray(SCROLLS)); + if (bundle.contains(SCROLLS) && bundle.getClassArray(SCROLLS) != null) { + for (Class scroll : bundle.getClassArray(SCROLLS)) { + if (scroll != null) scrolls.add(scroll); + } } }