This commit is contained in:
fullwall 2012-08-18 15:13:33 +08:00
parent 17366cba20
commit 07edf17dae
4 changed files with 7 additions and 43 deletions

View File

@ -38,7 +38,7 @@
<artifactId>Vault</artifactId> <artifactId>Vault</artifactId>
<version>${vault.version}</version> <version>${vault.version}</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>

View File

@ -232,21 +232,21 @@ public class LinearWaypointProvider implements WaypointProvider {
public void run() { public void run() {
} }
public void setPaused(boolean paused) { public void setPaused(boolean pause) {
if (paused && currentDestination != null) if (pause && currentDestination != null)
selector.finish(); selector.finish();
this.paused = paused; this.paused = pause;
} }
@Override @Override
public boolean shouldExecute(GoalSelector selector) { public boolean shouldExecute(GoalSelector selector) {
if (paused || currentDestination != null || waypoints.size() == 0) if (paused || currentDestination != null || !npc.isSpawned() || waypoints.size() == 0)
return false; return false;
if (waypoints.size() == 1) { if (waypoints.size() == 1) {
// avoid repeatedly pathing to the same point and wasting // avoid repeatedly pathing to the same point and wasting
// memory. // memory.
Location dest = npc.getBukkitEntity().getLocation(); Location dest = npc.getBukkitEntity().getLocation();
if (waypoints.get(0).getLocation().distanceSquared(dest) < 1) if (waypoints.get(0).getLocation().distanceSquared(dest) < 3)
return false; return false;
} }
ensureItr(); ensureItr();

View File

@ -1,27 +0,0 @@
package net.citizensnpcs.trait.waypoint;
import java.util.Iterator;
import org.bukkit.Location;
public class RandomPointFinder implements Iterator<Location> {
public Location find() {
return null;
}
@Override
public boolean hasNext() {
return true;
}
@Override
public Location next() {
return find();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
}

View File

@ -1,16 +1,12 @@
package net.citizensnpcs.trait.waypoint; package net.citizensnpcs.trait.waypoint;
import java.util.Iterator;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.DataKey; import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.editor.Editor; import net.citizensnpcs.editor.Editor;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class WanderingWaypointProvider implements WaypointProvider, Iterable<Location> { public class WanderingWaypointProvider implements WaypointProvider {
private final Iterator<Location> iterator = new RandomPointFinder();
private NPC npc; private NPC npc;
private boolean paused; private boolean paused;
@ -36,11 +32,6 @@ public class WanderingWaypointProvider implements WaypointProvider, Iterable<Loc
return paused; return paused;
} }
@Override
public Iterator<Location> iterator() {
return iterator;
}
@Override @Override
public void load(DataKey key) { public void load(DataKey key) {
} }