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>
<version>${vault.version}</version>
<type>jar</type>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>

View File

@ -232,21 +232,21 @@ public class LinearWaypointProvider implements WaypointProvider {
public void run() {
}
public void setPaused(boolean paused) {
if (paused && currentDestination != null)
public void setPaused(boolean pause) {
if (pause && currentDestination != null)
selector.finish();
this.paused = paused;
this.paused = pause;
}
@Override
public boolean shouldExecute(GoalSelector selector) {
if (paused || currentDestination != null || waypoints.size() == 0)
if (paused || currentDestination != null || !npc.isSpawned() || waypoints.size() == 0)
return false;
if (waypoints.size() == 1) {
// avoid repeatedly pathing to the same point and wasting
// memory.
Location dest = npc.getBukkitEntity().getLocation();
if (waypoints.get(0).getLocation().distanceSquared(dest) < 1)
if (waypoints.get(0).getLocation().distanceSquared(dest) < 3)
return false;
}
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;
import java.util.Iterator;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.editor.Editor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class WanderingWaypointProvider implements WaypointProvider, Iterable<Location> {
private final Iterator<Location> iterator = new RandomPointFinder();
public class WanderingWaypointProvider implements WaypointProvider {
private NPC npc;
private boolean paused;
@ -36,11 +32,6 @@ public class WanderingWaypointProvider implements WaypointProvider, Iterable<Loc
return paused;
}
@Override
public Iterator<Location> iterator() {
return iterator;
}
@Override
public void load(DataKey key) {
}