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

Call to a member function getChunk() on null

Comments in 'Plugin Development' started by Cristalix, May 1, 2016.

  1. Cristalix
    Offline

    Cristalix New Member

    Joined:
    Sep 10, 2015
    Posts:
    38
    Minecraft User:
    Gistrec
    I have a hub (world named "hub") and minigame (world named "nexus")
    Sometimes, when minigame finish, all player teleport to hub
    write:
    PHP:
    ErrorCall to a member function getChunk() on null
    File
    : /src/pocketmine/level/Level
    Line
    2
    Type
    E_ERROR
    My code (reset map):
    PHP:
    public function EndGame(){
             foreach(
    $this->getServer()->getOnlinePlayers() as $player){
                  
    //update player statistic
                  //update player health, inventory, spawn...
              
    }
               
    $this->UnloadMap();
               
    $this->LoadMap();
    }

    public function 
    UnloadMap(){
             
    $this->getServer()->getLevelByName("nexus")->setAutoSave(false);
             
    $this->getServer()->unloadLevel($this->getServer()->getLevelByName("nexus"),true);
         }

         public function 
    LoadMap(){
             
    $this->getServer()->loadLevel("nexus");
             
    $this->getLogger()->info('§2Map Nexus War reset');
         }
  2. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Where does it say getChunk in the code
  3. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    The level most likely isn't loaded so it will return null.
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    The error is inside PocketMine source.
    HotFireyDeath and ImagicalGamer like this.

Share This Page

Advertisement