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

Help me CrossOnlineCount , How do I solve the problem? I don't have the ability to write plugins.

Discussion in 'Plugin Help' started by Karanztez, Jan 28, 2019.

  1. Karanztez

    Karanztez Spider

    Messages:
    10
    GitHub:
    Karanztez
    PHP:
    [20:29:42] [Server thread/CRITICAL]: Error"Call to undefined method pocketmine\Server::getScheduler()" (EXCEPTIONin "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.
     
    Last edited: Jan 29, 2019
  2. Karanztez

    Karanztez Spider

    Messages:
    10
    GitHub:
    Karanztez
    PHP:
    <?php
    namespace 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);
        }
    }
     
    Last edited: Jan 29, 2019
  3. Karanztez

    Karanztez Spider

    Messages:
    10
    GitHub:
    Karanztez
    PHP:
    <?php
    namespace jasonwynn10\CrossOnlineCount;

    use 
    pocketmine\scheduler\PluginTask;

    class 
    UpdateTask extends PluginTask {
        public function 
    onRun(int $currentTick) {
            
    $this->getOwner()->update();
        }
    }
    .
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    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
     
    Primus and Karanztez like this.
  5. Karanztez

    Karanztez Spider

    Messages:
    10
    GitHub:
    Karanztez
    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 crashedCreating 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 pageGive as much info as you can.
    [09:
    02:18] [Server thread/EMERGENCY]: The crash dump has been automatically submitted to the Crash ArchiveYou can view it on https://crash.pmmp.io/view/2119293 or use the ID #2119293.
     
    Last edited: Jan 29, 2019
  6. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Add

    PHP:
    use pocketmine\scheduler\PluginTask;
     
  7. Karanztez

    Karanztez Spider

    Messages:
    10
    GitHub:
    Karanztez
     
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    The class doesn't exist in pocketmine anymore. Instead the task itself needs remade to work with extending the Task class
     
    corytortoise and Primus like this.
  9. Karanztez

    Karanztez Spider

    Messages:
    10
    GitHub:
    Karanztez
    I want you to go back and develop it.
     
  10. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    I stopped updating it because I thought it didn't work. I guess I can push out something
     
  11. Karanztez

    Karanztez Spider

    Messages:
    10
    GitHub:
    Karanztez
    Bug Dev 4
    PHP:
     [Server thread/CRITICAL]: Error"Call to undefined function jasonwynn10\CrossOnlineCount\getScheduler()" (EXCEPTIONin "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)
     

    Attached Files:

  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.