yaml help

Discussion in 'Plugin Development' started by bleachisback, Jul 20, 2011.

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

    bleachisback

    No matter how much I google it or look through the bukkit Configuration API, I simply can't figure out how to create a new yaml file with both sequences an mappings, and then load the yaml file again, and detect all of the sequences and mappings that someone might have edited in, similar to how bukkit registers commands in the plugin.yml

    I've gone through what seems like every tutorial there is, and none explains to me how to do this, and I can't find it in the Bukkit source code

    No one knows how to do this? I might just have to ask the guy who made Permissions...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  2. Offline

    CSharpRU

    Google it =)
     
  3. Offline

    tustin2121

    Congratulations for being an ass...

    @beachisback From what I can tell, the Configuration API is incomplete. I would start experimenting to see what you can come up with. I've found that Plugin.getConfiguration() is a likely starting place as it supposedly gets and parses the config.yml file for you. You can also try and decipher the ConfigurationNode class in the bukkit github source. I might be diving into that same thing shortly, so if I come up with anything, I'll tell you. :)
     
  4. Offline

    bleachisback

    thank you
     
  5. Offline

    nisovin

    When you call any of the get functions on the Configuration class, you need to specify a default value. That default value will be saved into the configuration object if there isn't a value already specified in the config file. Then, once you've read in your config, you just do config.save() and it will write out any of the options that weren't provided in the file initially.

    I assume this is what you're asking?

    Code:
    Configuration config = getConfiguration();
    config.getString("blah","blah");
    config.getString("bleh.blah", "wow");
    config.save();
    
     
  6. Offline

    bleachisback

    Okay, so if I do
    Code:
    Configuration config = getConfiguration();
    config.getString("blah","blah");
    config.getString("bleh.blah", "wow");
    config.save();
    
    It will make a yml file that looks like this:
    Code:
    [/FONT]
    [FONT=georgia]blah: blah[/FONT]
    [FONT=georgia]bleh:[/FONT]
    [FONT=georgia]    blah: wow[/FONT]
    [FONT=georgia]

    Okay, that's a step forward, but how would I make one like this:
    Code:
    shortcuts:
        name1:
            -   property1: stuff goes here
                property2: stuff also goes here
            -   property1: stuff goes here
                property2: stuff also goes here
            -   property1: stuff goes here
                property2: stuff also goes here
        name2:
            -   property1: stuff goes here
                property2: stuff also goes here
            -   property1: stuff goes here
                property2: stuff also goes here
            -   property1: stuff goes here
                property2: stuff also goes here
        name3:
            -   property1: stuff goes here
                property2: stuff also goes here
            -   property1: stuff goes here
                property2: stuff also goes here
            -   property1: stuff goes here
                property2: stuff also goes here
    

    And then detect if someone adds a "name" (similar to bukkit commands in plugin.yml) or adds a tick to a name[/code][/FONT]

    And please ignore the badly formatted post, I've literally spent 30 minutes trying to make it work. And if I try and edit it, it will just mess itself up even more.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  7. Offline

    nisovin

    That is what functions like getStringList(), getIntList(), getNodeList(), etc, are for.
     
    bleachisback likes this.
  8. Offline

    bleachisback

    Okay, thanks, I'll try this out. You've been a big help, thanks =D

    Also, one more thing, how do I get/make the tick marks, like
    Code:
    -     property1: stuff goes here [/FONT]
    [FONT=georgia]                property2: stuff also goes here         [/FONT]
    [FONT=georgia]-     property1: stuff goes here             [/FONT]
    [FONT=georgia]    property2: stuff also goes here [/FONT]
    [FONT=georgia]        -     property1: stuff goes here             [/FONT]
    [FONT=georgia]    property2: stuff also goes here
    [/code][/FONT]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
Thread Status:
Not open for further replies.

Share This Page