Fix error handling if a referenced world is unloaded; resolves #410

This commit is contained in:
Daniel Saukel 2018-06-05 13:04:02 +02:00
parent b236431456
commit 186dd1192b

View File

@ -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<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();
}
}