summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-12-15 14:12:34 +0100
committersnowleo <schneeleo@gmail.com>2012-12-15 14:12:34 +0100
commite706614a3b82a7314f60c7cb23142e812fe7b1fb (patch)
tree92f126402051f44a68e551d74e87d3c19a21c21e
parent5741cea3f582513e17e614fb796662c3a1196549 (diff)
downloadEssentials-e706614a3b82a7314f60c7cb23142e812fe7b1fb.tar
Essentials-e706614a3b82a7314f60c7cb23142e812fe7b1fb.tar.gz
Essentials-e706614a3b82a7314f60c7cb23142e812fe7b1fb.tar.lz
Essentials-e706614a3b82a7314f60c7cb23142e812fe7b1fb.tar.xz
Essentials-e706614a3b82a7314f60c7cb23142e812fe7b1fb.zip
Align /tp syntax with Minecraft /tp command
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtp.java46
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtppos.java18
2 files changed, 51 insertions, 13 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
index 7c6cbe82d..9f42283f1 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
@@ -4,6 +4,7 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
+import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -40,7 +41,28 @@ public class Commandtp extends EssentialsCommand
charge.isAffordableFor(user);
user.getTeleport().teleport(player, charge, TeleportCause.COMMAND);
throw new NoChargeException();
-
+ case 4:
+ if (!user.isAuthorized("essentials.tp.others"))
+ {
+ throw new Exception(_("noPerm", "essentials.tp.others"));
+ }
+ user.sendMessage(_("teleporting"));
+ final User target2 = getPlayer(server, args, 0);
+ 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 z = args[3].startsWith("~") ? target2.getLocation().getZ() + Integer.parseInt(args[3].substring(1)) : Integer.parseInt(args[3]);
+ if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
+ {
+ throw new NotEnoughArgumentsException("Value of coordinates cannot be over 30000000"); //todo: I18n
+ }
+ final Location location = new Location(target2.getWorld(), x, y, z);
+ if (!target2.isTeleportEnabled())
+ {
+ throw new Exception(_("teleportDisabled", target2.getDisplayName()));
+ }
+ target2.getTeleport().now(location, false, TeleportCause.COMMAND);
+ target2.sendMessage(_("teleporting"));
+ case 2:
default:
if (!user.isAuthorized("essentials.tp.others"))
{
@@ -78,8 +100,24 @@ public class Commandtp extends EssentialsCommand
sender.sendMessage(_("teleporting"));
final User target = getPlayer(server, args, 0);
- final User toPlayer = getPlayer(server, args, 1);
- target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
- target.sendMessage(_("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
+ if (args.length == 2)
+ {
+ final User toPlayer = getPlayer(server, args, 1);
+ target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
+ target.sendMessage(_("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
+ }
+ else if (args.length > 3)
+ {
+ final double x = args[1].startsWith("~") ? target.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
+ final double y = args[2].startsWith("~") ? target.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
+ final double z = args[3].startsWith("~") ? target.getLocation().getZ() + Integer.parseInt(args[3].substring(1)) : Integer.parseInt(args[3]);
+ if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
+ {
+ throw new NotEnoughArgumentsException("Value of coordinates cannot be over 30000000"); //todo: I18n
+ }
+ final Location location = new Location(target.getWorld(), x, y, z);
+ target.getTeleport().now(location, false, TeleportCause.COMMAND);
+ target.sendMessage(_("teleporting"));
+ }
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
index ddc86f19c..c9253c99b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
@@ -24,9 +24,9 @@ public class Commandtppos extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- final int x = Integer.parseInt(args[0]);
- final int y = Integer.parseInt(args[1]);
- final int z = Integer.parseInt(args[2]);
+ final double x = args[0].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[0].substring(1)) : Integer.parseInt(args[0]);
+ final double y = args[1].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
+ final double z = args[2].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
final Location location = new Location(user.getWorld(), x, y, z);
if (args.length > 3)
{
@@ -36,7 +36,7 @@ public class Commandtppos extends EssentialsCommand
{
location.setPitch(Float.parseFloat(args[4]));
}
- if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
+ if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
{
throw new NotEnoughArgumentsException("Value of coordinates cannot be over 30000000"); //todo: I18n
}
@@ -56,9 +56,9 @@ public class Commandtppos extends EssentialsCommand
}
User user = ess.getUser(server.getPlayer(args[0]));
- final int x = Integer.parseInt(args[1]);
- final int y = Integer.parseInt(args[2]);
- final int z = Integer.parseInt(args[3]);
+ final double x = args[1].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
+ final double y = args[2].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
+ final double z = args[3].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[3].substring(1)) : Integer.parseInt(args[3]);
final Location location = new Location(user.getWorld(), x, y, z);
if (args.length > 4)
{
@@ -68,13 +68,13 @@ public class Commandtppos extends EssentialsCommand
{
location.setPitch(Float.parseFloat(args[5]));
}
- if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
+ if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
{
throw new NotEnoughArgumentsException("Value of coordinates cannot be over 30000000"); //todo: I18n
}
sender.sendMessage(_("teleporting"));
user.sendMessage(_("teleporting"));
user.getTeleport().teleport(location, null, TeleportCause.COMMAND);
-
+
}
} \ No newline at end of file