Minor change

This commit is contained in:
fullwall 2012-02-28 20:38:08 +08:00
parent 96ea7fe363
commit c741cf08d6
2 changed files with 13 additions and 12 deletions

View File

@ -102,13 +102,11 @@ public class EquipmentEditor extends Editor {
// Now edit the equipment based on the slot // Now edit the equipment based on the slot
if (trait.getEquipment(slot) != null && trait.getEquipment(slot).getType() != Material.AIR) if (trait.getEquipment(slot) != null && trait.getEquipment(slot).getType() != Material.AIR)
player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), trait.getEquipment(slot)); player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), trait.getEquipment(slot));
ItemStack set = hand; trait.setEquipment(slot, hand);
if (hand.getAmount() > 1) if (hand.getAmount() > 1)
hand.setAmount(hand.getAmount() - 1); hand.setAmount(hand.getAmount() - 1);
else else
hand = null; hand = null;
player.setItemInHand(hand); player.setItemInHand(hand);
set.setAmount(1);
trait.setEquipment(slot, set);
} }
} }

View File

@ -47,6 +47,10 @@ public class LinearWaypointProvider implements WaypointProvider {
Messaging.send(player, Messaging.send(player,
String.format("<e>Removed<a> a waypoint (<e>%d<a> remaining)", waypoints.size())); String.format("<e>Removed<a> a waypoint (<e>%d<a> remaining)", waypoints.size()));
} }
if (waypoints.size() == 0)
callback.currentIndex = -1;
else if (callback.currentIndex == -1)
callback.currentIndex = 0;
} }
}; };
} }
@ -71,10 +75,11 @@ public class LinearWaypointProvider implements WaypointProvider {
return callback; return callback;
} }
private final NavigationCallback callback = new NavigationCallback() { private final LinearNavigationCallback callback = new LinearNavigationCallback();
private class LinearNavigationCallback extends NavigationCallback {
private boolean executing; private boolean executing;
private int currentIndex; private int currentIndex;
private AI attached;
@Override @Override
public boolean onCancel(AI ai, PathCancelReason reason) { public boolean onCancel(AI ai, PathCancelReason reason) {
@ -93,13 +98,11 @@ public class LinearWaypointProvider implements WaypointProvider {
@Override @Override
public void onAttach(AI ai) { public void onAttach(AI ai) {
if (attached == null || attached != ai) { executing = false;
executing = false; currentIndex = -1;
currentIndex = -1; cycle();
cycle(); if (currentIndex != -1) {
if (currentIndex != -1) { ai.setDestination(waypoints.get(currentIndex).getLocation());
ai.setDestination(waypoints.get(currentIndex).getLocation());
}
} }
} }