Fix NavigationStuckEvent set-null

If you set the action in a NavigationStuckEvent, it throws an NPE rather
than simply doing nothing. This patches that.
It also throws the event even when the default stuck action is null.
This commit is contained in:
mcmonkey4eva 2014-10-04 14:06:15 -07:00
parent 9eeae0c5b3
commit b5580ec70c

View File

@ -225,12 +225,12 @@ public class CitizensNavigator implements Navigator, Runnable {
stopNavigating();
return;
}
if (reason == CancelReason.STUCK && localParams.stuckAction() != null) {
if (reason == CancelReason.STUCK) {
StuckAction action = localParams.stuckAction();
NavigationStuckEvent event = new NavigationStuckEvent(this, action);
Bukkit.getPluginManager().callEvent(event);
action = event.getAction();
boolean shouldContinue = action.run(npc, this);
boolean shouldContinue = action != null ? action.run(npc, this): false;
if (shouldContinue) {
stationaryTicks = 0;
executing.clearCancelReason();