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

Fatal error: Call to a member function loadChunk() on null

Comments in 'Plugin Development' started by minebuilder0110, Sep 30, 2015.

  1. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    I am trying to debug a plugin (Skywars plugin) and this error comes up every time I execute join. This is the part of the code when /sw join was successfully executed.
    PHP:
                                                if($this->playersInArena[strtoupper($args[1])] < $max) {
                                                    
    $this->gamePlayers[$name] = strtoupper($args[1]);
                                                    
    $conf = new Config($this->getDataFolder() . strtoupper($args[1]) . ".yml"CONFIG::YAML);
                                                    
    $world $this->getServer()->getLevelByName($conf->get("LobbyWorld"));
                                                    
    $x $conf->get("LobbyX");
                                                    
    $y $conf->get("LobbyY");
                                                    
    $z $conf->get("LobbyZ");
                                                    
    $world->loadChunk($x$z);
                                                    
    $world->loadChunk($world->getSpawnLocation()->getX(), $world->getSpawnLocation()->getZ());
                                                    
    $sender->teleport($world->getSpawnLocation(), 00);
                                                    
    $pos = new Vector3($x$y$z);
                                                    
    $sender->getInventory()->clearAll();
                                                    
    $sender->setGamemode(2);
                                                    
    $sender->teleport($pos);
                                                    
    $sender->sendMessage("> Welcome to arena '" $conf->get("FullName") . "'!\nThe game will start soon!");
                                                    ++
    $this->playersInArena[strtoupper($args[1])];
                                                    return 
    true;
    Fatal error: Call to a member function loadChunk() on null on line 260
    (Yes, I know you aren't mine readers, but this plugin is on sale by other person, so there is a limit on how much I can put up.)
    I don't think there is anything wrong for me at least, and I don't quite understand the error.
    EDIT: line 260 is
    PHP:
                                                    $world->loadChunk($x$z);
    .
  2. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    Were is the line 260?
  3. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Read below.
    $world->loadChunk($x, $z);
  4. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    $world is not the Level object or the level doesn't exist or not loaded... Try to load / generate the level before
  5. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    If the level is generated load it else generate it and then load the chunk
  6. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    and what is the function to load level? :D
  7. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    bump. please? :3
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  9. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional

Share This Page

Advertisement