Clarify some YAML related things please

General discussion of Denizen-Bukkit, or even just Bukkit.
Post Reply
n0nnie
New
New
Posts: 14
Joined: January 10th, 2018, 3:19 am
Location: München - Germany
Contact:

Clarify some YAML related things please

Post by n0nnie » February 1st, 2019, 2:36 pm

I recently bumped into some Questions, which might be handy for further readers:

This tells me:
» Use to modify a YAML file similarly to a flag.
- yaml id:myfile set my.key[2]:hello
But if I do something like this:

Code: Select all

- yaml id:tablist_config set tablist.header.text:Zeile1
      - yaml id:tablist_config set tablist.header.text[2]:Zeile2
A yml file is created, where Zeile1 is overwritten with Zeile2 and i looks like this:

Code: Select all

tablist:
  footer:
    text:
    - Zeile2
Can I do something like this and if, how?

Code: Select all

tablist:
  footer:
    text:
    - <&f>--------------------------------
    - <&5>   www.uhu-uhu.de
    - <&5>   Eulen, die ranklotzen
Next question I ran into:
Is there some way to force a sorting order? The creation of the yaml files seems a bit random to me. It does not seem to sort it in any way?

Last question:
Is there a way to put some sort of comment into the default config file? Maybe I can make it looking like this:

Code: Select all

tablist:
  footer:
    text:
    #Here you can specify your footer. Each line will be a new line. Color codes have to be like <&code>
    - <&f>--------------------------------
    - <&5>   www.uhu-uhu.de
    - <&5>   Eulen, die ranklotzen

User avatar
mcmonkey
Site Admin
Site Admin
Posts: 200
Joined: August 5th, 2016, 7:27 pm
Location: Los Angeles, California, USA
Contact:

Re: Clarify some YAML related things please

Post by mcmonkey » February 2nd, 2019, 8:31 pm

n0nnie wrote:
February 1st, 2019, 2:36 pm
Can I do something like this and if, how?
That appears to actually be a bug in the YAML handler in Denizen. That bug is fixed in build DEV-603+ :D
Thanks for pointing that out!
n0nnie wrote:
February 1st, 2019, 2:36 pm
Is there some way to force a sorting order? The creation of the yaml files seems a bit random to me. It does not seem to sort it in any way?
You can sort the list of keys when looking at it via tags, like "list.alphanumeric". Keys beyond that are not inherently sorted and will not remain in any specific order while in YAML. YAML does not order keys, only lists in YAML are ordered.
n0nnie wrote:
February 1st, 2019, 2:36 pm
Is there a way to put some sort of comment into the default config file? Maybe I can make it looking like this:
Only if you distribute the config file as text or include it directly inside the script (via 'yaml data' script type!)
YAML does not retain knowledge of comments when loading/saving.
Denizen lead developer.
http://mcmonkey.org

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest