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

Teleporting playier to new world on join

Comments in 'Plugin Development' started by Tethered_, Jun 11, 2015.

  1. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    Not sure why, but this code:

    PHP:
    public function onPlayerJoin(PlayerJoinEvent $pje)
        {
            
    $pje->getPlayer()->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn());
    }
    When it runs, it doesn't give any errors, but it also doesn't teleport the player. Anyone know how to fix this?
  2. PixelGuy75
    Offline

    PixelGuy75 Notable Member Plugin Developer

    Joined:
    Feb 9, 2014
    Posts:
    316
    Plugins:
    2
    Minecraft User:
    PixelGuy75
    I also had this same problem. Couldn't figure it out.
  3. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
  4. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    Or is there a way to set the player info when they quit so that when they rejoin, they will always spawn in a certain spot in a certain world?
  5. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    Whats the difference between safespawn and spawn?
    PHP:
    $player->teleport($this->getServer()->getLevelByName("World")->getSpawn());
  6. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    In SpawnMgr (http://forums.pocketmine.net/plugins/spawnmgr.1141/) I do the teleport from a delayedTask. You can find my code in GitHub.

    - getSpawn : gives you the configured spawn
    - getSafeSpawn : checks the spawn first and makes sure it is safe (not inside a a wall for example).
    Tethered_ and PEMapModder like this.
  7. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    I noticed the same problem on MSpawns plugin with latest PocketMine builds. Maybe the teleport function is a bit different from Alpha 1.4.1
  8. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    It is not a problem with teleport but it is that after join the player is moved.

Share This Page

Advertisement