mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-18 13:21:45 +01:00
Make /npc pickupitems persistent
This commit is contained in:
parent
35245a580b
commit
ce1f306b08
@ -1768,7 +1768,7 @@ public class NPCCommands {
|
|||||||
public void pickupitems(CommandContext args, CommandSender sender, NPC npc, @Flag("set") Boolean set)
|
public void pickupitems(CommandContext args, CommandSender sender, NPC npc, @Flag("set") Boolean set)
|
||||||
throws CommandException {
|
throws CommandException {
|
||||||
boolean pickup = set == null ? !npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected()) : set;
|
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());
|
Messaging.sendTr(sender, pickup ? Messages.PICKUP_ITEMS_SET : Messages.PICKUP_ITEMS_UNSET, npc.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,9 +302,11 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
|
|||||||
selector.finish();
|
selector.finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (npc.getNavigator().isNavigating()) {
|
if (npc.getNavigator().isNavigating()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Waypoint current = plan.getCurrentWaypoint();
|
Waypoint current = plan.getCurrentWaypoint();
|
||||||
npc.getNavigator().setTarget(current.getLocation());
|
npc.getNavigator().setTarget(current.getLocation());
|
||||||
npc.getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() {
|
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()) {
|
if (paused || available.size() == 0 || !npc.isSpawned() || npc.getNavigator().isNavigating()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Waypoint target = available.get(Util.getFastRandom().nextInt(available.size()));
|
Waypoint target = available.get(Util.getFastRandom().nextInt(available.size()));
|
||||||
plan = ASTAR.runFully(new GuidedGoal(target), new GuidedNode(null, new Waypoint(npc.getStoredLocation())));
|
plan = ASTAR.runFully(new GuidedGoal(target), new GuidedNode(null, new Waypoint(npc.getStoredLocation())));
|
||||||
return plan != null;
|
return plan != null;
|
||||||
@ -403,8 +406,8 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
|
|||||||
List<AStarNode> resList = Lists.newArrayList();
|
List<AStarNode> resList = Lists.newArrayList();
|
||||||
res.forEachRemaining(new Consumer<Waypoint>() {
|
res.forEachRemaining(new Consumer<Waypoint>() {
|
||||||
@Override
|
@Override
|
||||||
public void accept(Waypoint t) {
|
public void accept(Waypoint n) {
|
||||||
resList.add(new GuidedNode(null, t));
|
resList.add(new GuidedNode(null, n));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return resList;
|
return resList;
|
||||||
|
Loading…
Reference in New Issue
Block a user