Add /npc swim command

This commit is contained in:
fullwall 2013-11-15 12:06:18 +08:00
parent 04cae6b692
commit 5765d80125
4 changed files with 22 additions and 1 deletions

View File

@ -1187,6 +1187,21 @@ public class NPCCommands {
Messaging.sendTr(sender, Messages.SPEED_MODIFIER_SET, newSpeed);
}
@Command(
aliases = { "npc" },
usage = "swim (--set [true|false])",
desc = "Sets an NPC to swim or not",
modifiers = { "swim" },
min = 1,
max = 1,
permission = "citizens.npc.swim")
public void swim(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
boolean swim = args.hasValueFlag("set") ? Boolean.parseBoolean(args.getFlag("swim")) : !npc.data().get(
NPC.SWIMMING_METADATA, true);
npc.data().setPersistent(NPC.SWIMMING_METADATA, swim);
Messaging.sendTr(sender, swim ? Messages.SWIMMING_SET : Messages.SWIMMING_UNSET, npc.getName());
}
@Command(
aliases = { "npc" },
usage = "targetable",

View File

@ -259,7 +259,9 @@ public class CitizensNPC extends AbstractNPC {
try {
super.update();
if (isSpawned()) {
NMS.trySwim(getEntity());
if (data().get(NPC.SWIMMING_METADATA, true)) {
NMS.trySwim(getEntity());
}
navigator.run();
if (++packetUpdateCount > 30) {
if (!getNavigator().isNavigating()) {

View File

@ -184,6 +184,8 @@ public class Messages {
public static final String SPAWN_NUMERIC_ID_ONLY = "citizens.commands.npc.spawn.numeric-id-only";
public static final String SPEED_MODIFIER_ABOVE_LIMIT = "citizens.commands.npc.speed.modifier-above-limit";
public static final String SPEED_MODIFIER_SET = "citizens.commands.npc.speed.set";
public static final String SWIMMING_SET = "citizens.commands.npc.swim.set";
public static final String SWIMMING_UNSET = "citizens.commands.npc.swim.unset";
public static final String TARGETABLE_SET = "citizens.commands.npc.targetable.set";
public static final String TARGETABLE_UNSET = "citizens.commands.npc.targetable.unset";
public static final String TELEPORT_NPC_LOCATION_NOT_FOUND = "citizens.commands.npc.tp.location-not-found";

View File

@ -96,6 +96,8 @@ citizens.commands.npc.spawn.numeric-id-only=Only numeric IDs can be used for /np
citizens.commands.npc.spawn.spawned=You spawned [[{0}]].
citizens.commands.npc.speed.modifier-above-limit=Speed is above the limit.
citizens.commands.npc.speed.set=NPC speed modifier set to [[{0}]].
citizens.commands.npc.swim.set=[[{0}]] will now swim in water.
citizens.commands.npc.swim.unset=[[{0}]] will no longer swim in water.
citizens.commands.npc.targetable.set=[[{0}]] can now be targeted by mobs.
citizens.commands.npc.targetable.unset=[[{0}]] can no longer be targeted by mobs.
citizens.commands.npc.tp.teleported=You teleported to [[{0}]].