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

Teleport to a custom spawn

Comments in 'Plugin Development' started by TheBison_, May 29, 2016.

  1. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Why does this not work? I will always be teleported to the default spawn

    arena.yml:
    Code:
    spawnx: 110.000000
    spawny: 75.000000
    spawnz: 92.000000
    spawnworld: Taiga
    saferadius: 10
    maxplayer: 16
    code:
    PHP:
        public function onRespawn(PlayerRespawnEvent $event)
        {
            
    $player $event->getPlayer();
            
    $arena = new Config($this->getDataFolder() . "/arena.yml"Config::YAML);
            if(
    $player->getLevel()->getFolderName() === $arena->get("spawnworld"))
            {
                
    $player->setSpawn(new Position($arena->get("spawnx")+0.5$arena->get("spawny"), $arena->get("spawnz")+0.5$this->getServer()->getLevelByName($arena->get("spawnworld"))));
            }
        }
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You need to set the spawn before the player dies.
    TheBison_ likes this.
  3. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    ok thanks!

Share This Page

Advertisement