How to set a player's coordinates?!?!

Discussion in 'Plugin Development' started by Mr Burkes, Dec 31, 2011.

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

    Mr Burkes

    Hi, I'm working on a plugin that randomizes a player's coordinates. I have EVERYTHING down, except the coordinates part. Bummer! This is what I'm trying, and for simplicity's sake, we will set it to a defined number, not a random one:

    Code:
            Player player = event.getPlayer();
            String name = player.getName();
            Location loc = player.getLocation();
    
            loc.setX(1000.0d);
    Y U NO WORK! Anyways, can anyone help me out? Thanks! :3
     
  2. player.teleport()
     
  3. Offline

    Codex Arcanum

    player.teleport(loc)
     
  4. Because you're telling the player to go to "null" world :p use player.getWorld() to keep the player in the same world.

    Still, making random Y too could spawn the player inside a wall, you could use world.getHighestY() (or something) at that location or make the player godmode for 1-3 seconds, spawn him at Y 128 and set it's velocity Y to -10 to push him really fast towards the ground.

    EDIT: why did you delete the message ?
     
  5. Offline

    Gunpowder

    Ok here:
    Code:
    player.teleport(p.getWorld, x, y, z);
     
  6. Offline

    edocsyl

    Teleport doesn't work..

    p.teleport(p.getWorld(), intTeleX, intTeleY, intTeleZ);
     
  7. Offline

    user_43347

    Yes it does, or else no teleport commands or plugins would.
     
  8. Offline

    ItsHarry

    Location location = new Location(player.getWorld(), x, y, z);
    player.teleport(location);
     
  9. Offline

    edocsyl

    i have x,y,z in the config file.. so i need to make it so p.teleport(p.getWorld(), intTeleX, intTeleY, intTeleZ);
    but it doesnt work..
     
Thread Status:
Not open for further replies.

Share This Page