Skip to content

Commit 97c8f51

Browse files
committed
New permission :essentials.tp.position Required to use /tp [player] <x> <y> <z>
1 parent 7c372cd commit 97c8f51

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,30 @@ public void run(final Server server, final User user, final String commandLabel,
4141
user.getTeleport().teleport(player.getBase(), charge, TeleportCause.COMMAND);
4242
throw new NoChargeException();
4343
case 3:
44+
if (!user.isAuthorized("essentials.tp.position"))
45+
{
46+
throw new Exception(tl("noPerm", "essentials.tp.position"));
47+
}
4448
final double x2 = args[0].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[0].substring(1)) : Integer.parseInt(args[0]);
4549
final double y2 = args[1].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
4650
final double z2 = args[2].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
4751
if (x2 > 30000000 || y2 > 30000000 || z2 > 30000000 || x2 < -30000000 || y2 < -30000000 || z2 < -30000000)
4852
{
4953
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
5054
}
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()));
55+
final Location locpos = new Location(user.getWorld(), x2, y2, z2, user.getLocation().getYaw(), user.getLocation().getPitch());
56+
user.getTeleport().now(locpos, false, TeleportCause.COMMAND);
57+
user.sendMessage(tl("teleporting", locpos.getWorld().getName(), locpos.getBlockX(), locpos.getBlockY(), locpos.getBlockZ()));
5858
break;
5959
case 4:
6060
if (!user.isAuthorized("essentials.tp.others"))
6161
{
6262
throw new Exception(tl("noPerm", "essentials.tp.others"));
6363
}
64+
if (!user.isAuthorized("essentials.tp.position"))
65+
{
66+
throw new Exception(tl("noPerm", "essentials.tp.position"));
67+
}
6468
final User target2 = getPlayer(server, user, args, 0);
6569
final double x = args[1].startsWith("~") ? target2.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
6670
final double y = args[2].startsWith("~") ? target2.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
@@ -69,14 +73,14 @@ public void run(final Server server, final User user, final String commandLabel,
6973
{
7074
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
7175
}
72-
final Location loc = new Location(target2.getWorld(), x, y, z, target2.getLocation().getYaw(), target2.getLocation().getPitch());
76+
final Location locposother = new Location(target2.getWorld(), x, y, z, target2.getLocation().getYaw(), target2.getLocation().getPitch());
7377
if (!target2.isTeleportEnabled())
7478
{
7579
throw new Exception(tl("teleportDisabled", target2.getDisplayName()));
7680
}
77-
user.sendMessage(tl("teleporting", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
78-
target2.getTeleport().now(loc, false, TeleportCause.COMMAND);
79-
target2.sendMessage(tl("teleporting", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
81+
user.sendMessage(tl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ()));
82+
target2.getTeleport().now(locposother, false, TeleportCause.COMMAND);
83+
target2.sendMessage(tl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ()));
8084
break;
8185
case 2:
8286
default:

0 commit comments

Comments
 (0)