1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

getTiles() error

Discussion in 'Help' started by A354-PH, Jan 2, 2019.

  1. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Guys how to fix this kind of error?
    Code:
    [11:27:32] [Server thread/CRITICAL]: Error: "Call to a member function getTiles() on null" (EXCEPTION) in "MicroBattle v1.1.0 PRO.phar/src/LittleBigMC/MicroBattles/MicroBattles" at line 633
    Here is line 633
    PHP:
    public function onRun($tick)
        {
            
    $allplayers $this->plugin->getServer()->getOnlinePlayers();
            
    $level $this->plugin->getServer()->getLevelByName("MBLobby");
            
    $tiles $level->getTiles(); //Line 633
            
    foreach($tiles as $t) {
                if(
    $t instanceof Sign) {   
                    
    $text $t->getText();
                    if(
    $text[3]==$this->prefix)
                    {
     
  2. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    Change
    PHP:
    $tiles $level->getTiles();
    to
    PHP:
    $tiles $level->getTiles($allplayers);
    it error because it didnt has anything to getTiles
     
  3. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    While it's easy to think that, the issue is actually that $level is returning null. $level->getTiles doesn't require any parameters.

    Either MBLobby doesn't exist, or it isn't loaded when this code is being executed. You can't get tiles from a level that isn't loaded.
     
    Diduhless likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.