Add wander delays
This commit is contained in:
parent
04daf1c053
commit
0e747889e7
|
@ -561,9 +561,9 @@ public class EventListen implements Listener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleEnter(final VehicleEnterEvent event) {
|
||||
if (!CitizensAPI.getNPCRegistry().isNPC(event.getVehicle()))
|
||||
return;
|
||||
NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getVehicle());
|
||||
if (npc == null)
|
||||
return;
|
||||
if ((Util.isHorse(npc.getEntity()) || npc.getEntity().getType() == EntityType.BOAT
|
||||
|| npc.getEntity().getType() == EntityType.PIG || npc.getEntity() instanceof Minecart)
|
||||
&& (!npc.hasTrait(Controllable.class) || !npc.getTrait(Controllable.class).isEnabled())) {
|
||||
|
|
|
@ -38,6 +38,8 @@ import net.citizensnpcs.util.Util;
|
|||
*/
|
||||
public class WanderWaypointProvider implements WaypointProvider, Supplier<QuadTree>, Function<NPC, Location> {
|
||||
private WanderGoal currentGoal;
|
||||
@Persist
|
||||
public int delay = -1;
|
||||
private NPC npc;
|
||||
private volatile boolean paused;
|
||||
@Persist
|
||||
|
@ -152,6 +154,27 @@ public class WanderWaypointProvider implements WaypointProvider, Supplier<QuadTr
|
|||
} else {
|
||||
markers.destroyMarkers();
|
||||
}
|
||||
} else if (message.startsWith("delay")) {
|
||||
event.setCancelled(true);
|
||||
try {
|
||||
delay = Integer.parseInt(message.split(" ")[1]);
|
||||
if (currentGoal != null) {
|
||||
currentGoal.setDelay(delay);
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Messaging.sendTr(sender, Messages.WANDER_WAYPOINTS_DELAY_SET, delay);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Messaging.sendErrorTr(sender, Messages.WANDER_WAYPOINTS_INVALID_DELAY);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +244,7 @@ public class WanderWaypointProvider implements WaypointProvider, Supplier<QuadTr
|
|||
if (currentGoal == null) {
|
||||
currentGoal = WanderGoal.createWithNPCAndRangeAndTreeAndFallback(npc, xrange, yrange,
|
||||
WanderWaypointProvider.this, WanderWaypointProvider.this);
|
||||
currentGoal.setDelay(delay);
|
||||
}
|
||||
npc.getDefaultGoalController().addGoal(currentGoal, 1);
|
||||
}
|
||||
|
|
|
@ -313,7 +313,9 @@ public class Messages {
|
|||
public static final String VULNERABLE_STOPPED = "citizens.commands.npc.vulnerable.stopped";
|
||||
public static final String WANDER_WAYPOINTS_ADDED_REGION = "citizens.editors.waypoints.wander.added-region";
|
||||
public static final String WANDER_WAYPOINTS_BEGIN = "citizens.editors.waypoints.wander.begin";
|
||||
public static final String WANDER_WAYPOINTS_DELAY_SET = "citizens.editors.waypoints.wander.delay-set";
|
||||
public static final String WANDER_WAYPOINTS_END = "citizens.editors.waypoints.wander.end";
|
||||
public static final String WANDER_WAYPOINTS_INVALID_DELAY = "citizens.editors.waypoints.wander.invalid-delay";
|
||||
public static final String WANDER_WAYPOINTS_RANGE_SET = "citizens.editors.waypoints.wander.range-set";
|
||||
public static final String WANDER_WAYPOINTS_REGION_EDITING_START = "citizens.editors.waypoints.wander.editing-regions";
|
||||
public static final String WANDER_WAYPOINTS_REMOVED_REGION = "citizens.editors.waypoints.wander.removed-region";
|
||||
|
|
|
@ -117,7 +117,7 @@ public class Util {
|
|||
public static boolean isHorse(Entity entity) {
|
||||
String name = entity.getType().name();
|
||||
return entity.getType() == EntityType.HORSE || name.contains("_HORSE") || name.equals("DONKEY")
|
||||
|| name.equals("MULE") || name.equals("LLAMA");
|
||||
|| name.equals("MULE") || name.equals("LLAMA") || name.equals("TRADER_LLAMA");
|
||||
}
|
||||
|
||||
public static boolean isLoaded(Location location) {
|
||||
|
|
|
@ -260,8 +260,10 @@ citizens.editors.text.removed-entry=[[Removed]] entry at index [[{0}]].
|
|||
citizens.editors.text.start-prompt=Type [[add]] to add an entry, [[edit]] to edit entries, [[remove]] to remove entries, [[close]] to toggle the NPC as a close talker, [[item]] to set the item in hand pattern, [[range]] to set the talking range, [[delay]] to set the talking delay in ticks and [[random]] to toggle the NPC as a random talker. Type [[help]] to show this again.
|
||||
citizens.editors.text.talk-item-set=[[Talk item pattern]] set to [[{0}]].
|
||||
citizens.editors.waypoints.wander.range-set=Wander range set to xrange [[{0}]] and yrange [[{1}]].
|
||||
citizens.editors.waypoints.wander.begin=<b>Entered the wander waypoint editor.<br> Type [[xrange <number>]] or [[yrange <number>]] to modify the random wander range. Type [[regions]] to enter the region editor.
|
||||
citizens.editors.waypoints.wander.begin=<b>Entered the wander waypoint editor.<br> Type [[xrange <number>]] or [[yrange <number>]] to modify the random wander range. Type [[regions]] to enter the region editor.<br>Type [[delay <ticks>]] to delay the NPC between wanders.
|
||||
citizens.editors.waypoints.wander.end=Exited the wander waypoint editor.
|
||||
citizens.editors.waypoints.wander.delay-set=Delay between wanders set to [[{0}]] ticks.
|
||||
citizens.editors.waypoints.wander.invalid-delay=Invalid delay specified.
|
||||
citizens.editors.waypoints.wander.added-region=[[Added]] wanderable region at ({0}) ([[{1}]]).
|
||||
citizens.editors.waypoints.wander.removed-region=[[Removed]] wanderable region at ({0}) ([[{1}]] remaining).
|
||||
citizens.editors.waypoints.wander.editing-regions=Now editing regions!<br> [[Left click]] to add a new wanderable region using the xrange/yrange box centred at that block.<br> [[Right click]] an existing marker to remove that region.<br> Type [[regions]] to stop or simply exit the editor. Regions should be overlapping with each other.
|
||||
|
|
Loading…
Reference in New Issue