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
if (trait.getEquipment(slot) != null && trait.getEquipment(slot).getType() != Material.AIR)
player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), trait.getEquipment(slot));
ItemStack set = hand;
trait.setEquipment(slot, hand);
if (hand.getAmount() > 1)
hand.setAmount(hand.getAmount() - 1);
else
hand = null;
player.setItemInHand(hand);
set.setAmount(1);
trait.setEquipment(slot, set);
}
}

View File

@ -47,6 +47,10 @@ public class LinearWaypointProvider implements WaypointProvider {
Messaging.send(player,
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;
}
private final NavigationCallback callback = new NavigationCallback() {
private final LinearNavigationCallback callback = new LinearNavigationCallback();
private class LinearNavigationCallback extends NavigationCallback {
private boolean executing;
private int currentIndex;
private AI attached;
@Override
public boolean onCancel(AI ai, PathCancelReason reason) {
@ -93,13 +98,11 @@ public class LinearWaypointProvider implements WaypointProvider {
@Override
public void onAttach(AI ai) {
if (attached == null || attached != ai) {
executing = false;
currentIndex = -1;
cycle();
if (currentIndex != -1) {
ai.setDestination(waypoints.get(currentIndex).getLocation());
}
executing = false;
currentIndex = -1;
cycle();
if (currentIndex != -1) {
ai.setDestination(waypoints.get(currentIndex).getLocation());
}
}