mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-28 05:35:45 +01:00
Fix some issues with Navigator as reported by jrbudda
This commit is contained in:
parent
f62e536473
commit
338a853b79
@ -149,13 +149,18 @@ public class CitizensNavigator implements Navigator {
|
|||||||
StuckAction action = localParams.stuckAction();
|
StuckAction action = localParams.stuckAction();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
boolean shouldContinue = action.run(npc, this);
|
boolean shouldContinue = action.run(npc, this);
|
||||||
if (shouldContinue)
|
if (shouldContinue) {
|
||||||
|
stationaryTicks = 0;
|
||||||
|
executing.clearCancelReason();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stationaryTicks = 0;
|
|
||||||
}
|
}
|
||||||
Bukkit.getPluginManager().callEvent(new NavigationCancelEvent(this, reason));
|
NavigationCancelEvent event = new NavigationCancelEvent(this, reason);
|
||||||
stopNavigating();
|
PathStrategy old = executing;
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (old == executing)
|
||||||
|
stopNavigating();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchStrategyTo(PathStrategy newStrategy) {
|
private void switchStrategyTo(PathStrategy newStrategy) {
|
||||||
@ -175,8 +180,11 @@ public class CitizensNavigator implements Navigator {
|
|||||||
if (executing.getCancelReason() != null)
|
if (executing.getCancelReason() != null)
|
||||||
stopNavigating(executing.getCancelReason());
|
stopNavigating(executing.getCancelReason());
|
||||||
else {
|
else {
|
||||||
Bukkit.getPluginManager().callEvent(new NavigationCompleteEvent(this));
|
NavigationCompleteEvent event = new NavigationCompleteEvent(this);
|
||||||
stopNavigating();
|
PathStrategy old = executing;
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (old == executing)
|
||||||
|
stopNavigating();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,4 +59,9 @@ public class MCNavigationStrategy implements PathStrategy {
|
|||||||
navigation.a(parameters.speed());
|
navigation.a(parameters.speed());
|
||||||
return navigation.f();
|
return navigation.f();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearCancelReason() {
|
||||||
|
cancelReason = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,11 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int ATTACK_DELAY_TICKS = 20;
|
@Override
|
||||||
|
public void clearCancelReason() {
|
||||||
|
cancelReason = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int ATTACK_DELAY_TICKS = 20;
|
||||||
private static final double ATTACK_DISTANCE = 1.75 * 1.75;
|
private static final double ATTACK_DISTANCE = 1.75 * 1.75;
|
||||||
}
|
}
|
@ -15,4 +15,6 @@ public interface PathStrategy {
|
|||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
boolean update();
|
boolean update();
|
||||||
|
|
||||||
|
void clearCancelReason();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user