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

getName() on null?

Comments in 'Plugin Development' started by Tethered_, Jul 2, 2015.

  1. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    I have no idea what is causing this error:

    PocketMine-MP Crash Dump Thu Jul 2 10:08:59 EDT 2015

    Error: Call to a member function getName() on null
    File: /src/pocketmine/level/Level__64bit
    Line: 2634
    Type: E_ERROR

    Code:
    [2625] return (int) $this->time;
    [2626] }
    [2627]
    [2628] /**
    [2629] * Returns the Level name
    [2630] *
    [2631] * @return string
    [2632] */
    [2633] public function getName(){
    [2634] return $this->provider->getName();
    [2635] }
    [2636]
    [2637] /**
    [2638] * Returns the Level folder name
    [2639] *
    [2640] * @return string
    [2641] */
    [2642] public function getFolderName(){
    [2643] return $this->folderName;
    [2644] }
    DunxandMinecraft likes this.
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    435
    Plugins:
    4
    Minecraft User:
    Lambo
    You have to call the getName function on a Level object. Try
    PHP:
    $this->getServer()->getLevelByName("name");
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Probably a wrongly initialized level?
  4. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    Just figured it out. I was trying to unload a level, but I ended up using a delayed task to do it which did the trick.
  5. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    Bump. I'm getting the same error. Every time I try to unload a world, I get this error

    Code:
    [14:02:45] [Server thread/INFO]: Unloading level "kingoftheladder"
    
    Fatal error: Call to a member function getName() on null in phar://C:/Users/Jack/Desktop/Coding/POCKETMINE/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/level/Level__32bit.php on line 2634
    
    What could be causing this?
  6. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Are you sure that is the correct name of the level? Are you using that level later on?

Share This Page

Advertisement