Skip to content

Commit 7c372cd

Browse files
necrodoomkhobbits
authored andcommitted
Add support for vanilla /tp <x> <y> <z> teleport syntax.
1 parent 02fe581 commit 7c372cd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Essentials/src/com/earth2me/essentials/commands/Commandtp.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ public void run(final Server server, final User user, final String commandLabel,
4040
charge.isAffordableFor(user);
4141
user.getTeleport().teleport(player.getBase(), charge, TeleportCause.COMMAND);
4242
throw new NoChargeException();
43+
case 3:
44+
final double x2 = args[0].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[0].substring(1)) : Integer.parseInt(args[0]);
45+
final double y2 = args[1].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
46+
final double z2 = args[2].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
47+
if (x2 > 30000000 || y2 > 30000000 || z2 > 30000000 || x2 < -30000000 || y2 < -30000000 || z2 < -30000000)
48+
{
49+
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
50+
}
51+
final Location loc2 = new Location(user.getWorld(), x2, y2, z2, user.getLocation().getYaw(), user.getLocation().getPitch());
52+
if (!user.isTeleportEnabled())
53+
{
54+
throw new Exception(tl("teleportDisabled", user.getDisplayName()));
55+
}
56+
user.getTeleport().now(loc2, false, TeleportCause.COMMAND);
57+
user.sendMessage(tl("teleporting", loc2.getWorld().getName(), loc2.getBlockX(), loc2.getBlockY(), loc2.getBlockZ()));
58+
break;
4359
case 4:
4460
if (!user.isAuthorized("essentials.tp.others"))
4561
{

0 commit comments

Comments
 (0)