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

Config Error

Discussion in 'Plugin Help' started by NutXzG, May 6, 2020.

  1. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    Hello everyone I have developed this plug-in for a long time. I can solve all problems, but this problem I can not really solve. Please help me. Thanks for the reply
    Loader.php:
    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;
      
         }
    }
    EventHandler.php:
    PHP:
    <?php

    namespace Nurtzatvchkung\Stat;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\player\PlayerChatEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\utils\Config;

    use 
    Nurtzatvchkung\Stat\Loader;

    class 
    EventHandler implements Listener{
                 public 
    $load;
        public function 
    __construct(Loader $load){
        
    $this->load $load;
        }
         public function 
    onJoin(PlayerJoinEvent $ev){
          
    $sender $ev->getPlayer();
          
    $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->getDtaFolder() . "Data/Place/" strtolower($sender->getName()) . ".yml"Config::YAML);
          
    $break = new Config($this->load->getDataFolder() . "Data/Break/" strtolower($sender->getName()) . ".yml"Config::YAML);
          if(empty(
    $join->get("Join"))){
            
    $join->set("Join"1);
            
    $join->save();
          }else{
          
    $join->set("Join"$join->get("Join")+1);
          }
            if(empty(
    $kill->get("Kill"))){
            
    $kill->set("Kill"0);
            
    $kill->save();
          }
             if(empty(
    $death->get("Death"))){
            
    $death->set("Death"0);
            
    $death->save();
          }
           if(empty(
    $chat->get("Chat"))){
            
    $chat->set("Chat"0);
            
    $chat->save();
          }
           if(empty(
    $place->get("Place"))){
            
    $place->set("Place"0);
            
    $place->save();
          }
         if(empty(
    $break->get("Break"))){
            
    $break->set("Kill"0);
            
    $break->save();
         }
        }
        public function 
    onChat(PlayerChatEvent $ev){
        
    $sender $ev->getPlayer();
         if(!
    $ev->isCancelled()){
          
    $chat = new Config($this->load->getDataFolder() . "Data/Chat/" strtolower($sender->getName()) . Config::YAML);
          
    $chat->set("Chat"$chat->get("Chat")+1);
          }
        }
          public function 
    onDeath(PlayerDeathEvent $ev){
            
    $cause $ev->getEntity()->getLastDamageCause();
            if(
    $cause instanceof EntityDamageByEntityEvent) {
               
    $player $ev->getEntity();
               if(
    $player instanceof Player){
                  if(!
    $ev->isCancelled()){
                      
    $death = new Config($this->load->getDataFolder() . "Data/Death/" strtolower($sender->getName()) . Config::YAML);
                      
    $death->set("Death"$death->get("Death")+1);
                    }
               }
                      
    $sender $ev->getEntity()->getLastDamageCause()->getDamager();
          if(
    $sender instanceof Player){
          if(!
    $ev->isCancelled()){
          
    $kill = new Config($this->load->getDataFolder() . "Data/Kill/" strtolower($sender->getName()) . Config::YAML);
          
    $death->set("Kill"$kill->get("Kill")+1);
                }
             }
           }   
        }
            public function 
    onPlace(BlockPlaceEvent $ev){
             
    $sender $ev->getPlayer();
             if(!
    $ev->isCancelled()){
             
    $place = new Config($this->load->getDataFolder() ."Data/Place/" strtolower($sender->getName()) . Config::YAML);
             
    $place->set("Place"$place->get("Place")+1);
             }
           }
             public function 
    onBreak(BlockBreakEvent $ev){
              
    $sender $ev->getPlayer();
              if(!
    $ev->isCancelled()){
              
    $break = new Config($this->load->getDataFolder() . "Data/Break/" strtolower($sender->getName()) . Config::YAML);
              
    $break->set("Break"$break->get("Break")+1);
             }
           }
    }
    myTask.php:
    PHP:
    <?php

    namespace Nurtzatvchkung\Stat;

    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    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");
                   foreach(
    $this->load->getServer()->getOnlinePlayers() as $p){
          
    $this->text = new FloatingTextParticle(new Vector3($x$y$z), """สถิติของคุณ $p->getName()");
                   }
    }

        public function 
    onRun(int $currentTick){
            
    $config = new Config($this->load->getDataFolder() . "config.yml" Config::YAML);
            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);
       }
         }
    }
    }
     

    Attached Files:

  2. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
     
  3. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Can i have the screenshot of the code please :3
     
  4. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    I think is long screenshots But this code
    Loader.php:
    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;

         }
    }
    EventHandler.php:
    PHP:
    <?php

    namespace Nurtzatvchkung\Stat;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\player\PlayerChatEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\utils\Config;

    use 
    Nurtzatvchkung\Stat\Loader;

    class 
    EventHandler implements Listener{
                 public 
    $load;
        public function 
    __construct(Loader $load){
        
    $this->load $load;
        }
         public function 
    onJoin(PlayerJoinEvent $ev){
          
    $sender $ev->getPlayer();
          
    $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->getDtaFolder() . "Data/Place/" strtolower($sender->getName()) . ".yml"Config::YAML);
          
    $break = new Config($this->load->getDataFolder() . "Data/Break/" strtolower($sender->getName()) . ".yml"Config::YAML);
          if(empty(
    $join->get("Join"))){
            
    $join->set("Join"1);
            
    $join->save();
          }else{
          
    $join->set("Join"$join->get("Join")+1);
          }
            if(empty(
    $kill->get("Kill"))){
            
    $kill->set("Kill"0);
            
    $kill->save();
          }
             if(empty(
    $death->get("Death"))){
            
    $death->set("Death"0);
            
    $death->save();
          }
           if(empty(
    $chat->get("Chat"))){
            
    $chat->set("Chat"0);
            
    $chat->save();
          }
           if(empty(
    $place->get("Place"))){
            
    $place->set("Place"0);
            
    $place->save();
          }
         if(empty(
    $break->get("Break"))){
            
    $break->set("Kill"0);
            
    $break->save();
         }
        }
        public function 
    onChat(PlayerChatEvent $ev){
        
    $sender $ev->getPlayer();
         if(!
    $ev->isCancelled()){
          
    $chat = new Config($this->load->getDataFolder() . "Data/Chat/" strtolower($sender->getName()) . Config::YAML);
          
    $chat->set("Chat"$chat->get("Chat")+1);
          }
        }
          public function 
    onDeath(PlayerDeathEvent $ev){
            
    $cause $ev->getEntity()->getLastDamageCause();
            if(
    $cause instanceof EntityDamageByEntityEvent) {
               
    $player $ev->getEntity();
               if(
    $player instanceof Player){
                  if(!
    $ev->isCancelled()){
                      
    $death = new Config($this->load->getDataFolder() . "Data/Death/" strtolower($sender->getName()) . Config::YAML);
                      
    $death->set("Death"$death->get("Death")+1);
                    }
               }
                      
    $sender $ev->getEntity()->getLastDamageCause()->getDamager();
          if(
    $sender instanceof Player){
          if(!
    $ev->isCancelled()){
          
    $kill = new Config($this->load->getDataFolder() . "Data/Kill/" strtolower($sender->getName()) . Config::YAML);
          
    $death->set("Kill"$kill->get("Kill")+1);
                }
             }
           } 
        }
            public function 
    onPlace(BlockPlaceEvent $ev){
             
    $sender $ev->getPlayer();
             if(!
    $ev->isCancelled()){
             
    $place = new Config($this->load->getDataFolder() ."Data/Place/" strtolower($sender->getName()) . Config::YAML);
             
    $place->set("Place"$place->get("Place")+1);
             }
           }
             public function 
    onBreak(BlockBreakEvent $ev){
              
    $sender $ev->getPlayer();
              if(!
    $ev->isCancelled()){
              
    $break = new Config($this->load->getDataFolder() . "Data/Break/" strtolower($sender->getName()) . Config::YAML);
              
    $break->set("Break"$break->get("Break")+1);
             }
           }
    }
    myTask.php:
    PHP:
    <?php

    namespace Nurtzatvchkung\Stat;

    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    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");
                   foreach(
    $this->load->getServer()->getOnlinePlayers() as $p){
          
    $this->text = new FloatingTextParticle(new Vector3($x$y$z), """สถิติของคุณ $p->getName()");
                   }
    }

        public function 
    onRun(int $currentTick){
            
    $config = new Config($this->load->getDataFolder() . "config.yml" Config::YAML);
            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);
       }
         }
    }
    }
     
  5. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Bruh, gives me the file
    I won't steal, because why i need to do that :)
     
  6. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
  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.