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

Solved YAML error...Ughhh ‍

Discussion in 'Development' started by TheDiamondYT, Jul 9, 2017.

  1. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    I have a yaml_parse error at line 3 and line 13 for some reason

    Code:
    ---
    # Set to false to stop the generator being registered
    enabled: true
    
    # The world type used
    #  - normal
    #  - nether
    world-type: nether
    
    blocks:
      1: 120  # Stone
      2: 80   # Grass
      3: 20   # Dirt
      9: 10   # Still Water
      11: 5   # Still Lava
      12: 20  # Sand
      13: 10  # Gravel
      14: 10  # Gold Ore
      15: 20O # Iron Ore
      16: 40  # Coal Ore
      17: 100 # Trunk
      18: 40  # Leaves
      20: 1   # Glass
      21: 5   # Lapis Ore
      24: 10  # Sandstone
      30: 10  # Cobweb
      31: 3   # Tall Grass
      32: 3   # Dead Bush
      35: 25  # Wool
      37: 2   # Dandelion
      38: 2   # Rose
      39: 2   # Brown Mushroom
      40: 2   # Red Mushroom
      46: 2   # TNT
      47: 3   # Bookshelf
      48: 5   # Mossy Stone
      49: 5   # Obsidian
      54: 1   # Chest
      52: 1   # Monster Spawner
      56: 1   # Diamond Ore
      73: 8   # Redstone Ore
      79: 4   # Ice
      80: 8   # Snow Block
      81: 1   # Cactus
      82: 20  # Clay Block
      83: 15  # Sugarcane Block
      86: 5   # Pumpkin
      103: 5  # Melon Block
      110: 15 # Mycelium
    ...
    
    Error
    Code:
    Warning: yaml_parse(): parsing error encountered during parsing: did not find expected key (line 12, column 3), context while parsing a block mapping (line 3, column 1) in phar:///storage/emulated/0/PocketMine/PocketMine-MP.phar/src/pocketmine/utils/Config.php on line 143
    
    Warning: yaml_parse(): parsing error encountered during parsing: did not find expected key (line 12, column 3), context while parsing a block mapping (line 3, column 1) in phar:///storage/emulated/0/PocketMine/PocketMine-MP.phar/src/pocketmine/plugin/PluginBase.php on line 262
    [20:36:44] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\utils\Config::setDefaults() must be of the type array, boolean given, called in phar:///storage/emulated/0/PocketMine/PocketMine-MP.phar/src/pocketmine/plugin/PluginBase.php on line 262" (EXCEPTION) in "/src/pocketmine/utils/Config" at line 441
    
     
    Last edited: Jul 9, 2017
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You might want to show the error. It should help ;)
     
    jojoe77777 likes this.
  3. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Updated (unrelated: check my profile post)
     
  4. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Although I see no errors, to easily fix errors like this, just hardcode the YAML data into your code and then remove it afterwards when your config has been generated.
     
  5. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    But i spent ages commenting it all >_<
     
  6. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    http://www.yamllint.com/ says the file should be right and valid. I'm not sure what could be the issue. Are the values entered in the file those values that you showed too?

    You might also want to try and change the spacing before the keys.
     
  7. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    I think you need to check your '0's and 'O's.
     
    HimbeersaftLP and SOFe like this.
  8. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
  9. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Same error wtf
     
  10. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    I generated this code from an array and var_dump(yaml_emit(array)) and copied it and how i think about it that could be why
     
  11. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Don't copy it, try rewriting everything, especially the spaces parts.
     
  12. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Copying your YAML code from Chrome, the data are parsed correctly using PHP 7.0.6 CLI with YAML 2.0.0RC8.
    Try copying the data here back?
     
  13. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    I printed it using var_dump but i changed it to yaml_emit_file and it works now... Now my problem is i need to access the config from a custom generator class but its in a different thread
     
  14. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    well, create a new config object for reading in that thread?
     
  15. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Read in the main thread, serialize it and pass the serialized string to the main thread if you don't want to parse on the other thread?
    Otherwise, what's wrong with parsing directly on the other thread?
     
  16. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    I asked dylan and it doesnt work i cant access static methods (Loader::getInstance()) from the generator thread. Technically i just need to pass an array
     
  17. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Why do you want to pass the main instance at all? Only pass data you need.
     
  18. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    HOW (example?)
     
  19. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
  20. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
  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.