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

Why Class Not Found?

Discussion in 'Plugin Help' started by NutXzG, Apr 20, 2020.

  1. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    I make plugin Stat and Use Task New File name "myTask.php" and Register File But Show Error Class Not Found
    Screenshot_2020-04-20-20-00-27-53_3686cb59f45a8f4a2b1e8d6e99664d6d.jpg
    Code:
    PHP:
    <?php

    namespace Nurtzatvchkung\Stat;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\{
    Command,  CommandSender
    };
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;

    use 
    pocketmine\utils\Config;

    use 
    Nurtzatvchkung\Stat\EventHandler;
    use 
    Nurtzatvchkung\Stat\myTask;

    class 
    Loader extends PluginBase{
          public function 
    onEnable() {
             
    $this->getServer()->getPluginManager()->registerEvents(new EventHandler($this), $this);
          @
    mkdir($this->getDataFolder() . "Data/Kill");
          @
    mkdir($this->getDataFolder() . "Data/Death");
          @
    mkdir($this->getDataFolder() . "Data/Join");
          @
    mkdir($this->getDataFolder() . "Data/Place");
          @
    mkdir($this->getDataFolder() . "Data/Break");
          @
    mkdir($this->getDataFolder() . "Data/Chat");
          
    $this->getLogger()->info("Stat's Enable");
           
    $this->getLogger()->info("======================================");
           
    $this->getLogger()->info("Contact:             ");
           
    $this->getLogger()->Info("Youtube: Nutzatvch");
           
    $this->getLogger()->Info("Facebook: fb.com/nutzatvchmc");
           
    $this->getLogger()->Info("Discord: nutza tv ch #0377");
           
    $this->getLogger()->info("======================================");
           
    $this->getScheduler()->scheduleRepeatingTask(new myTask($this), 2);
          }
          public function 
    onComamnd(CommandSender $senderCommand $cmd, array $argsstring $string): bool {
          switch(
    $cmd->getName()){
               case 
    "stat":
                 if(
    $sender instanceof Player) {
                    if(
    $sender->hasPermission("use.stat.command")){
                    if(
    count($args) === 0){
                      
    $sender->sendMessage("Usge: /stat <set/remove/help>");
                      if(
    count($args) === 1){
                      switch(
    $args[0]){
                         case 
    "set";
                   
    $x $sender->getX();
                   
    $y $sender->getY();
                   
    $z $sender->getZ();
                   
    $config = new Config($this->getDataFolder() . "config.yml" Config::YAML);
                   
    $config->set("enable"true);
                  
    $config->set("x"$x);
                   
    $config->set("y"$y);
                   
    $config->set("z"$z);
                   
    $sender->sendMessage("§aAccomplish the given coordinates");
                 break;
                 case 
    "remove";
                
    $config = new Config($this->getDataFolder() . "config.yml" Config::YAML);
                   
    $config->set("enable"false);
                   break;
                    case 
    "help";
                    
    $sender->sendMessage("Usge: /stat <set/remove/world> world name");
                    break;
                    case 
    "world";
                      if(
    count($args[1]) === 0){
                      
    $sender->sendMessage("Usge: /stat world <world name>");
                      }
                      if(
    count($args[1]) === 1){
                         
    $config = new Config($this->getDataFolder() . "config.yml" Config::YAML);
                         
    $config->set("world"$args[1]);
                         }
                         break;
                               }
                          }
                      }
                    }
                 }else{
                      
    $sender->sendMessage("§cUse Command in game only");
                      return 
    true;
                      }
                      break;
                  }
             return 
    true;
      
         }
    }
    myTask
    PHP:
    <?php

    namespace Nurtzatvch\Stat;

    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\level\particle\FloatingParticle;
    use 
    pocketmine\level\particle\Particle;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\utils\Config;
    use 
    Nurtzatvchkung\Stat\Loader;

    class 
    myTask extends Task{

                public 
    $load;
                public 
    $text;

        public function 
    __construct(Loader $load){
        
    $this->load $load;
        
    $config = new Config($this->load->getDataFolder() . "config.yml" Config::YAML);
                   
    $x $config->get("x");
                   
    $y $config->get("y");
                   
    $z $config->get("z");
          
    $this->text = new FloatingTextParticle(new Vector3($x$y$z), """");
    }

        public function 
    onRun(int $currentTick){
            if(
    $config->get("enable") == true){
    foreach(
    $this->load->getServer()->getOnlinePlayer() as $sender){
       
    $config = new Config($this->load->getDataFolder() . "config.yml" Config::YAML);
       
    $world $config->get("world");
      
    $level $this->getServer()->getLevelByName("$world");
     
    $join = new Config($this->load->getDataFolder() . "Data/Join/" strtolower($sender->getName()) . ".yml"Config::YAML);
          
    $kill = new Config($this->load->getDataFolder() . "Data/Kill/" strtolower($sender->getName()) . ".yml"Config::YAML);
          
    $death = new Config($this->load->getDataFolder() . "Data/Death/" strtolower($sender->getName()) . ".yml"Config::YAML);
          
    $chat = new Config($this->load->getDataFolder() . "Data/Chat/" strtolower($sender->getName()) . ".yml"Config::YAML);
          
    $place = new Config($this->load->getDataFolder() . "Data/Place/" strtolower($sender->getName()) . ".yml"Config::YAML);
          
    $break = new Config($this->load->getDataFolder() . "Data/Break/" strtolower($sender->getName()) . ".yml"Config::YAML);
          
    $joins $join->get("Join");
          
    $kills $kill->get("Kill");
          
    $deaths $death->get("Death");
          
    $places $place->get("Place");
          
    $breaks $break->get("Break");
          
    $chats $chat->get("Chat");
         
    $this->text->setText("สถิติของคุณ $sender->getName()\nจำนวนการเข้า $joins\nจำนวนการฆ่า $kills\nจำนวนการตาย $deaths\nจำนวนการวางบล็อก $places\nจำนวนการทุบบล็อก $breaks\nจำนวนการแชท $chats\nจะอัพเดพทุก 2วิ");
       
    $level->addParticle($this->text);
       }
         }
    }
    }
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    You wrote Nurtzatvch instead of Nurtzatvchkung in myTask's namespace
     
    NutXzG likes this.
  3. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    Thanks
     
    HimbeersaftLP likes this.
  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.