Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

YAML syntax error?

Comments in 'Plugin Development' started by PocketKiller, Jan 31, 2016.

  1. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Hi,

    YAML syntax error.. :oops:

    code :
    PHP:
    public function onDeath(\pocketmine\event\player\PlayerDeathEvent $event){
            if(
    $event->getEntity()->getLastDamageCause() instanceof \pocketmine\event\entity\EntityDamageByEntityEvent){
                if(
    $event->getEntity()->getLastDamageCause()->getDamager() instanceof Player){
                    
    $this->addPoints($event->getEntity()->getLastDamageCause()->getDamager()->getName(), 1);
                    foreach(
    $this->getConfig()->get("killmessages") as $k => $msg){ // 
                        
    if($this->getPoints($event->getEntity()->getLastDamageCause()->getDamager()->getName()) > $k 1){
                            
    $event->getEntity()->getLastDamageCause()->getDamager()->sendMessage($msg);
                        }
                    }
                }
            }
        }
    config :
    Code:
    ---
    killmessages:
      50: "You have killed 50 players!"
      1: "You killed 1 player! first killstreak!"
    ...
    
    error:
    Code:
    "Could not pass event 'pocketmine\event\player\PlayerDeathEvent' to 'CLKillerRecorder v1.0.0 Beta': yaml_parse(): scanning error encountered during parsing: could not find expected ':' (line 6, column 1), context while scanning a simple key (line 5, column 2) on PocketKiller\CLKillRecorder\Main
    [22:25:04] warning> RuntimeException: "yaml_parse(): scanning error encountered during parsing: could not find expected ':' (line 6, column 1), context while scanning a simple key (line 5, column 2)" (E_WARNING) in "/src/pocketmine/plugin/PluginBase" at line 266
    
    Thanks
    Last edited: Jan 31, 2016
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Code:
    killmessages:
     '50': "You have killed 50 players!"
     '1': "You killed 1 player! first killstreak!"
    
    PocketKiller likes this.
  3. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    tried that already.
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Code:
    ...
    # YAML content goes between these 'tags'
    ---
    
    It says line 6. But you only gave us three lines tho.
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    I gave you the whole content, when I get YAML syntax errors it always says big numbers..
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Whole? Did you include these ^ YAML tags?
  7. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    yes.
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    converted to JSON :
    Code:
    {
    "killmessages": {
    "1": "You killed 1 player! first killstreak!",
    "50": "You have killed 50 players!"
            }
    }
  9. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Really strange :\
    PocketKiller likes this.
  10. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    maybe the code doesnt search the yml for "50".... but hay ho.... maybe im wrong....
  11. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    it didn't even parse it, how can it read?
  12. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    You write arrays in a config like this:
    Code:
    ---
    killmessages:
    - 50: "You have killed 50 players!"
    - 1: "You killed 1 player! first killstreak!"
    ...
    
  13. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I dont really understand this line:
    PHP:
    if($this->getPoints($event->getEntity()->getLastDamageCause()->getDamager()->getName()) > $k 1){
    Do you want to get if the killamount of a player is in the config?
  14. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    tried that already.
  15. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    Can you just make sure that the config.yml in your datafolder is the same?
    Perhaps you may have rewrote the config.yml in your resources while testing, and config will not replace an earlier one written in the datafolder (unless you designed it)?
    Primus likes this.
  16. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    I am editing the generated one (not the one on /resources)
    HotFireyDeath likes this.
  17. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Why dont you try another way, when this is to complicated?
    PHP:
    $this->killMsg[] = $this->config->get("messages");
    public function 
    sendKillMsg($player){
    $name $player->getName();
    foreach(
    $this->killMsg as $points => $msg){
    if(
    $points == $this->getPoints($player->getName)){
    $player->sendMessage($msg);
    }}}
  18. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    how can I read it when it's even not parsed properly?
  19. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Can't you see the YAML parsing error on the main post? that doesn't mean I called something wrongly, while I am getting the config there is a parsing error.
  20. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    it'll just make an error, DID YOU EVEN UNDERSTAND? you don't know whats a parse error.
    PEMapModder likes this.

Share This Page

Advertisement