Solved YAML config

Discussion in 'Plugin Development' started by CrystallFTW, Apr 25, 2015.

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

    CrystallFTW

    Hi, I'm trying to create a kits plugin with a config file where i can create kits. I want my yaml file to look like that:
    Code:
    Kits:
       Archer:
         - item1
         - item2
    ...
       Warrior:
         - item1
         - item2
    ...
       Mage:
         - item1
         - item2
    ...
    What i want to know is how do i get kits name in plugin? So whenever someone types my command(/kits list ) they will receive a message "Available kits: Archer, Warrior, Mage"
    Kits aren't made in plugin. I have to make them in config.

    (I hope you understand what I'm trying to say xD)
     
  2. Offline

    SuperOriginal

    YamlConfiguration#getConfiguationSection("Kits).getKeys(false)

    //the boolean represents a deep search which you do not want.
     
    vhbob and mine-care like this.
  3. Offline

    CrystallFTW

    @SuperOriginal I don't really understand what you are saying, sorry xd
     
  4. Offline

    ChromeHD__

    Code:
    YamlConfiguration#getConfiguationSection("Kits).getKeys(false)
    this will get all the the kit names for example
    Code:
    Kits:
       Archer: <------ These
         - item1
         - item2
    ...
       Warrior: <------ These
         - item1
         - item2
    ...
       Mage:  <------ These
         - item1
         - item2
    ...
    but dosent show the items
     
  5. Offline

    CrystallFTW

    @ChromeHD__ Thanks, that helped!
    But I have another question.. What if I have my code like this :
    Code:
    Kits:
       Archer: 
         Name: §l§4Archer
         Description: §l§4Archer Kit
    ...
       Warrior: 
         Name: §l§oWarrior
         Description: §l§oWarrior Kit
    ...
       Mage:  
         Name: §l§bMage
         Description: §l§bMage Kit
    ...
    How do I get the "Name" and "Description" section from every kit? I want to make a command to show all the names + Description of every kit.
     
  6. Offline

    BlazingBroGamer

    @CrystallFTW
    Loop through, and use:
    YamlConfiguration#getString(kitname + ".Name")
    This will get the name, then you can just change the "Name" part to "Description" for the description.
     
  7. Offline

    CrystallFTW

    Solved! Thanks to everyone!
     
Thread Status:
Not open for further replies.

Share This Page