Prevent NPE in portal code.

Fixes WORLDGUARD-3516
This commit is contained in:
Wizjany 2015-06-27 00:42:08 -04:00
parent fc0be7db09
commit c9eaec0ae8

View File

@ -372,15 +372,15 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerPortal(PlayerPortalEvent event) {
if (event.getTo() == null) { // apparently this counts as a cancelled event, implementation specific though
return;
}
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getTo().getWorld());
if (!wcfg.regionNetherPortalProtection) return;
if (event.getCause() != TeleportCause.NETHER_PORTAL) {
return;
}
if (event.getTo() == null) { // apparently this counts as a cancelled event, implementation specific though
return;
}
if (!event.useTravelAgent()) { // either end travel (even though we checked cause) or another plugin is fucking with us, shouldn't create a portal though
return;
}