Set Position Player

Discussion in 'Plugin Development' started by alex1a, Feb 5, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    alex1a

    I want to create a /teleport comand to teleport the player to a location i define.
    please help me to find the method.
    is not the .setX or .setZ????

    Sorry about my bad english :s
    Cumps

    My code, but dont work:
    Code:
    else if(cmd.getName().equalsIgnoreCase("teleport")){
                Player player = (Player)sender;
                if(player.hasPermission("mcLEI.teleport")){
                    Location location = (Location) player.getLocation();
                    location.setX(-165);
                    location.setY(62);
                    location.setZ(212);
                    location.setYaw(2);
                    player.sendMessage(ChatColor.GOLD + "Todas as ferramentas foram adicionadas ao teu inventário");
                    return true;
                }
                player.sendMessage(ChatColor.GOLD + "Nao tens permissoes para tal");
                return true;
            }
            return false; 
     
  2. Offline

    CainFoool

    Wrong forum.
    Also why are you casting (Location) player.getLocation?
     
  3. Offline

    md_5

    @alex1
    Yeah, moved to plugin dev
     
  4. Offline

    MDCreator

    You need to use teleport.
    Code:java
    1.  
    2. else if(cmd.getName().equalsIgnoreCase("teleport")){
    3. Player player = (Player)sender;
    4. if(player.hasPermission("mcLEI.teleport")){
    5. Location location = player.getLocation();
    6.  
    7. pitch= player.getDirection().getPitch();
    8. yaw = player.getDirection.getYaw();
    9. player.teleport(location);
    10. player.setPitch(pitch); //Forgot the exact way to do this
    11. player.setYaw(yaw);
    12. player.sendMessage(ChatColor.GOLD + "Todas as ferramentas foram adicionadas ao teu inventário");
    13. return true;
    14. }
    15. player.sendMessage(ChatColor.GOLD + "Nao tens permissoes para tal");
    16. return true;
    17. }
    18. return false;
    19.  
    By the way, did you know this does absolutely nothing? :p
     
  5. Offline

    alex1a

    sorry about wrong forum. thanks all, i need to teleport player to X: -165 ; Y: 62; Z: 212 ; Yaw: 2
    thanks about .teleport() method.
    i use a cast because my eclipse recommend

    Cumps
     
Thread Status:
Not open for further replies.

Share This Page