@Command( command = "tp", aliases = {"teleport"}, arguments = {"target player[s]", "destination player"}, description = "teleports <target player[s]> to <destination player>", permissions = {"other"}) public static boolean teleport( CommandSender sender, String targetPlayer, String destinationPlayer) throws EssentialsCommandException { // try to find the destination player Player destination = Bukkit.getServer().getPlayer(destinationPlayer); if (destination == null) { throw new EssentialsCommandException( "&cI couldn't find player '%s' to teleport to!", destination); } // get a list of all target players ArrayList<Player> targetPlayers = PlayerSelector.selectPlayersExact(targetPlayer); // make sure we have at least one target player if (targetPlayers.size() == 0) { throw new EssentialsCommandException( "I couldn't find target player[s] '%s' to teleport!", targetPlayer); } // loop through all target players for (Iterator<Player> it = targetPlayers.iterator(); it.hasNext(); ) { // get the player Player target = it.next(); // do it! target.teleport(destination); // alert everyone ColourHandler.sendMessage( target, "&6You have been teleported to " + destination.getName() + " by " + sender.getName()); if (!destination.getName().equals(sender.getName())) { ColourHandler.sendMessage( destination, "&6" + target.getName() + " has been teleported to you by " + sender.getName()); } ColourHandler.sendMessage( sender, "&6" + target.getName() + " has been teleported to " + destination.getName()); } return true; }
@Command( command = "origin", aliases = {"tporigin"}, description = "sends you back to where you were before you started teleporting", permissions = {"history.origin"}, playerOnly = true) public static boolean origin(CommandSender sender) throws EssentialsCommandException { // get our player Player player = (Player) sender; // make sure we have somewhere else to go if (!player.hasMetadata("tpHistory")) { throw new EssentialsCommandException("You don't have anywhere to go!"); } // get their last location Location lastLocation = getFirstLocationAndClear(player); // disable teleport logging ignoreTeleport(player, true); // and send them there player.teleport(lastLocation); ColourHandler.sendMessage(player, "&6!hsooW"); return true; }
@Command( command = "tpclear", aliases = {"rewind"}, description = "clears your teleport history", permissions = {"history.clear"}, playerOnly = true) public static boolean clearHistory(CommandSender sender) throws EssentialsCommandException { clearHistory((Player) sender); ColourHandler.sendMessage(sender, "&6Your teleport history has been wiped!"); return true; }
@Command( command = "tptoggle", aliases = "notp", description = "prevents other players from teleporting you / to you", permissions = {"teleport.toggle"}, playerOnly = true) public static boolean tpToggle(CommandSender sender) throws EssentialsCommandException { // determine whether they have teleporting disabled or not boolean disabled = tpDisabled((Player) sender); // change their status disableTP((Player) sender, !disabled); // alert them if (!disabled) { ColourHandler.sendMessage(sender, "&3Teleports have been turned off"); } else { ColourHandler.sendMessage(sender, "&3Teleports have been turned on"); } return true; }
@Command( command = "tp", aliases = {"teleport"}, arguments = {"target player[s]", "world name", "x", "y", "z"}, tabCompletions = { TabCompleteType.PLAYER, TabCompleteType.WORLD, TabCompleteType.NUMBER, TabCompleteType.NUMBER, TabCompleteType.NUMBER }, description = "teleports <player[s]> to the given coordinates in the given world", permissions = {"othercoords"}) public static boolean teleport( CommandSender sender, String targetPlayer, String worldName, float x, float y, float z) throws EssentialsCommandException { // make sure the world exists World targetWorld = Bukkit.getServer().getWorld(worldName); if (targetWorld == null) { throw new EssentialsCommandException("I couldn't find world '%s' to teleport to!", worldName); } // get a list of all target players ArrayList<Player> targetPlayers = PlayerSelector.selectPlayers(targetPlayer); // make sure we have at least one target player if (targetPlayers.size() == 0) { throw new EssentialsCommandException( "I couldn't find target player[s] '%s' to teleport!", targetPlayer); } // loop through all target players for (Iterator<Player> it = targetPlayers.iterator(); it.hasNext(); ) { // get the player Player target = it.next(); // make sure that player doesn't have teleporting disabled if (tpDisabled(target) && !PermissionsManager.playerHasPermission(sender, "teleport.toggle.override")) { ColourHandler.sendMessage( sender, "%s &cdoesn't have teleporting enabled!", target.getName()); continue; } // build their destination Location destination = new Location( targetWorld, x, y, z, target.getLocation().getYaw(), target.getLocation().getPitch()); // do it! target.teleport(destination); // alert everyone ColourHandler.sendMessage( target, "&6You have been teleported to (" + destination.getBlockX() + ", " + destination.getBlockY() + ", " + destination.getBlockZ() + ") in world: " + destination.getWorld().getName() + " by " + sender.getName()); if (!target.getName().equals(sender.getName())) { ColourHandler.sendMessage( sender, "&6" + target.getName() + " has been teleported to (" + destination.getBlockX() + ", " + destination.getBlockY() + ", " + destination.getBlockZ() + ") in world: " + destination.getWorld().getName()); } } return true; }
@Command( command = "tp", aliases = {"teleport"}, arguments = {"target player[s]", "world name", "x", "y", "z"}, description = "teleports <player[s]> to the given coordinates in the given world", permissions = {"othercoords"}, playerOnly = true) public static boolean teleport( CommandSender sender, String targetPlayer, String worldName, float x, float y, float z) throws EssentialsCommandException { // make sure the world exists World targetWorld = Bukkit.getServer().getWorld(worldName); if (targetWorld == null) { throw new EssentialsCommandException("I couldn't find world '%s' to teleport to!", worldName); } // get a list of all target players ArrayList<Player> targetPlayers = PlayerSelector.selectPlayersExact(targetPlayer); // make sure we have at least one target player if (targetPlayers.size() == 0) { throw new EssentialsCommandException( "I couldn't find target player[s] '%s' to teleport!", targetPlayer); } // loop through all target players for (Iterator<Player> it = targetPlayers.iterator(); it.hasNext(); ) { // get the player Player target = it.next(); // build their destination Location destination = new Location( targetWorld, x, y, z, target.getLocation().getYaw(), target.getLocation().getPitch()); // do it! target.teleport(destination); // alert everyone ColourHandler.sendMessage( target, "&6You have been teleported to (" + destination.getBlockX() + ", " + destination.getBlockY() + ", " + destination.getBlockZ() + ") in world: " + destination.getWorld().getName() + " by " + sender.getName()); ColourHandler.sendMessage( target, "&6" + target.getName() + " has been teleported to (" + destination.getBlockX() + ", " + destination.getBlockY() + ", " + destination.getBlockZ() + ") in world: " + destination.getWorld().getName()); } return true; }