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

TimerTask crash :(

Comments in 'Plugin Development' started by TheMaks, Sep 27, 2015.

  1. TheMaks
    Offline

    TheMaks Active Member

    Joined:
    Jul 19, 2015
    Posts:
    58
    Minecraft User:
    TheMaks
    Help me found error in timer :)
    File: Main.php
    Code:
    <?php
    namespace TheMaks;
    use pocketmine\plugin\PluginBase;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerJoinEvent;
    use pocketmine\scheduler\PluginTask;
    use pocketmine\Player;
    class Main extends PluginBase implements Listener{
    public function onEnable(){
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
    }
    public function onJoin(PlayerJoinEvent $e){
    $player = $e->getPlayer();
    if($player instanceof Player){
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new TimerTask($this), 40);
    }
    }
    }
    File TimerTask.php

    Code:
    <?php
    
    namespace TheMaks;
    
    use pocketmine\scheduler\PluginTask;
    use pocketmine\utils\TextFormat;
    use pocketmine\Player;
    
    class TimerTask extends PluginTask{
        public $player;
        public function __construct(Main $plugin, Player $player){
           parent::__construct($plugin);
           $this->player = $player;
        }
    
        public function onRun($currentTick){
           $this->player->sendPopup("lol");
        }
    }
    File CrashDump:

    PocketMine-MP Crash Dump Sun Sep 27 05:25:56 UTC 2015

    Error: Call to undefined function TheMaks\new TimerTask()
    File: /DevTools/src/TheMaks/Main
    Line: 15
    Type: E_ERROR

    THIS CRASH WAS CAUSED BY A PLUGIN
    BAD PLUGIN: ServerPortal v1

    Code:
    [6] use pocketmine\scheduler\PluginTask;
    [7] use pocketmine\Player;
    [8] class Main extends PluginBase implements Listener{
    [9] public function onEnable(){
    [10] $this->getServer()->getPluginManager()->registerEvents($this,$this);
    [11] }
    [12] public function onJoin(PlayerJoinEvent $e){
    [13] $player = $e->getPlayer();
    [14] if($player instanceof Player){
    [15] $this->getServer()->getScheduler()->scheduleRepeatingTask(new TimerTask($this), 40);
    [16] }
    [17] }
    [18] }
    [19]
    [20]
    [21]
    [22]
    [23]
    [24]
    [25]
  2. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    PHP:
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new TimerTask($this,$player),40);
    You haven't specified $player
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Delete the problematic line and write it again. Something strange happened and made it such that your space isn't a space.

Share This Page

Advertisement