PHP: [20:29:42] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\Server::getScheduler()" (EXCEPTION) in "plugins/coline/src/jasonwynn10/CrossOnlineCount/Main" at line 15[20:29:42] [Server thread/DEBUG]: #0 src/pocketmine/plugin/PluginBase(123): jasonwynn10\CrossOnlineCount\Main->onEnable()[20:29:42] [Server thread/DEBUG]: #1 src/pocketmine/plugin/PluginManager(587): pocketmine\plugin\PluginBase->setEnabled(boolean 1)[20:29:42] [Server thread/DEBUG]: #2 src/pocketmine/Server(2003): pocketmine\plugin\PluginManager->enablePlugin(jasonwynn10\CrossOnlineCount\Main object)[20:29:42] [Server thread/DEBUG]: #3 src/pocketmine/Server(1989): pocketmine\Server->enablePlugin(jasonwynn10\CrossOnlineCount\Main object)[20:29:42] [Server thread/DEBUG]: #4 plugins/PocketMine-DevTools (2).phar/src/DevTools/DevTools(51): pocketmine\Server->enablePlugins(integer 0)[20:29:42] [Server thread/DEBUG]: #5 src/pocketmine/plugin/PluginBase(123): DevTools\DevTools->onEnable()[20:29:42] [Server thread/DEBUG]: #6 src/pocketmine/plugin/PluginManager(587): pocketmine\plugin\PluginBase->setEnabled(boolean 1)[20:29:42] [Server thread/DEBUG]: #7 src/pocketmine/Server(2003): pocketmine\plugin\PluginManager->enablePlugin(DevTools\DevTools object)[20:29:42] [Server thread/DEBUG]: #8 src/pocketmine/Server(1989): pocketmine\Server->enablePlugin(DevTools\DevTools object)[20:29:42] [Server thread/DEBUG]: #9 src/pocketmine/Server(1722): pocketmine\Server->enablePlugins(integer 0)[20:29:42] [Server thread/DEBUG]: #10 src/pocketmine/PocketMine(249): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\Administrator\Desktop\Server\Lobby\, string C:\Users\Administrator\Desktop\Server\Lobby\plugins\)[20:29:42] [Server thread/DEBUG]: #11 (1): require(string phar://C:/Users/Administrator/Desktop/Server/Lobby/PocketMine-MP.phar/src/pocketmine/PocketMine.php) plugin does not update player information now.
PHP: <?phpnamespace jasonwynn10\CrossOnlineCount;use jasonwynn10\CrossOnlineCount\libpmquery\PMQuery;use jasonwynn10\CrossOnlineCount\libpmquery\PmQueryException;use pocketmine\event\Listener;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat;use slapper\events\SlapperCreationEvent;use slapper\events\SlapperDeletionEvent;class Main extends PluginBase implements Listener { public function onEnable() { $this->getServer()->getScheduler()->scheduleRepeatingTask(new UpdateTask($this), 5); // server updates query data every 5 ticks $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onDisable() { foreach($this->getServer()->getLevels() as $level) { foreach($level->getEntities() as $entity) { if(!empty($entity->namedtag->getString("server", ""))) { $lines = explode("\n", $entity->getNameTag()); $lines[0] = $entity->namedtag->getString("server", ""); $nametag = implode("\n", $lines); $entity->setNameTag($nametag); } } } } /** * @priority LOW * * @param SlapperCreationEvent $ev */ public function onSlapperCreate(SlapperCreationEvent $ev) { $entity = $ev->getEntity(); $lines = explode("\n", $entity->getNameTag()); if($this->isValidIP($lines[0]) or $this->is_valid_domain_name($lines[0])) { $entity->namedtag->setString("server", $lines[0]); $this->update(); } } /** * @priority LOW * * @param SlapperDeletionEvent $ev */ public function onSlapperDelete(SlapperDeletionEvent $ev) { $entity = $ev->getEntity(); if(!empty($entity->namedtag->getString("server", ""))) { $entity->namedtag->removeTag("server"); } } /** * @api */ public function update() { foreach($this->getServer()->getLevels() as $level) { foreach($level->getEntities() as $entity) { if(!empty($entity->namedtag->getString("server", ""))) { $server = explode(":", $entity->namedtag->getString("server", "")); try { $queryData = PMQuery::query($server[0], $server[1]); //TODO make async $online = (int) $queryData['num']; $lines = explode("\n", $entity->getNameTag()); $lines[0] = TextFormat::YELLOW.$online." Online".TextFormat::WHITE; $nametag = implode("\n", $lines); $entity->setNameTag($nametag); }catch(PmQueryException $e) { $this->getLogger()->logException($e); $lines = explode("\n", $entity->getNameTag()); $lines[0] = TextFormat::DARK_RED."Server Offline".TextFormat::WHITE; $nametag = implode("\n", $lines); $entity->setNameTag($nametag); } } } } } /** * @api * * @param string $domain_name * * @return bool */ public function is_valid_domain_name(string $domain_name) { return (preg_match("/([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*:(\d{1,5})/i", $domain_name) //valid chars check and preg_match("/.{1,253}/", $domain_name) //overall length check and preg_match("/[^\.]{1,63}(\.[^\.]{1,63})*/", $domain_name)); //length of each label } /** * @api * * @param string $ip * * @return bool */ public function isValidIP(string $ip) { return (preg_match("/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})/", $ip) !== false); }}
PHP: <?phpnamespace jasonwynn10\CrossOnlineCount;use pocketmine\scheduler\PluginTask;class UpdateTask extends PluginTask { public function onRun(int $currentTick) { $this->getOwner()->update(); }} .
replace $this->getServer()->getScheduler() with $this->getScheduler() Also, I'm surprised that the plugin is even working because PluginTask doesn't exist in PocketMine anymore
PHP: $this->getScheduler()->scheduleRepeatingTask(new UpdateTask($this), 5); Or I misunderstand Because it still has errors. PHP: Fatal error: Class 'pocketmine\scheduler\PluginTask' not found in C:\Users\Administrator\Desktop\Server\Lobby\plugins\coline\src\jasonwynn10\CrossOnlineCount\UpdateTask.php on line 6[09:02:17] [Server thread/EMERGENCY]: An unrecoverable error has occurred and the server has crashed. Creating a crash dump[09:02:17] [Server thread/EMERGENCY]: Please upload the "C:\Users\Administrator\Desktop\Server\Lobby\crashdumps/Tue_Jan_29-09.02.17-WIB_2019.log" file to the Crash Archive and submit the link to the Bug Reporting page. Give as much info as you can.[09:02:18] [Server thread/EMERGENCY]: The crash dump has been automatically submitted to the Crash Archive. You can view it on https://crash.pmmp.io/view/2119293 or use the ID #2119293.
The class doesn't exist in pocketmine anymore. Instead the task itself needs remade to work with extending the Task class
Bug Dev 4 PHP: [Server thread/CRITICAL]: Error: "Call to undefined function jasonwynn10\CrossOnlineCount\getScheduler()" (EXCEPTION) in "plugins/ci/src/jasonwynn10/CrossOnlineCount/Main" at line 17[15:47:56] [Server thread/DEBUG]: #0 src/pocketmine/plugin/PluginBase(123): jasonwynn10\CrossOnlineCount\Main->onEnable()[15:47:56] [Server thread/DEBUG]: #1 src/pocketmine/plugin/PluginManager(587): pocketmine\plugin\PluginBase->setEnabled(boolean 1)[15:47:56] [Server thread/DEBUG]: #2 src/pocketmine/Server(2003): pocketmine\plugin\PluginManager->enablePlugin(jasonwynn10\CrossOnlineCount\Main object)[15:47:56] [Server thread/DEBUG]: #3 src/pocketmine/Server(1989): pocketmine\Server->enablePlugin(jasonwynn10\CrossOnlineCount\Main object)[15:47:56] [Server thread/DEBUG]: #4 plugins/PocketMine-DevTools (2).phar/src/DevTools/DevTools(51): pocketmine\Server->enablePlugins(integer 0)[15:47:56] [Server thread/DEBUG]: #5 src/pocketmine/plugin/PluginBase(123): DevTools\DevTools->onEnable()[15:47:56] [Server thread/DEBUG]: #6 src/pocketmine/plugin/PluginManager(587): pocketmine\plugin\PluginBase->setEnabled(boolean 1)[15:47:56] [Server thread/DEBUG]: #7 src/pocketmine/Server(2003): pocketmine\plugin\PluginManager->enablePlugin(DevTools\DevTools object)[15:47:56] [Server thread/DEBUG]: #8 src/pocketmine/Server(1989): pocketmine\Server->enablePlugin(DevTools\DevTools object)[15:47:56] [Server thread/DEBUG]: #9 src/pocketmine/Server(1722): pocketmine\Server->enablePlugins(integer 0)[15:47:56] [Server thread/DEBUG]: #10 src/pocketmine/PocketMine(249): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\Administrator\Desktop\Server\Lobby\, string C:\Users\Administrator\Desktop\Server\Lobby\plugins\)[15:47:56] [Server thread/DEBUG]: #11 (1): require(string phar://C:/Users/Administrator/Desktop/Server/Lobby/PocketMine-MP.phar/src/pocketmine/PocketMine.php)