Hi, sometimes i get a fatal error when running an asynctask. Its the getPluginManager() on null error. here is the asynctask code: PHP: <?php#### SamCraft SkyWars - Core Plugin | Sql Task###namespace Samueljh1\Samcraft\SkyWars\LeaderboardSystem;use pocketmine\plugin\Plugin;use pocketmine\scheduler\ServerScheduler;use pocketmine\scheduler\AsyncTask;use pocketmine\scheduler\PluginTask;use pocketmine\Server;private $leaderboard;class getdata extends AsyncTask{ public function onRun(){ //async code not related to error } public function onCompletion(Server $server){ $server->getPluginManager()->getPlugin("SkyWars-Leaderboard")->processData($this->leaderboard); }} Any ideas/replacements for the getPluginManager() line? thanks @PEMapModder u will probably know xD
PHP: [20:45:49] [Server thread/NOTICE]: RuntimeException: "Declaration of Samueljh1\Samcraft\SkyWars\LeaderboardSystem\getdata::onCompletion() should be compatible with pocketmine\scheduler\AsyncTask::onCompletion(pocketmine\Server $server)" (E_STRICT) in "/SkyWars-Leaderboard/src/Samueljh1/Samcraft/SkyWars/LeaderboardSystem/getdata" at line 37
PHP: public function onCompletion(PluginManager $pm){$pm->getPlugin("SkyWars-Leaderboard")->processData($this->leaderboard); } when you call it: PHP: $this->getdata->onCompletion($this->getPluginManager());
Ouh i'm sorry did'nt see this part: pocketmine\scheduler\AsyncTask:nCompletion ( Server $server) Dont do what i said before! Idk why it's letting through $server if it is an instanceof Server but saying on null Try checking before this action PHP: public function onCompletion(Server $server){ ($server != null ? $server->getPluginManager()->getPlugin("SkyWars-Leaderboard")->processData($this->leaderboard) : $this->getLogger()->alert('[ERROR]'));)}
yes but the server should always work. something weird is happening and that means that sometimes the asynctask won't complete properly because i can't call the finishing function