From 7d31c12b25d159c51ddbd9f87a1cad8f069d63d7 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 31 Oct 2012 21:26:43 -0400 Subject: [PATCH] Add yaw and rotation to default TeleportCommand. Fixes BUKKIT-2774 By: EvilSeph --- .../command/defaults/TeleportCommand.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java index 2c2e11f0f0..77013afb19 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java @@ -55,20 +55,24 @@ public class TeleportCommand extends VanillaCommand { return true; } player.teleport(target, TeleportCause.COMMAND); - Command.broadcastCommandMessage(sender, "Teleported " + player.getName() + " to " + target.getName()); + Command.broadcastCommandMessage(sender, "Teleported " + player.getDisplayName() + " to " + target.getDisplayName()); } else if (player.getWorld() != null) { - double x = getCoordinate(sender, player.getLocation().getX(), args[args.length - 3]); - double y = getCoordinate(sender,player.getLocation().getY(), args[args.length - 2], 0, 0); - double z = getCoordinate(sender, player.getLocation().getZ(), args[args.length - 1]); + Location playerLocation = player.getLocation(); + double x = getCoordinate(sender, playerLocation.getX(), args[args.length - 3]); + double y = getCoordinate(sender, playerLocation.getY(), args[args.length - 2], 0, 0); + double z = getCoordinate(sender, playerLocation.getZ(), args[args.length - 1]); if (x == MIN_COORD_MINUS_ONE || y == MIN_COORD_MINUS_ONE || z == MIN_COORD_MINUS_ONE) { sender.sendMessage("Please provide a valid location!"); return true; } - Location location = new Location(player.getWorld(), x, y, z); - player.teleport(location); - Command.broadcastCommandMessage(sender, "Teleported " + player.getName() + " to " + + x + "," + y + "," + z); + playerLocation.setX(x); + playerLocation.setY(y); + playerLocation.setZ(z); + + player.teleport(playerLocation); + Command.broadcastCommandMessage(sender, String.format("Teleported %s to %.2f, %.2f, %.2f", player.getDisplayName(), x, y, z)); } return true; }