From e97a991c258cd4774afa144ca8ffa7a9801cd85f Mon Sep 17 00:00:00 2001 From: Brianna Date: Tue, 21 May 2019 19:38:38 -0400 Subject: [PATCH] Protection against deleted worlds. --- src/main/java/com/songoda/ultimatekits/UltimateKits.java | 1 + src/main/java/com/songoda/ultimatekits/utils/Methods.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/ultimatekits/UltimateKits.java b/src/main/java/com/songoda/ultimatekits/UltimateKits.java index ed975fe..43b8e27 100644 --- a/src/main/java/com/songoda/ultimatekits/UltimateKits.java +++ b/src/main/java/com/songoda/ultimatekits/UltimateKits.java @@ -271,6 +271,7 @@ public class UltimateKits extends JavaPlugin { */ for (KitBlockData kitBlockData : kitManager.getKitLocations().values()) { String locationStr = Methods.serializeLocation(kitBlockData.getLocation()); + if (locationStr == null) continue; dataFile.getConfig().set("BlockData." + locationStr + ".type", kitBlockData.getType().name()); dataFile.getConfig().set("BlockData." + locationStr + ".kit", kitBlockData.getKit().getName()); dataFile.getConfig().set("BlockData." + locationStr + ".holograms", kitBlockData.showHologram()); diff --git a/src/main/java/com/songoda/ultimatekits/utils/Methods.java b/src/main/java/com/songoda/ultimatekits/utils/Methods.java index fc71715..80c8aee 100644 --- a/src/main/java/com/songoda/ultimatekits/utils/Methods.java +++ b/src/main/java/com/songoda/ultimatekits/utils/Methods.java @@ -101,8 +101,8 @@ public class Methods { * @return The serialized data. */ public static String serializeLocation(Location location) { - if (location == null) - return ""; + if (location == null || location.getWorld() == null) + return null; String w = location.getWorld().getName(); double x = location.getX(); double y = location.getY();