I got this error when I try to activate my task: Code: [Server thread/CRITICAL]: pocketmine\utils\PluginException: "Invalid owner of PluginTask DanielYTK\CA" (EXCEPTION) in "/src/pocketmine/scheduler/ServerScheduler" at line 190 Code to activate my task: (ps: it's in the main of file) PHP: $this->getServer()->getScheduler()->scheduleRepeatingTask(new CB($this, $player, $inv), 5);
PHP: <?phpnamespace DanielYTK;use DanielYTK\main;use pocketmine\scheduler\PluginTask;use pocketmine\Player;use pocketmine\item\Item;use pocketmine\level\Level;use pocketmine\block\Block;use pocketmine\math\Vector3;class CB extends PluginTask{ public $plugin; public $player; public $inv; public $type; public $time; public function __construct($plugin, $player, $inv){ $this->plugin = $plugin; $this->player = $player; $this->inv = $inv; $this->time = 40; } public function getPlugin(){ return $this->plugin; } public function onRun($ticks){ if($this->time === 0){ $this->plugin->getServer()->getScheduler()->cancelTask($this->getTaskId()); $this->inv->close($this->player); $this->player->getLevel()->setBlock(new Vector3($this->player->getX(), $this->player->getY()-2, $this->player->getZ()), Block::get(Block::AIR)); $this->plugin->giveReward($this->player, "basica"); } $itens = [ Item::get(57, 0, 8), Item::get(42, 0, 8), Item::get(276, 0, 1), Item::get(277, 0, 1), Item::get(278, 0, 1), Item::get(279, 0, 1), Item::get(310, 0, 1), Item::get(311, 0, 1), Item::get(312, 0, 1), Item::get(313, 0, 1), Item::get(120, 1, 1)->setCustomName("§r§6Caixa Avançada"), ]; $this->inv->setItem(10, $itens[mt_rand(1,10)]); }}
PHP: <?phpnamespace DanielYTK;use DanielYTK\main;use pocketmine\scheduler\PluginTask;use pocketmine\Player;use pocketmine\item\Item;use pocketmine\level\Level;use pocketmine\block\Block;use pocketmine\math\Vector3;class CB extends PluginTask{ public $plugin; public $player; public $inv; public $type; public $time; public function __construct(main $plugin, $player, $inv){ $this->plugin = $plugin; $this->player = $player; $this->inv = $inv; $this->time = 40; } public function getPlugin(){ return $this->plugin; } public function onRun($ticks){ if($this->time === 0){ $this->plugin->getServer()->getScheduler()->cancelTask($this->getTaskId()); $this->inv->close($this->player); $this->player->getLevel()->setBlock(new Vector3($this->player->getX(), $this->player->getY()-2, $this->player->getZ()), Block::get(Block::AIR)); $this->plugin->giveReward($this->player, "basica"); } $itens = [ Item::get(57, 0, 8), Item::get(42, 0, 8), Item::get(276, 0, 1), Item::get(277, 0, 1), Item::get(278, 0, 1), Item::get(279, 0, 1), Item::get(310, 0, 1), Item::get(311, 0, 1), Item::get(312, 0, 1), Item::get(313, 0, 1), Item::get(120, 1, 1)->setCustomName("§r§6Caixa Avançada"), ]; $this->inv->setItem(10, $itens[mt_rand(1,10)]); }}