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

Solution for this error

Discussion in 'Development' started by Qeis2007, Aug 30, 2018.

  1. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    Anybody have solution for this error? Im confused with this:
    Code:
    2018-08-30 [08:55:17] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'HealthTag v1': Cannot instantiate abstract class pocketmine\scheduler\Task on HealthTag\Main
    2018-08-30 [08:55:17] [Server thread/CRITICAL]: Error: "Cannot instantiate abstract class pocketmine\scheduler\Task" (EXCEPTION) in "HealthTag/src/HealthTag/Main" at line 17
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #0 src/pocketmine/plugin/MethodEventExecutor(38): HealthTag\Main->onJoin(pocketmine\event\player\PlayerJoinEvent object)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #1 src/pocketmine/plugin/RegisteredListener(98): pocketmine\plugin\MethodEventExecutor->execute(HealthTag\Main object, pocketmine\event\player\PlayerJoinEvent object)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #2 src/pocketmine/plugin/PluginManager(749): pocketmine\plugin\RegisteredListener->callEvent(pocketmine\event\player\PlayerJoinEvent object)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #3 src/pocketmine/Player(1029): pocketmine\plugin\PluginManager->callEvent(pocketmine\event\player\PlayerJoinEvent object)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #4 src/pocketmine/Player(977): pocketmine\Player->doFirstSpawn()
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #5 src/pocketmine/level/Level(2464): pocketmine\Player->sendChunk(integer 13, integer 20, pocketmine\network\mcpe\protocol\BatchPacket object)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #6 src/pocketmine/level/Level(2516): pocketmine\level\Level->sendChunkFromCache(integer 13, integer 20)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #7 src/pocketmine/level/format/io/ChunkRequestTask(88): pocketmine\level\Level->chunkRequestCallback(integer 13, integer 20, pocketmine\network\mcpe\protocol\BatchPacket object)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #8 src/pocketmine/scheduler/AsyncPool(285): pocketmine\level\format\io\ChunkRequestTask->onCompletion(pocketmine\Server object)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #9 src/pocketmine/Server(2513): pocketmine\scheduler\AsyncPool->collectTasks()
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #10 src/pocketmine/Server(2258): pocketmine\Server->tick()
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #11 src/pocketmine/Server(2136): pocketmine\Server->tickProcessor()
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #12 src/pocketmine/Server(1713): pocketmine\Server->start()
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #13 src/pocketmine/PocketMine(237): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /storage/emulated/0/PocketMine-MP/, string /storage/emulated/0/PocketMine-MP/plugins/)
    2018-08-30 [08:55:17] [Server thread/DEBUG]: #14 /storage/emulated/0/PocketMine-MP/PocketMine-MP.phar(1): require(string phar:///storage/emulated/0/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    Code:
    PHP:
    <?php
    namespace HealthTag;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\scheduler\TaskScheduler;

    class 
    Main extends PluginBase implements Listener {
        public function 
    onEnable(){
            
    $this->getLogger()->info("HealthTag Enabled!");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
        public function 
    onJoin(PlayerJoinEvent $event){
            
    $player $event->getPlayer();
            
    $task = new Task($this$player);
            
    $this->getScheduler()->scheduleRepeatingTask($task20);
        }
    }
    ?>
     
  2. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    I think u used a wrong phar !
    It's look like phar without orginals files of phar
     
  3. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    I use original and latest PocketMine-MP phar
     
  4. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Show us your task class
     
  5. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    The task is not completed
    PHP:
    <?php
    namespace HealthTag;

    use 
    pocketmine\Player;
    use 
    pocketmine\scheduler\Task;

    class 
    Task extends Task {
        public function 
    __construct($player){
            
    $this->player $player;
        }
        public function 
    onRun(int $tick){
            
    $health $this->player->getHealth();
        }
    }
    ?>
     
  6. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Your class name and the extend name is same
     
  7. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    public function __construct(Main $plugin, Player $player){
     
  8. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Main.php
    PHP:
    <?php
    namespace HealthTag;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\scheduler\TaskScheduler;

    class 
    Main extends PluginBase implements Listener {
        public function 
    onEnable(){
            
    $this->getLogger()->info("HealthTag Enabled!");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
        public function 
    onJoin(PlayerJoinEvent $event){
            
    $player $event->getPlayer();
            
    $task = new Task($player);
            
    $this->getScheduler()->scheduleRepeatingTask($task20);
        }
    }
    Task.php
    PHP:
    <?php
    namespace HealthTag;

    use 
    pocketmine\Player;
    use 
    pocketmine\scheduler\Task as TaskPM;

    class 
    Task extends TaskPM {
        public function 
    __construct(Player $player){
            
    $this->player $player;
        }
        public function 
    onRun(int $tick): void{
            
    $health $this->player->getHealth();
        }
    }
     
    RyanShaw likes this.
  9. Qeis2007

    Qeis2007 Witch

    Messages:
    70
    GitHub:
    FrostingBita
    Thanks, now it works :D
     
  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.