From 03a45784c7dfb2e7504e1c318b2d0a377e09e1b8 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Sun, 19 Feb 2012 08:23:13 -0600 Subject: [PATCH] Fix for potential NPE in CraftBukkit caused by LWC location world returning null --- .../factions/integration/LWCFeatures.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/massivecraft/factions/integration/LWCFeatures.java b/src/com/massivecraft/factions/integration/LWCFeatures.java index 9cacb807..2f62b7bc 100644 --- a/src/com/massivecraft/factions/integration/LWCFeatures.java +++ b/src/com/massivecraft/factions/integration/LWCFeatures.java @@ -30,9 +30,15 @@ public class LWCFeatures P.p.log("Successfully hooked into LWC!"+(Conf.lwcIntegration ? "" : " Integration is currently disabled, though (\"lwcIntegration\").")); } + public static boolean getEnabled() + { + return Conf.lwcIntegration && lwc != null; + } + public static void clearOtherChests(FLocation flocation, Faction faction) { Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16); + if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error Chunk chunk = location.getChunk(); BlockState[] blocks = chunk.getTileEntities(); List chests = new LinkedList(); @@ -58,6 +64,7 @@ public class LWCFeatures public static void clearAllChests(FLocation flocation) { Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16); + if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error Chunk chunk = location.getChunk(); BlockState[] blocks = chunk.getTileEntities(); List chests = new LinkedList(); @@ -78,9 +85,4 @@ public class LWCFeatures } } } - - public static boolean getEnabled() - { - return Conf.lwcIntegration && lwc != null; - } }