Make /npc pickupitems persistent

This commit is contained in:
fullwall 2022-11-11 22:41:34 +08:00
parent 35245a580b
commit ce1f306b08
2 changed files with 6 additions and 3 deletions

View File

@ -1768,7 +1768,7 @@ public class NPCCommands {
public void pickupitems(CommandContext args, CommandSender sender, NPC npc, @Flag("set") Boolean set)
throws CommandException {
boolean pickup = set == null ? !npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected()) : set;
npc.data().set(NPC.Metadata.PICKUP_ITEMS, pickup);
npc.data().setPersistent(NPC.Metadata.PICKUP_ITEMS, pickup);
Messaging.sendTr(sender, pickup ? Messages.PICKUP_ITEMS_SET : Messages.PICKUP_ITEMS_UNSET, npc.getName());
}

View File

@ -302,9 +302,11 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
selector.finish();
return;
}
if (npc.getNavigator().isNavigating()) {
return;
}
Waypoint current = plan.getCurrentWaypoint();
npc.getNavigator().setTarget(current.getLocation());
npc.getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() {
@ -322,6 +324,7 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
if (paused || available.size() == 0 || !npc.isSpawned() || npc.getNavigator().isNavigating()) {
return false;
}
Waypoint target = available.get(Util.getFastRandom().nextInt(available.size()));
plan = ASTAR.runFully(new GuidedGoal(target), new GuidedNode(null, new Waypoint(npc.getStoredLocation())));
return plan != null;
@ -403,8 +406,8 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
List<AStarNode> resList = Lists.newArrayList();
res.forEachRemaining(new Consumer<Waypoint>() {
@Override
public void accept(Waypoint t) {
resList.add(new GuidedNode(null, t));
public void accept(Waypoint n) {
resList.add(new GuidedNode(null, n));
}
});
return resList;