Fix for potential NPE in CraftBukkit caused by LWC location world returning null

This commit is contained in:
Brettflan 2012-02-19 08:23:13 -06:00
parent 4ba73af883
commit 03a45784c7

View File

@ -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<Block> chests = new LinkedList<Block>();
@ -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<Block> chests = new LinkedList<Block>();
@ -78,9 +85,4 @@ public class LWCFeatures
}
}
}
public static boolean getEnabled()
{
return Conf.lwcIntegration && lwc != null;
}
}