Spawn at world spawn on server join

Discussion in 'Plugin Development' started by Camaflicks, Jun 23, 2014.

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

    Camaflicks

    I am developing a plugin for a server and want it so when someone leaves the server and then joins the server they will spawn at the set spawn, not in the place where they left off.

    I have it where a firework shoots when they spawn, but I never spawn back at my essentials spawn :/

    I don't have any premade code so don't ask for any! I just want to know how to do this.
     
  2. Offline

    Fhbgsdhkfbl

    Camaflicks
    Use a playerjoinevent and get the coords of the location
     
  3. Offline

    Camaflicks

  4. Offline

    Fhbgsdhkfbl

    Camaflicks
    I don't spoonfeed code but
    Code:
    @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e) {
            Player p = e.getPlayer();
            Location l = new Location(p.getWorld(), 501, 9, 1021, 0, 0 ); //heres where the coords will go
            p.teleport(l); //this will teleport the player when they log in
        }
    Not Tested, if it doesn't work, inbox me or tahg me.
     
  5. Offline

    xXBeLkAXx

    Camaflicks
    If u don't want to type some numbers, you can use p.getWorld().getSpawnLocation();
    It will be like this:
    Code:
    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
    Location spawn = p.getWorld().getSpawnLocation();
    p.teleport(spawn);
    }
     
  6. Offline

    Fhbgsdhkfbl

  7. Offline

    xXBeLkAXx

    Fhbgsdhkfbl
    Lol, at my server, I'm using code, like yours :D But also, my code should work.
     
  8. Offline

    Camaflicks

    xXBeLkAXx likes this.
  9. Offline

    Fhbgsdhkfbl

Thread Status:
Not open for further replies.

Share This Page