Skip to content

Commit

Permalink
Fix error handling if a referenced world is unloaded; resolves #410
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed Jun 5, 2018
1 parent b236431 commit 186dd11
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/de/erethon/dungeonsxl/player/DPlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public void setKeepInventoryAfterLogout(boolean keepInventoryAfterLogout) {
* @return the old location
*/
public Location getOldLocation() {
if (oldLocation.getWorld() == null) {
return Bukkit.getWorlds().get(0).getSpawnLocation();
}
return oldLocation;
}

Expand Down Expand Up @@ -427,8 +430,9 @@ public void load() {
}
oldPotionEffects = (Collection<PotionEffect>) 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();
}
}
Expand Down

0 comments on commit 186dd11

Please sign in to comment.