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

This commit is contained in:
Brettflan 2012-02-19 08:23:09 -06:00
parent ff56162c12
commit 03d32ec5b0

View File

@ -30,9 +30,15 @@ public class LWCFeatures
P.p.log("Successfully hooked into LWC!"+(Conf.lwcIntegration ? "" : " Integration is currently disabled, though (\"lwcIntegration\").")); 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) public static void clearOtherChests(FLocation flocation, Faction faction)
{ {
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16); 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(); Chunk chunk = location.getChunk();
BlockState[] blocks = chunk.getTileEntities(); BlockState[] blocks = chunk.getTileEntities();
List<Block> chests = new LinkedList<Block>(); List<Block> chests = new LinkedList<Block>();
@ -58,6 +64,7 @@ public class LWCFeatures
public static void clearAllChests(FLocation flocation) public static void clearAllChests(FLocation flocation)
{ {
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16); 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(); Chunk chunk = location.getChunk();
BlockState[] blocks = chunk.getTileEntities(); BlockState[] blocks = chunk.getTileEntities();
List<Block> chests = new LinkedList<Block>(); List<Block> chests = new LinkedList<Block>();
@ -78,9 +85,4 @@ public class LWCFeatures
} }
} }
} }
public static boolean getEnabled()
{
return Conf.lwcIntegration && lwc != null;
}
} }