Gettings my kits in configuration (Urgent)

Discussion in 'Spigot Plugin Development' started by luigieai, Jan 16, 2015.

  1. Hello guys, everything fine?
    Im creating my SkyWars plugin, and i am implementing a kit system to my arenas. But the kits aren't defined by the code, i make a command to add the kits to the config. Im creating a kit shop, when the kit shop is open, all the kits from configuration is show on GUI selector, i usually know how to do the GUI and the kit system, but i dont know how to get the kits from my config. I know this method:
    Code (Text):
            ArrayList<String> kits = new ArrayList<String>();
            Inventory selector = Bukkit.createInventory(null, 54, ChatColor.BOLD+""+ChatColor.GREEN+"Selecione seu kit");
            for(String s : SettingsManager.getKits().getH().getStringList("allkits")) {
                kits.add(s);
            }
    but this works when the config is like that:
    HTML:
    AllKits:
    Kit 1:
      armor:
      itens:
    Kit 2:
      armor:
      itens:
    etc...
    (i just need the kit name, Kit1, Kit2 etc... i dont need to pick the armor and itens string)
    but my config is like that:
    HTML:
    Kit 1:
       armor:
       itens:
    Kit 2:
       armor:
       itens:
    etc..
    How i can just get the KIT name?
     
  2. @luigieai getKeys(false) returns the immediate children of a node.
     
    • Like Like x 1
  3. Ohhh, thanks so much, so my method will be like this?:
    HTML:
            for(String s : SettingsManager.getKits().getH().getKeys(false)) {
                kits.add(s);
            }
     
  4. @luigieai assuming getH() returns the config you showed in your first post (the last code block), yes.
     
  5. Thanks for the help :p
    JUST A LAST eZ THING:
    my kits will use >1 arguments in their name(example: Extra Life), so in my kit.yml will be like:
    Code (Text):
     Extra Life:
      Itens:
      Armor:
    in YAML, i can espace the words like i did in my example, because i see lot of people do like this:
    Code (Text):
    Extra-Life:
    armor:
    Itens:
    I can do without the "-"?
     
  6. @luigieai Of course you can :p
    Code (YAML):
    'Extra Life':
      items
    : x
      armor
    : y
     
    • Like Like x 1