Hi, i've been getting this error a lot. I'm not sure why.. Any help would be appreciated.. My Error: PHP: [06:27:39] [Server thread/CRITICAL]: pocketmine\utils\PluginException: "Invalid owner of PluginTask RTG\HUD\Task" (EXCEPTION) in "/src/pocketmine/scheduler/ServerScheduler" at line 276 My Main: PHP: <?phpnamespace RTG\HUD;/* Essentials */use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\Server;use pocketmine\scheduler\PluginTask;use pocketmine\command\CommandExecutor;use pocketmine\Player;use RTG\HUD\Task;use RTG\HUD\command\HUDCommand;class Loader extends PluginBase implements Listener { public $enable; public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->warning("Starting..."); $this->getServer()->getScheduler()->scheduleRepeatingTask(new Task($this), 20); $this->enable = array(); $this->getCommand("hud")->setExecutor(new HUDCommand($this)); } public function onDisable() { } } My Task; PHP: <?phpnamespace RTG\HUD;use RTG\HUD\Loader;use pocketmine\Server;use pocketmine\Player;use pocketmine\scheduler\PluginTask;use pocketmine\utils\Config;class Task extends PluginTask { public function __construct(Loader $plugin) { $this->plugin = $plugin; } public function onRun($tick) { $online = $this->getServer()->getOnlinePlayers(); $c = $this->plugin->getConfig(); foreach($online as $p) { if(isset($this->plugin->enable[strtolower($p->getName())])) { $p->sendPopup("->".$c->get("hud")); } } } } NOTE: This isn't the full plugin, it contains more files like for commands. For the full SRC. I've added it here -> https://github.com/RTGDaCoder/CustomHUD
You must call the parent constructor when you overwrite the constructor method of a plugin task: PHP: class YourTask extends pocketmine\scheduler\PluginTask{ protected $myPlugin; public function __construct(pocketmine\plugin\Plugin $yourPluginInstance){ parent::__construct($yourPluginInstance); $this->myPlugin = $myPluginInstance; } public function onRun($tick){ // do stuff }}
If the name of your plugins main class is Loader and your are passing it to your tasks constructor, yes that would be your plugins instance/object.