Setting players death spawn (World spawn)

Discussion in 'Plugin Development' started by Xyplo, Apr 14, 2014.

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

    Xyplo

    So I need help on setting the worlds death spawn which is also known as the world spawn. It's the spawn you're teleported to when you die. I spawn randomly which I do not want. So how would I set the world spawn in coding? On the first join, the player spawns in the correct place, but once they die they do not. Help?

    BTW: I am NOT using Essentials as my server only has plugins coded by me; with an exception of a few plugins. So PLEASE do not reply with essentials related replies as they will not help.

    -Thanks, Xyplo.
     
  2. Offline

    multikus

    This is a pretty simple way of doing it:

    Code:java
    1. //Event will be called when player hits the "Respawn" button
    2. @EventHandler
    3. public void onrespawn(PlayerRespawnEvent event){
    4. //Get's the current world
    5. World world = Bukkit.getWorld("world");
    6. //Set in the Coordinates for X - Y - Z
    7. Location newspawn = new Location(world, x, y, z);
    8.  
    9. //Teleport the player to the set location
    10. event.setRespawnLocation(lobbyspawn);
    11. }
     
  3. Offline

    Xyplo

    Changed it from
    Code:java
    1. event.setRespawnLocation(lobbyspawn);
    to
    Code:java
    1. e.setRespawnLocation(newspawn);
    and it worked fine! Thanks XD
     
Thread Status:
Not open for further replies.

Share This Page