mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-29 19:41:50 +01:00
Validate target NPC in /npc tp
This commit is contained in:
parent
676d2658dd
commit
350a63f0b8
@ -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());
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user