Ignore NPE onCreatureSpawn and attempt to get more information about it instead.

This commit is contained in:
Wizjany 2011-08-11 22:52:01 -04:00
parent 602b1d8a27
commit eacce487ed
2 changed files with 9 additions and 2 deletions

View File

@ -628,6 +628,8 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
if (wcfg.useRegions) { if (wcfg.useRegions) {
Vector pt = toVector(eventLoc); Vector pt = toVector(eventLoc);
RegionManager mgr = plugin.getGlobalRegionManager().get(eventLoc.getWorld()); RegionManager mgr = plugin.getGlobalRegionManager().get(eventLoc.getWorld());
// @TODO get victims' stacktraces and find out why it's null anyway
if (mgr == null) return;
ApplicableRegionSet set = mgr.getApplicableRegions(pt); ApplicableRegionSet set = mgr.getApplicableRegions(pt);
if (!set.allows(DefaultFlag.MOB_SPAWNING)) { if (!set.allows(DefaultFlag.MOB_SPAWNING)) {
@ -635,8 +637,8 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
return; return;
} }
Set<CreatureType> blockTypes = set.getFlag(DefaultFlag.DENY_SPAWN); Set<CreatureType> creatureTypes = set.getFlag(DefaultFlag.DENY_SPAWN);
if (blockTypes != null && blockTypes.contains(creaType)) { if (creatureTypes != null && creatureTypes.contains(creaType)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@ -150,9 +150,14 @@ public RegionManager load(World world) {
return manager; return manager;
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
logger.warning("WorldGuard: Region file for world \""
+ name + "\" missing or inaccessible.");
} catch (IOException e) { } catch (IOException e) {
logger.warning("WorldGuard: Failed to load regions from file " logger.warning("WorldGuard: Failed to load regions from file "
+ file.getAbsolutePath() + " : " + e.getMessage()); + file.getAbsolutePath() + " : " + e.getMessage());
} catch (Exception e) {
logger.warning("WorldGuard: Error loading regions for world \""
+ name + "\":" + e.getMessage());
} }
// @TODO: THIS CREATES PROBLEMS!! // @TODO: THIS CREATES PROBLEMS!!