mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
New permission :essentials.tp.position Required to use /tp [player] <x> <y> <z>
This commit is contained in:
parent
7c372cd978
commit
97c8f5192e
1 changed files with 15 additions and 11 deletions
|
@ -41,6 +41,10 @@ public class Commandtp extends EssentialsCommand
|
||||||
user.getTeleport().teleport(player.getBase(), charge, TeleportCause.COMMAND);
|
user.getTeleport().teleport(player.getBase(), charge, TeleportCause.COMMAND);
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
case 3:
|
case 3:
|
||||||
|
if (!user.isAuthorized("essentials.tp.position"))
|
||||||
|
{
|
||||||
|
throw new Exception(tl("noPerm", "essentials.tp.position"));
|
||||||
|
}
|
||||||
final double x2 = args[0].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[0].substring(1)) : Integer.parseInt(args[0]);
|
final double x2 = args[0].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[0].substring(1)) : Integer.parseInt(args[0]);
|
||||||
final double y2 = args[1].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
|
final double y2 = args[1].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
|
||||||
final double z2 = args[2].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
|
final double z2 = args[2].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
|
||||||
|
@ -48,19 +52,19 @@ public class Commandtp extends EssentialsCommand
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
|
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
|
||||||
}
|
}
|
||||||
final Location loc2 = new Location(user.getWorld(), x2, y2, z2, user.getLocation().getYaw(), user.getLocation().getPitch());
|
final Location locpos = new Location(user.getWorld(), x2, y2, z2, user.getLocation().getYaw(), user.getLocation().getPitch());
|
||||||
if (!user.isTeleportEnabled())
|
user.getTeleport().now(locpos, false, TeleportCause.COMMAND);
|
||||||
{
|
user.sendMessage(tl("teleporting", locpos.getWorld().getName(), locpos.getBlockX(), locpos.getBlockY(), locpos.getBlockZ()));
|
||||||
throw new Exception(tl("teleportDisabled", user.getDisplayName()));
|
|
||||||
}
|
|
||||||
user.getTeleport().now(loc2, false, TeleportCause.COMMAND);
|
|
||||||
user.sendMessage(tl("teleporting", loc2.getWorld().getName(), loc2.getBlockX(), loc2.getBlockY(), loc2.getBlockZ()));
|
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (!user.isAuthorized("essentials.tp.others"))
|
if (!user.isAuthorized("essentials.tp.others"))
|
||||||
{
|
{
|
||||||
throw new Exception(tl("noPerm", "essentials.tp.others"));
|
throw new Exception(tl("noPerm", "essentials.tp.others"));
|
||||||
}
|
}
|
||||||
|
if (!user.isAuthorized("essentials.tp.position"))
|
||||||
|
{
|
||||||
|
throw new Exception(tl("noPerm", "essentials.tp.position"));
|
||||||
|
}
|
||||||
final User target2 = getPlayer(server, user, args, 0);
|
final User target2 = getPlayer(server, user, args, 0);
|
||||||
final double x = args[1].startsWith("~") ? target2.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
|
final double x = args[1].startsWith("~") ? target2.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
|
||||||
final double y = args[2].startsWith("~") ? target2.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
|
final double y = args[2].startsWith("~") ? target2.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
|
||||||
|
@ -69,14 +73,14 @@ public class Commandtp extends EssentialsCommand
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
|
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
|
||||||
}
|
}
|
||||||
final Location loc = new Location(target2.getWorld(), x, y, z, target2.getLocation().getYaw(), target2.getLocation().getPitch());
|
final Location locposother = new Location(target2.getWorld(), x, y, z, target2.getLocation().getYaw(), target2.getLocation().getPitch());
|
||||||
if (!target2.isTeleportEnabled())
|
if (!target2.isTeleportEnabled())
|
||||||
{
|
{
|
||||||
throw new Exception(tl("teleportDisabled", target2.getDisplayName()));
|
throw new Exception(tl("teleportDisabled", target2.getDisplayName()));
|
||||||
}
|
}
|
||||||
user.sendMessage(tl("teleporting", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
user.sendMessage(tl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ()));
|
||||||
target2.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
target2.getTeleport().now(locposother, false, TeleportCause.COMMAND);
|
||||||
target2.sendMessage(tl("teleporting", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
target2.sendMessage(tl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ()));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue