YML Syntax

Discussion in 'Plugin Development' started by iZanax, May 2, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    iZanax

    Do braces belong to the YML Syntax? like it used below?
    Yes? How to use them like here.
    PHP:
    min: {x275.0y48.0z: -92.0}
    max: {x474.0y98.0z65.0}
    This looks much smoother, for sure if I got 50-300 entries.
    But if this accomplished by String Regex/Split than it's not my preference.

    I use normally
    PHP:
        min:
          
    x43
          y
    38
          z
    3
        max
    :
          
    x39
          y
    35
          z
    7
    Thanks in advance.
    Zanax

    Source: (Braces part)
    http://dev.bukkit.org/bukkit-plugins/simple-region-market/pages/tutorials/
     
  2. Offline

    Drew1080

    iZanax
    JSON is a subset of YAML so yes braces can be used.

    So valid JSON like this
    Code:
    '["foo", {"bar":["baz", "kwa", 1.0, 2]}]'
    Could be written in YAML as this:

    Code:
    - foo
    - bar:
        - baz
        - kwa
        - 1.0
        - 2
     
  3. Offline

    iZanax

    Drew1080
    Thanks a lot!
    I do have a question about setting the value in this format

    Normal approach
    ConfigurationSection v1Section = keySection.getConfigurationSection("v1");
    v1Section.set("x", 1);
    v1Section.set("y", 1);
    v1Section.set("z", 1);

    But how do u make it in the bracket format? : )
    Thanks in advance
     
  4. Offline

    xTrollxDudex

    iZanax
    Those are braces or curly brackets. Brackets are these [ and ]. I believe that YAML supports brackets for arrays (correct me if I'm wrong)
     
  5. Offline

    Panjab

    That's true. That is why you can actually use

    Code:
    authors: [x,Troll,x,Dude,x]
    
    in your plugin.yml for example. It creates an array of strings. :)
     
  6. Offline

    iZanax

    xTrollxDudex I've changed it to Braces ^^


    However, I do have a strange thing that occurs.
    min: {x: 275.0, y: 48.0, z: -92.0}

    This will get acceped by the YML under the ConfigurationSection,
    but it will change it back to the extended version without braces.
    So is there any other approaches that will keep the braces format?

    Code:java
    1. Vector min = new Vector(minSection.getDouble("x"), minSection.getDouble("y"), minSection.getDouble("z"));

    Thanks in advance.
     
  7. Offline

    xTrollxDudex

    iZanax
    You'd have to use brackets [ and ] in order to do that. Using braces { and } defaults to a sectional node in SnakeYAMl and will auto format it for you.
     
  8. Offline

    iZanax

    xTrollxDudex
    Okay, SnakeYAML will auto format it back to without braces.

    min: [x: 275.0, y: 48.0, z: -92.0]

    I've tried the brackets, but this is no ConfigurationSection and won't work with the current settings.
    What are u suggesting? I preferably wont want to use regex/split
     
  9. Offline

    xTrollxDudex

    iZanax
    Are you setting string, or as array?
     
  10. Offline

    iZanax

    xTrollxDudex
    ConfigurationSection min;
    min.set("x", 275);
    min.set("y", 48);
    min.set("z", -92);

    Im setting each xyz individually as Double.
     
Thread Status:
Not open for further replies.

Share This Page