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

PlayerTeleportEvent.

Comments in 'Plugin Development' started by WinniePooh, Nov 23, 2014.

  1. WinniePooh
    Offline

    WinniePooh New Member

    Joined:
    Jun 12, 2014
    Posts:
    16
    Minecraft User:
    WinniePooh
    So, I enter cmd "/spawn" and then there is a crash. What is the problem? If I don't give enough info about problem, I can give more.

    PHP:
    private function XYZWfromPlayerTo($evt) {
            return array(
                
    "xto" => $evt->getTo()->x,
                
    "yto" => $evt->getTo()->y,
                
    "zto" => $evt->getTo()->z,
                
    "wto" => $evt->getTo()->level->getName());  //127 line
        
    }

    public function 
    onEntityTeleport(EntityTeleportEvent $evt) {
            
    $player $evt->getEntity();
            if (
    $player instanceof Player) {
                
    extract($this->XYZWfromPlayerTo($evt));
            }
    }
    Code:
    Error: Call to a member function getName() on null
    Line: 127 (getting name of level)
    Type: E_ERROR
    
  2. WinniePooh
    Offline

    WinniePooh New Member

    Joined:
    Jun 12, 2014
    Posts:
    16
    Minecraft User:
    WinniePooh
    I don't sure, but may will it be a problem with spawn coords?..
    YES, EURICA! In plugin where this cmd checks, there I use "....(new Pos(x,y,z)..." and DON'T pass the world name!!! There is in the core, exact in Posintion.php constructor, "public function __construct($x = 0, $y = 0, $z = 0, Level $level = null)", so I passed NULLED world.
    I'm sorry guys!
    PEMapModder likes this.
  3. Sergey_D
    Offline

    Sergey_D Active Member

    Joined:
    Jan 19, 2014
    Posts:
    75
    Minecraft User:
    CLILLZ
    $evt->getTo()->getLevel()->getName();
    PEMapModder and 64FF00 like this.

Share This Page

Advertisement