From 186dd1192b1ea7953e873ba6992fdef21c5d3a56 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Tue, 5 Jun 2018 13:04:02 +0200 Subject: [PATCH] Fix error handling if a referenced world is unloaded; resolves #410 --- .../java/de/erethon/dungeonsxl/player/DPlayerData.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/erethon/dungeonsxl/player/DPlayerData.java b/src/main/java/de/erethon/dungeonsxl/player/DPlayerData.java index 83182f1a..e7f4916e 100644 --- a/src/main/java/de/erethon/dungeonsxl/player/DPlayerData.java +++ b/src/main/java/de/erethon/dungeonsxl/player/DPlayerData.java @@ -110,6 +110,9 @@ public class DPlayerData extends DREConfig { * @return the old location */ public Location getOldLocation() { + if (oldLocation.getWorld() == null) { + return Bukkit.getWorlds().get(0).getSpawnLocation(); + } return oldLocation; } @@ -427,8 +430,9 @@ public class DPlayerData extends DREConfig { } oldPotionEffects = (Collection) config.get(PREFIX_STATE_PERSISTENCE + "oldPotionEffects"); - oldLocation = (Location) config.get(PREFIX_STATE_PERSISTENCE + "oldLocation"); - if (oldLocation.getWorld() == null) { + try { + oldLocation = (Location) config.get(PREFIX_STATE_PERSISTENCE + "oldLocation"); + } catch (IllegalArgumentException exception) { oldLocation = Bukkit.getWorlds().get(0).getSpawnLocation(); } }