Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

teleport player to the worldspawn

Comments in 'Plugin Development' started by Driesboy1, Dec 1, 2015.

  1. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    can i get a code to teleport a player to the worldspawn
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    $this->getServer()->getPlayer()->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn());
  3. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
  4. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    $player->teleport(new Vector3($this->getServer()->getLevelByName($level)->getSpawnLocation()));
  5. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    Thx its better
  6. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    This is even better :p

    Code for teleporting to the spawn of world player currently is in.
    PHP:
    $player->teleport($player->getLevel()->getSafeSpawn());
    Code for teleporting to the spawn of a specific world.
    PHP:
    $player->teleport($this->getServer()->getLevelByName("LevelName")->getSafeSpawn());
    Code for teleporting to the server spawn.
    PHP:
    $player->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn());
    PEMapModder and jojoe77777 like this.
  7. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
  8. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    PHP:
    $player->teleport($player->getLevel()->getSafeSpawn());
    dont work in my plugin
  9. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    PHP:
    $player->teleport($player->getLevel()->getSpawn());
    i use now this

Share This Page

Advertisement