Merge pull request #4062 from kevlahnota/newmaster2

prevent NPE when loading save with null boosters object
This commit is contained in:
kevlahnota
2023-11-01 19:35:15 +08:00
committed by GitHub

View File

@@ -384,6 +384,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
} }
if (data.containsKey("boosters")) { if (data.containsKey("boosters")) {
Deck[] decks = (Deck[]) data.readObject("boosters"); Deck[] decks = (Deck[]) data.readObject("boosters");
if (decks != null) {
for (Deck d : decks) { for (Deck d : decks) {
if (d != null && !d.isEmpty()) { if (d != null && !d.isEmpty()) {
boostersOwned.add(d); boostersOwned.add(d);
@@ -392,6 +393,9 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
System.out.println("You have an empty booster pack in your inventory."); System.out.println("You have an empty booster pack in your inventory.");
} }
} }
} else {
System.err.println("Deck[] is null! [boosters]");
}
} }
deck = new Deck(data.readString("deckName")); deck = new Deck(data.readString("deckName"));