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

Plugin error

Discussion in 'Plugin Help' started by dragonflex, Mar 9, 2017.

  1. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    Hi! I have a error on my plugin. Well, my plugin hot send message!

    PHP:
     
      
    public function onCommand(CommandSender $senderCommand $cmd$label, array $args){
        
    $name $sender->getName();
        if(
    $cmd->getName() == "staty"){
          if(empty(
    $args[0])){
            if(
    $sender instanceof Player){
            
    $player $sender;
            
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
            
    $online $pconfig->get("Online""true");
            
    $joins $pconfig->get("JoinCount""0");
            
    $deaths $pconfig->get("DeathCount""0");
            
    $kills $pconfig->get("KillCount""0");
            
    $places $pconfig->get("PlaceCount""0");
            
    $breaks $pconfig->get("BreakCount""0");
           
            
    $player->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]");
            
    $player->sendMessage("§c* §7Online:§c ".$online." ");
            
    $player->sendMessage("§c* §7Odwiedzin:§c ".$joins." ");
            
    $player->sendMessage("§c* §7Zabojstwa:§c ".$kills." ");
            
    $player->sendMessage("§c* §7Smierci:§c ".$deaths." ");
            
    $player->sendMessage("§c* §7Postawione Bloki:§c ".$places." ");
            
    $player->sendMessage("§c* §7Zniszczone Bloki:§c ".$breaks." ");
            
    $player->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]");
            }
          }elseif(!empty(
    $args[0])){
            if(
    file_exists($this->getDataFolder()."/Players/".strtolower($args[0]).".yml")){
              
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($args[0]).".yml"Config::YAML);
              
    $online $pconfig->get("Online""true");
              
    $joins $pconfig->get("JoinCount""0");
              
    $deaths $pconfig->get("DeathCount""0");
              
    $kills $pconfig->get("KillCount""0");
              
    $places $pconfig->get("PlaceCount""0");
              
    $breaks $pconfig->get("BreakCount""0");          
           
              
    $sender->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]");
              
    $sender->sendMessage("§c* §7Online:§c ".$online." ");
              
    $sender->sendMessage("§c* §7Odwiedzin:§c ".$joins." ");
              
    $sender->sendMessage("§c* §7Zabojstwa:§c ".$kills." ");
              
    $sender->sendMessage("§c* §7Smierci:§c ".$deaths." ");
              
    $sender->sendMessage("§c* §7Postawione Bloki:§c ".$places." ");
              
    $sender->sendMessage("§c* §7Zniszczone Bloki:§c ".$breaks." ");
              
    $sender->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]");
            }else{
              
    $sender->sendMessage($this->prefix.C::RED." Dieser Spieler war noch nie auf dem Server!");
            }
          } 
        } 
      }
    Please help on edit my plugin
     

    Attached Files:

  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Are there any errors on console?
     
  3. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    On the $pconfig->get you must online write "Online" for example and not the "true"
    PHP:
    $online $pconfig->get("Online");
            
    $joins $pconfig->get("JoinCount");
            
    $deaths $pconfig->get("DeathCount");
            
    $kills $pconfig->get("KillCount");
            
    $places $pconfig->get("PlaceCount");
            
    $breaks $pconfig->get("BreakCount");
         
           
     
  4. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
  5. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    I assume your issue is fixed, but please fix this . Its easy if you make your folder's name lowercase which can save your life in the future!
     
  6. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    Yes, but I think it is more beautiful if the folders are capitalized: D
     
  7. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Its up to you but you could run into issues!
     
  8. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    Yes, this is true
     
  9. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    Not work this
     
  10. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    english please :)
     
    jasonwynn10 likes this.
  11. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    Not work this!
     
  12. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    it works :D when you make it like I showed you :D
     
  13. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    Not work -_- i edit this and get empty message on sending command
     
  14. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    Then show me the whole plugin
     
  15. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    PHP:
    <?php

    namespace StatusGracza;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\TextFormat as C;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Position\getLevel;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    Main extends PluginBase implements Listener{
       
      public 
    $prefix C::GRAY."".C::AQUA."§cSTATY§7".C::GRAY."";
       
      public function 
    onEnable(){
        
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        @
    mkdir($this->getDataFolder());
        @
    mkdir($this->getDataFolder()."Players");
       
        
    $this->getLogger()->info("by McpeBooster!");
      }
     
      public function 
    initPlayer($player){
        
    $name $player->getName();
       
        
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
        if(empty(
    $pconfig->get("JoinCount"))){
          
    $pconfig->set("Online","true");
          
    $pconfig->set("JoinCount""0");
          
    $pconfig->set("DeathCount""0");
          
    $pconfig->set("KillCount""0");
          
    $pconfig->set("PlaceCount""0");
          
    $pconfig->set("BreakCount""0");
        }
      }
     
      public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args){
        
    $name $sender->getName();
        if(
    $cmd->getName() == "staty"){
          if(empty(
    $args[0])){
            if(
    $sender instanceof Player){
            
    $player $sender;
            
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
    $online $pconfig->get("Online");
            
    $joins $pconfig->get("JoinCount");
            
    $deaths $pconfig->get("DeathCount");
            
    $kills $pconfig->get("KillCount");
            
    $places $pconfig->get("PlaceCount");
            
    $breaks $pconfig->get("BreakCount");    
           
            
    $player->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]");
            
    $player->sendMessage("§c* §7Online:§c ".$online);
            
    $player->sendMessage("§c* §7Odwiedzin:§c ".$joins);
            
    $player->sendMessage("§c* §7Zabojstwa:§c ".$kills);
            
    $player->sendMessage("§c* §7Smierci:§c ".$deaths);
            
    $player->sendMessage("§c* §7Postawione Bloki:§c ".$places);
            
    $player->sendMessage("§c* §7Zniszczone Bloki:§c ".$breaks);
            
    $player->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]");
            }
          }elseif(!empty(
    $args[0])){
            if(
    file_exists($this->getDataFolder()."/Players/".strtolower($args[0]).".yml")){
              
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($args[0]).".yml"Config::YAML);
    $online $pconfig->get("Online");
            
    $joins $pconfig->get("JoinCount");
            
    $deaths $pconfig->get("DeathCount");
            
    $kills $pconfig->get("KillCount");
            
    $places $pconfig->get("PlaceCount");
            
    $breaks $pconfig->get("BreakCount");    
           
              
    $sender->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]");
              
    $sender->sendMessage("§c* §7Online:§c ".$online);
              
    $sender->sendMessage("§c* §7Odwiedzin:§c ".$joins);
              
    $sender->sendMessage("§c* §7Zabojstwa:§c ".$kills);
              
    $sender->sendMessage("§c* §7Smierci:§c ".$deaths);
              
    $sender->sendMessage("§c* §7Postawione Bloki:§c ".$places);
              
    $sender->sendMessage("§c* §7Zniszczone Bloki:§c ".$breaks);
              
    $sender->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]");
            }else{
              
    $sender->sendMessage($this->prefix.C::RED." Dieser Spieler war noch nie auf dem Server!");
            }
          } 
        } 
      }

      public function 
    onJoin(PlayerJoinEvent $event){
        
    $player $event->getPlayer();
        
    $name $player->getName();
       
        
    $this->initPlayer($player);
        
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
        
    $joins $pconfig->get("JoinCount");
        
    $pconfig->set("JoinCount"$joins 1);
        
    $pconfig->set("Online""true");
        
    $pconfig->save();
      }
     
      public function 
    onPlace(BlockPlaceEvent $event){
        
    $player $event->getPlayer();
        
    $name $player->getName();

        
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
        
    $places $pconfig->get("PlaceCount");
        
    $pconfig->set("PlaceCount"$places 1);
        
    $pconfig->save();
      }
     
      public function 
    onDestroy(BlockBreakEvent $event){
        
    $player $event->getPlayer();
        
    $name $player->getName();

        
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
        
    $breaks $pconfig->get("BreakCount");
        
    $pconfig->set("BreakCount"$breaks 1);
        
    $pconfig->save();
      }
     
      public function 
    onQuit(PlayerQuitEvent $event){
        
    $player $event->getPlayer();
        
    $name $player->getName();
       
        
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
        
    $pconfig->set("Online""false");
        
    $pconfig->save();
      }  
     
      public function 
    onDeath(PlayerDeathEvent $event){
        
    $player $event->getPlayer();
        
    $name $player->getName();
       
        
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
        
    $deaths $pconfig->get("DeathCount");
        
    $pconfig->set("DeathCount"$deaths 1);
       
        
    $lastDmg $player->getLastDamageCause();
        if(
    $lastDmg instanceof EntityDamageEvent){
          if(
    $lastDmg instanceof EntityDamageByEntityEvent){
          
    $killer $lastDmg->getDamager();
            if(
    $killer instanceof Player){ 
              
    $kconfig = new Config($this->getDataFolder()."/Players/".strtolower($killer).".yml"Config::YAML);
              
    $kills $kconfig->get("KillCount");
              
    $kconfig->set("KillCount"$kills 1);
            }
          }
        }
        
    $pconfig->save();
      }
    }
     
  16. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    And your plugin.yml?

     
  17. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    PHP:
    nameStatusGracza
    main
    StatusGracza\Main
    version
    1.0.0
    api
    2.0.0
    author
    McpeBooster
    commands
    :
      
    staty:
        
    description"Statystyki danego gracza"
     
  18. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    Does the server create a yourname.yml when you join?
     
  19. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
  20. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    please show me this file
     
  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.