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

Solved Crash on call to a member funtion on null

Comments in 'Plugin Development' started by Tim // robske Büba, Dec 19, 2015.

  1. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    just check it
    PHP:
      if($this->getServer()->getLevelByName($mapnameis instanceof Level) echo "exists\n";
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And is it loaded?
    PocketKiller likes this.
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    if($this->getServer()->loadLevel($mapname) != false)
    That could be the solution
    Will test it out
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    1. I had to load the world (now done with
    PHP:
    if($this->getServer()->loadLevel($mapname) != false)
    )
    2. I had to use PlayerLoginEvent instead of PlayerJoin Evenrt
    PHP:
    public function onPlayerJoinSteve(PlayerLoginEvent $e){
            
    $playerJoinName $e->getPlayer()->getName();
            
    $this->getServer()->broadcastMessage("[rBServer] Got ".$playerJoinName." as PlayerName");
            if(
    $playerJoinName == "Steve"){
                
    $SteveIsOnline true;
                
    $this->getServer()->broadcastMessage("SteveJoined");
                
    $mapname "Lobby4";
                
    //while($SteveIsOnline == true)
                //{
                    
    $this->getServer()->broadcastMessage("IsStillOnline");
                    if(
    $this->getServer()->loadLevel($mapname) != false)
                    {
                        
    $e->getPlayer()->teleport($this->getServer()->getLevelByName($mapname)->getSafeSpawn());
                    }
                    else
                    {
                        
    $this->getServer()->broadcastMessage("ERR_xxx_DESC_DESC");
                    }
                    
    $SteveIsOnline $e->getPlayer()->IsOnline();
                
    //}
            
    }
        }
    SOLVED
    Last edited: Dec 23, 2015
  5. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    The code does exact the same thing and does (It's php) not crash, even if the level is loaded already!
    PEMapModder likes this.

Share This Page

Advertisement