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

ClassNotFoundException CallbackTask

Discussion in 'Development' started by Gold, Dec 4, 2016.

Thread Status:
Not open for further replies.
  1. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    [Server thread/CRITICAL]: ClassNotFoundException: "Class pocketmine\scheduler\CallbackTask not found" (EXCEPTION) in "/src/spl/BaseClassLoader"
    at line 144
    I am trying to diy a fix for the survival games plugin but I am stumped.
    The repo is here https://github.com/xZeroMCPE/SurvivalGames/
    Img (codeanywhere.com I use this for tests of plugins and some cloud coding):
    [​IMG]
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    CallbackTask should never be used in plugins and has already been removed from PocketMine. Implement your own PluginTask.
     
    Last edited: Dec 4, 2016
  3. JackboyPlay

    JackboyPlay Spider

    Messages:
    11
    GitHub:
    JackboyPlay
    The name of the task is callback task but the task is a normal scheduler repeating
     
  4. JackboyPlay

    JackboyPlay Spider

    Messages:
    11
    GitHub:
    JackboyPlay
    You havent a class called callbackTask...
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    A callback task was once a thing in PM. It got removed though, you now need to create it with a regular task.
     
    SOFe likes this.
  6. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    CallbackTask was removed from PocketMine-MP over a year ago, and was deprecated some time before that. Some spoons simply haven't removed it yet.

    Which reminds me... the MonkeyPatch mess needs clearing up.
     
  7. Infernus101

    Infernus101 Witch

    Messages:
    54
    GitHub:
    infernus102
    @xZeroMCPE
     
  8. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    [​IMG]
    Alright I am now truly confused Because I get and error on line 52
    Error: "Cannot instantiate abstract class pocketmine\scheduler\PluginTask" (EXCEPTION) in "/SurvivalGames/src/Andre/SurvivalGames/Main" at line 52
     
    Last edited: Dec 4, 2016
  9. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    And where is your Task class?
     
  10. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    What do you mean? (Sorry Still learning the api and stuffs)
     
  11. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    You wrote `new Task([$this, "gameTask"]) in your code. Where did the Task come from?
     
  12. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    What gametask?
     
  13. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    It is in the line you were asking...

    You are just blindly editing code, aren't you? Next time I'll get you writing some code that emails all your passwords stored in your computer to me.
     
  14. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    PHP:
        public function gameTask(){
            if(!isset(
    $this->lastpos) || $this->lastpos==array())
            {
                return 
    false;
            }
                
    $this->level $this->getServer()->getLevelByName($this->config->get("pos1")["level"]);
                
    $this->signlevel $this->getServer()->getLevelByName($this->config->get("sign")["level"]);
                if(!
    $this->signlevel instanceof Level)
                {
                    return 
    false;
                }
            
    $this->changeStatusSign();
            if(
    $this->gameStatus==0)
            {
                
    $i=0;
                foreach(
    $this->players as $key=>$val)
                {
                    
    $i++;
                    
    $p=$this->getServer()->getPlayer($val["id"]);
                    
    //echo($i."\n");
                    
    $p->setLevel($this->level);
                    eval(
    "\$p->teleport(\$this->pos".$i .");");
                    unset(
    $p);
                }
            }
            if(
    $this->gameStatus==1)
            {
                
    $this->lastTime--;
                
    $i=0;
                foreach(
    $this->players as $key=>$val)
                {
                    
    $i++;
                    
    $p=$this->getServer()->getPlayer($val["id"]);
                    
    //echo($i."\n");
                    
    $p->setLevel($this->level);
                    eval(
    "\$p->teleport(\$this->pos".$i .");");
                    unset(
    $p);
                }
                switch(
    $this->lastTime)
                {
                case 
    1:
                    
    $this->sendMessage("$Starting ".$this->lastTime." seconds");
                    break;
                case 
    2:
                    
    $this->sendMessage("$Starting ".$this->lastTime." seconds");
                    break;
                case 
    3:
                    
    $this->sendMessage("$Starting ".$this->lastTime." seconds");
                    break;
                case 
    4:
                    
    $this->sendMessage("$Starting ".$this->lastTime." seconds");
                    break;
                case 
    5:
                    
    $this->sendMessage("$Starting ".$this->lastTime." seconds");
                    break;  
                case 
    10:
                    
    $this->sendMessage(TextFormat::RED."[{$this->getConfig()->get("prefix")}$Time 0:10.");
                    break;
                case 
    30:
                    
    $this->sendMessage(TextFormat::RED."[{$this->getConfig()->get("prefix")}$Time 0:30.");
                    break;
                case 
    60:
                    
    $this->sendMessage(TextFormat::RED."[{$this->getConfig()->get("prefix")}$Time 1:00.");
                    break;
                case 
    90:
                    
    $this->sendMessage(TextFormat::RED."[{$this->getConfig()->get("prefix")}$Time 1:30.");
                    break;
                case 
    120:
                    
    $this->sendMessage(TextFormat::RED."[{$this->getConfig()->get("prefix")}$Time 2:00.");
                    break;
                case 
    150:
                    
    $this->sendMessage(TextFormat::RED."[{$this->getConfig()->get("prefix")}$Time 2:30.");
                    break;
                case 
    0:
                    
    $this->gameStatus=2;
                    
    $arena $this->getConfig()->get("Arena-Map");
                    
    Server::getInstance()->broadcastMessage(TextFormat::BLUE"$Started");
                    foreach(
    $this->players as $key=>$val){
                        if(
    $p->hasPermission("SurvivalGames.vip")){
                            
    $p->getInventory()->addItem(new Item(Item::IRON_HELMET01));
                            
    $p->getInventory()->addItem(new Item(Item::IRON_CHESTPLATE01));
                            
    $p->getInventory()->addItem(new Item(Item::IRON_LEGGINGS01));
                            
    $p->getInventory()->addItem(new Item(Item::IRON_BOOTS01));
                            
    $p->getInventory()->addItem(new Item(Item::DIAMOND_AXE01));
                        }
                      
                        
    $p=$this->getServer()->getPlayer($val["id"]);
                        
    $p->setMaxHealth(25);
                        
    $p->setHealth(25);
                        
    $p->setGamemode(0); //Those who cheats
                        
    $p->setLevel($this->level);
                    }
                    
    $this->all=count($this->players);
                    break;
                }
            }
            if(
    $this->gameStatus==2)
            {
                
    $this->lastTime--;
                if(
    $this->lastTime<=0)
                {
                    
    $this->gameStatus=3;
                    
    $this->sendMessage("$Chest_Refilled");
                    
    $this->lastTime=$this->gameTime;
                  
                }
            }
            if(
    $this->gameStatus==|| $this->gameStatus==4)
            {
                if(
    count($this->players)==1)
                {
                    
    $this->sendMessage(TextFormat::RED."[{$this->getConfig()->get("prefix")}] "); // DELETED
                    
    foreach($this->players as &$pl)
                    {
                        
    $p=$this->getServer()->getPlayer($pl["id"]);
                        
    $p->setLevel($this->signlevel);
                        
    $p->getInventory()->clearAll();
                        
    $p->setMaxHealth(25);
                        
    $p->setHealth(25);
                        
    $p->teleport($this->signlevel->getSpawnLocation());
                        unset(
    $pl,$p);
                    }
                    
    $this->players=array();
                    
    $this->gameStatus=0;
                    
    $this->lastTime=0;
                }
                else if(
    count($this->players)==0)
                {
                    
    $this->gameStatus=0;
                    
    $this->lastTime=0;
                    
    $this->ClearAllInv();
                }
            }
            if(
    $this->gameStatus==3)
            {
                
    $this->lastTime--;
                switch(
    $this->lastTime)
                {
                case 
    1:
                    
    $this->sendMessage("$Deathmatch_starting Â§b1 seconds");
                    break;
                case 
    2:
                    
    $this->sendMessage("$Deathmatch_starting Â§b2 seconds");
                    break;
                case 
    3:
                    
    $this->sendMessage("$Deathmatch_starting Â§b3 seconds");
                    break;
                case 
    4:
                    
    $this->sendMessage("$Deathmatch_starting Â§b4 seconds");
                    break;
                case 
    5:
                    
    $this->sendMessage("$Deathmatch_starting Â§b5 seconds");
                    break;  
                case 
    10:
                    
    $this->sendMessage(TextFormat::YELLOW."[{$this->getConfig()->get("prefix")}] Deathmatch will start in 0:10.");
                    break;
                case 
    0:
                    
    $this->sendMessage(TextFormat::YELLOW."[{$this->getConfig()->get("prefix")}$Deatchmatch_started");
                    foreach(
    $this->players as $pl)
                    {
                        
    $p=$this->getServer()->getPlayer($pl["id"]);
                        
    $p->setLevel($this->level);
                        
    $p->teleport($this->lastpos);
                        unset(
    $p,$pl);
                    }
                    
    $this->gameStatus=4;
                    
    $this->lastTime=$this->endTime;
                    break;
                }
            }
            if(
    $this->gameStatus==4)
            {
                
    $this->lastTime--;
                switch(
    $this->lastTime)
                {
                case 
    1:
                    
    $this->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}$Match_Ending " .$this->lastTime".");
                    break;
                case 
    2:
                    
    $this->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}$Match_Ending " .$this->lastTime".");
                    break;
                case 
    3:
                    
    $this->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}$Match_Endingn " .$this->lastTime".");
                    break;
                case 
    4:
                    
    $this->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}$Match_Ending " .$this->lastTime".");
                    break;
                case 
    5:
                    
    $this->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}$Match_Ending " .$this->lastTime".");
                    break;  
                case 
    10:
                    
    $this->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}$Match_Ending 0:10.");
                    break;
                
    //case 20:
                
    case 30:
                    
    $this->sendMessage(TextFormat::RED"[{$this->getConfig()->get("prefix")}$Match_Ending 0:30.");
                    break;
                case 
    0:
                    
    $this->sendMessage(TextFormat::BLUE"[{$this->getConfig()->get("prefix")}$Match_Ended");
                    foreach(
    $this->players as $pl)
                    {
                        
    $p=$this->getServer()->getPlayer($pl["id"]);
                        
    $p->setLevel($this->signlevel);
                        
    $p->teleport($this->signlevel->getSpawnLocation());
                        
    $p->getInventory()->clearAll();
                        
    $p->setMaxHealth(25);
                        
    $p->setHealth(25);
                        unset(
    $p,$pl);
                    }
                    
    $this->players=array();
                    
    $this->gameStatus=0;
                    
    $this->lastTime=0;
                    break;
                }
            }
            
    $this->changeStatusSign();
        }
     
  15. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Do you understand the error message at all?
    Please note that this is PMMP Forums, not PHP Forums. Your problem seems to be purely due to your lack of understanding in the concept of abstract classes in PHP, which is off-topic here.
     
  16. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    I am asking for help with fixing this plugin. I am a new coder.
     
    Last edited: Dec 4, 2016
  17. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    PHP:
    namespace Andre\SurvivalGames;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\OfflinePlayer;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\command\ConsoleCommandSender;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\scheduler\CallbackTask;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\scheduler\TaskHandler;
    use 
    pocketmine\scheduler\ServerScheduler;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\event\entity\EntityDeathEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\tile\Tile;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;
    use 
    killrate\Main as KillRate;
    use 
    pocketmine\event\player\PlayerRespawnEvent;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\event\player\PlayerJoinEvent;

    class 
    Main extends PluginBase implements Listener
    {   
        public 
    $data;
        public 
    $version "1.0.10";
        private static 
    $object null;
       
        public static function 
    getInstance(){
            return 
    self::$object;
        }

        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
            
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new Task([$this,"gameTask"]),20);
            @
    mkdir($this->getDataFolder(), 0777true);
     
  18. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    Does anyone know what to do?
     
  19. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    I'm trying to fix this one.
     
  20. Gold

    Gold Silverfish

    Messages:
    23
    GitHub:
    goldcodes
    Its not old.. It just has one thing that's messed up; CallbackTask @xBeastMode
     
Thread Status:
Not open for further replies.
  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.