Validate target NPC in /npc tp

This commit is contained in:
fullwall 2013-07-03 18:05:18 +08:00
parent 676d2658dd
commit 350a63f0b8
3 changed files with 6 additions and 0 deletions

View File

@ -1026,6 +1026,10 @@ public class NPCCommands {
permission = "citizens.npc.tp")
public void tp(CommandContext args, Player player, NPC npc) {
Location to = npc.getTrait(CurrentLocation.class).getLocation();
if (to == null) {
Messaging.sendError(player, Messages.TELEPORT_NPC_LOCATION_NOT_FOUND);
return;
}
player.teleport(to, TeleportCause.COMMAND);
Messaging.sendTr(player, Messages.TELEPORTED_TO_NPC, npc.getName());
}

View File

@ -157,6 +157,7 @@ public class Messages {
public static final String SKIPPING_INVALID_POSE = "citizens.notifications.skipping-invalid-pose";
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 TELEPORT_NPC_LOCATION_NOT_FOUND = "citizens.commands.npc.tp.location-not-found";
public static final String TELEPORTED_TO_NPC = "citizens.commands.npc.tp.teleported";
public static final String TEMPLATE_APPLIED = "citizens.commands.template.applied";
public static final String TEMPLATE_CONFLICT = "citizens.commands.template.conflict";

View File

@ -78,6 +78,7 @@ 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.tp.teleported=You teleported to [[{0}]].
citizens.commands.npc.tp.location-not-found=Couldn't find the target NPC's location.
citizens.commands.npc.tpto.success=Teleported successfully.
citizens.commands.npc.tpto.to-not-found=Destination entity not found.
citizens.commands.npc.tpto.from-not-found=Source entity not found.