From 59dee87f38990f6162f4ed879a7ee5a206fc6c73 Mon Sep 17 00:00:00 2001 From: fullwall Date: Tue, 28 Feb 2012 20:38:08 +0800 Subject: [PATCH] Minor change --- .../citizensnpcs/editor/EquipmentEditor.java | 4 +--- .../waypoint/LinearWaypointProvider.java | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java index d934f0fc1..98b90a5c2 100644 --- a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java +++ b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java @@ -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); } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java b/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java index 5fdae49ea..6a076a34c 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java @@ -47,6 +47,10 @@ public class LinearWaypointProvider implements WaypointProvider { Messaging.send(player, String.format("Removed a waypoint (%d 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()); } }