Protection against deleted worlds.

This commit is contained in:
Brianna 2019-05-21 19:38:38 -04:00
parent 005dd5d495
commit e97a991c25
2 changed files with 3 additions and 2 deletions

View File

@ -271,6 +271,7 @@ public class UltimateKits extends JavaPlugin {
*/ */
for (KitBlockData kitBlockData : kitManager.getKitLocations().values()) { for (KitBlockData kitBlockData : kitManager.getKitLocations().values()) {
String locationStr = Methods.serializeLocation(kitBlockData.getLocation()); String locationStr = Methods.serializeLocation(kitBlockData.getLocation());
if (locationStr == null) continue;
dataFile.getConfig().set("BlockData." + locationStr + ".type", kitBlockData.getType().name()); dataFile.getConfig().set("BlockData." + locationStr + ".type", kitBlockData.getType().name());
dataFile.getConfig().set("BlockData." + locationStr + ".kit", kitBlockData.getKit().getName()); dataFile.getConfig().set("BlockData." + locationStr + ".kit", kitBlockData.getKit().getName());
dataFile.getConfig().set("BlockData." + locationStr + ".holograms", kitBlockData.showHologram()); dataFile.getConfig().set("BlockData." + locationStr + ".holograms", kitBlockData.showHologram());

View File

@ -101,8 +101,8 @@ public class Methods {
* @return The serialized data. * @return The serialized data.
*/ */
public static String serializeLocation(Location location) { public static String serializeLocation(Location location) {
if (location == null) if (location == null || location.getWorld() == null)
return ""; return null;
String w = location.getWorld().getName(); String w = location.getWorld().getName();
double x = location.getX(); double x = location.getX();
double y = location.getY(); double y = location.getY();