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

Plugin Crash

Discussion in 'Development' started by Jonas, Mar 21, 2017.

  1. Jonas

    Jonas Baby Zombie

    Messages:
    192
    My Plugin crash. Here is the reason:
    Code:
    [Server] Warning: yaml_parse(): reading error encountered during parsing: invalid leading UTF-8 octet (line 1, column 1) in phar:///storage/emulated/0/PocketMine/PocketMine-MP.phar/src/pocketmine/plugin/PluginDescription.php on line 50
    [Server] [14:12:06] ERROR> Could not load '/storage/emulated/0/PocketMine/plugins/FFAStats' in folder '/storage/emulated/0/PocketMine/plugins/': Argument 1 passed to pocketmine\plugin\PluginDescription::loadMap() must be of the type array, boolean given, called in phar:///storage/emulated/0/PocketMine/PocketMine-MP.phar/src/pocketmine/plugin/PluginDescription.php on line 50
    [Server][14:12:06] CRITICAL> TypeError: "Argument 1 passed to pocketmine\plugin\PluginDescription::loadMap() must be of the type array, boolean given, called in phar:///storage/emulated/0/PocketMine/PocketMine-MP.phar/src/pocketmine/plugin/PluginDescription.php on line 50" (EXCEPTION) in "/src/pocketmine/plugin/PluginDescription" at line 58
    Here The plugin.yml
    Code:
    name: FFA-Stats
    main: FFAStats\Stats
    version: 1.0
    api: 2.0.0
    commands:
      stats:
        description: "Stats Command für FFA"
    [/Code]
    Here is the Stats.php
    PHP:
    <?php

    namespace FFAStats;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\TextFormat as C;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    Stats extends PluginBase implements Listener{
     
      public 
    $prefix C::RED"FFA"C::GOLD"Stats"C::GRAY" |";
     
      public function 
    onEnable(){
        
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        @
    mkdir($this->getDataFolder());
        @
    mkdir($this->getDataFolder()."Players");
        
        
    $this->getLogger()->info($this->prefix." Wurde aktiviert!");
      }
     
      public function 
    initPlayer($player){
        
    $name $player->getName();
        
        
    $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml"Config::YAML);
        if(empty(
    $pconfig->get("Joins"))){
          
    $pconfig->set("Online""true");
          
    $pconfig->set("Joins""0");
          
    $pconfig->set("Deaths""0");
          
    $pconfig->set("Kills""0");
          
    $pconfig->save();
        }
      }
     
      public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args){
        
    $name $sender->getName();
        if(
    $cmd->getName() == "stats"){
          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("Joins""0");
            
    $deaths $pconfig->get("Deaths""0");
            
    $kills $pconfig->get("Kills""0");
            
            
    $sender->senndMessage($this->prefix);
            
    $sendee->sendMessage(C::GOLD."Online: ".$online);
            
    $sender->sendMessage(C::GOLD."Joins: ".$joins);
            
    $sender->sendMessage(C::GOLD."Kills: ".$kills);
            
    $sender->sendMessage(C::GOLD."Deaths: ".$deaths);
            
    $sender->sendMessage(C::GILS."K/D: ".$kills $deaths);
            
    $sender->sendMessage($this->prefix);
            }
          }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("Joins""0");
              
    $deaths $pconfig->get("Deaths""0");
              
    $kills $pconfig->get("Kills""0");
            
              
    $sender->sendMessage($this->prefix);
              
    $sender->sendMessage(C::GRAY."Online: ".$online);
              
    $sender->sendMessage(C::GRAY."Joins: ".$joins);
              
    $sender->sendMessage(C::GRAY."Kills: ".$kills);
              
    $sender->sendMessage(C::GRAY."Deaths: ".$deaths);
              
    $sender->sendMessage(C::GRAY."K/D: ".$kills $deaths);
              
    $sender->sendMessage(C::GRAY."------------");
            }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("Joins");
        
    $pconfig->set("Joins"$joins 1);
        
    $pconfig->set("Online""true");
        
    $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("Deaths");
        
    $pconfig->set("Deaths"$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("Kills");
              
    $kconfig->set("Kills"$kills 1);
              
    $event->setDeathMessage(C::RED "FFA" C::GRAY " | "C::RED$nameC::GRAY" wurde von "C::GOLD$killerC::GRAY " getoetet";
            }
          }
        }
        
    $pconfig->save();
      }
    }
     
  2. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    Well first of all, you're using API 2.0.0 when you need 3.0.0.
     
  3. Jonas

    Jonas Baby Zombie

    Messages:
    192
    2.0.0 work on my Server
     
  4. Jonas

    Jonas Baby Zombie

    Messages:
    192
    With the 3.0.0 comes the same error
     
  5. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    Do you have a crash dump?
     
  6. Jonas

    Jonas Baby Zombie

    Messages:
    192
    No the error comes and the other plugins load
     
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Your plugin.yml seems to contain an invisible invalid character for yaml. Try zipping the real file and uploading that here.
     
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    spaces work with yaml, tabs don't for whatever the reason...
     
  9. Jonas

    Jonas Baby Zombie

    Messages:
    192
    [/QUOTE]
    Here is the zip
     

    Attached Files:

  10. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Screen Shot 2017-03-21 at 16.30.07.png
    That may be the reason :p
    You might want to consider to switch your text editor, obviously it doesn't quite save files cleanly.
    A cleaned plugin.yml is attached. I'm also curious which text editor you are using?
     

    Attached Files:

    HimbeersaftLP and Jonas like this.
  11. Jonas

    Jonas Baby Zombie

    Messages:
    192
    I use QuickEdit(Android)
     
  12. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    my Plugin :D
     
  13. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    obviously a piece of sh*t
     
  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.