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

Solved Teleport() not working

Comments in 'Plugin Development' started by MooShoe, Dec 28, 2015.

  1. MooShoe
    Offline

    MooShoe New Member

    Joined:
    Dec 27, 2015
    Posts:
    16
    Minecraft User:
    StevieBlock
    Hi, I've been having some trouble with the teleport() function. When I try to teleport a player to a certain coordinate, it gives me an error and shuts down the server as soon as I join the server or fails to teleport the player. Here is the code:
    PHP:
    namespace Some\Random\Namespace;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\plugin\PluginBase;

    class 
    Hub extends PluginBase implements Listener {
        public function 
    onEnable() {
            
    $this->getLogger()->info("MyPlugin is up and ready to welcome people to NatalieCraft!");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
       
        public function 
    onPlayerJoin(PlayerJoinEvent $event) {
            
    $event->getPlayer()->sendMessage("§eHey There! Welcome to §cNatalieCraft§e, we're glad to see you!");
            
    $event->setJoinMessage("§c".$event->getPlayer()->getName()." §ehas joined the game.");
            
    $event->getPlayer()->teleport(new Position(050));
        }
  2. MooShoe
    Offline

    MooShoe New Member

    Joined:
    Dec 27, 2015
    Posts:
    16
    Minecraft User:
    StevieBlock
    Yea... I just realized one error. I forgot to import Position.
    Still getting the same error.
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You should tell us the error.
  4. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Whats the error?
  5. MooShoe
    Offline

    MooShoe New Member

    Joined:
    Dec 27, 2015
    Posts:
    16
    Minecraft User:
    StevieBlock
    teleport() is not working
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Send the error..
  7. MooShoe
    Offline

    MooShoe New Member

    Joined:
    Dec 27, 2015
    Posts:
    16
    Minecraft User:
    StevieBlock
    Maybe "error" is the wrong term. In the console it's not giving me any errors, it's just not teleporting the player.
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
  9. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Teleporting doesn't work in PlayerJoinEvent, teleport the player in PlayerLoginEvent
    AndrewBit likes this.
  10. MooShoe
    Offline

    MooShoe New Member

    Joined:
    Dec 27, 2015
    Posts:
    16
    Minecraft User:
    StevieBlock
    hehe... srry I'm not too clear about this stuff. I'm just wondering why my player is not being teleported to (0, 5, 0) when he logs on.
  11. MooShoe
    Offline

    MooShoe New Member

    Joined:
    Dec 27, 2015
    Posts:
    16
    Minecraft User:
    StevieBlock
    cant read! thx so much
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Teleport the player through PlayerRespawnEvent. PlayerRespawnEvent is called after the player died-and-respawned or after the player joined.
    AndrewBit and CraftYourBukkit like this.
  13. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    PlayerLoginEvent is good, too!
    (PlayerLoginEvent will be called before the yellow text appears and PlayerRespawnEvent after the yellow text appears)
    I am using only PlayerLoginEvent because my serverCore plugin has much to do on the playerlogin and i want that yellow text after that!
  14. MooShoe
    Offline

    MooShoe New Member

    Joined:
    Dec 27, 2015
    Posts:
    16
    Minecraft User:
    StevieBlock
    Thank you so much for all the support! I got it to work!

Share This Page

Advertisement