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

Error to Server::getScheduler

Discussion in 'Facepalm' started by Flupko, Jul 27, 2018.

Thread Status:
Not open for further replies.
  1. Flupko

    Flupko Silverfish

    Messages:
    24
    GitHub:
    Warex
    I have an error in my code that I can not solve:
    HTML:
    [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\Server::getScheduler()" (EXCEPTION) in "GunCore v17/src/GunCore/Main" at line 108[m
    
    Code :
    PHP:
        $this->getServer()->getScheduler()->scheduleRepeatingTask(new ClearLaggTask($this), 12000);
     
  2. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Replace with:
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new ClearLaggTask($this), 12000);
    Change PluginTask to Task on the ClearLaggTask file.
    And on its constructor, remove parent::__construct(...);
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    dktapps likes this.
  5. Darku

    Darku Spider Jockey

    Messages:
    49
    GitHub:
    DarkWav
    As far as I know, the getServer() function is completely obsolete for normal (not Async) tasks now since all plugins have their own sheduler, so shouldn't it be
    PHP:
    $this->getScheduler()->scheduleRepeatingTask(new ClearLaggTask($this), 12000);
    ?
     
Thread Status:
Not open for further replies.
  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.