Cant figure this out..

Discussion in 'Plugin Development' started by blogget, Dec 30, 2019.

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

    blogget

    I am having a little problem with my config.yml file..
    I want to know how to access the information values after the 1.. lol I've searched google for a long while and cant find a tutorial that suits my needs. Granted its been a long while since I've done any type of development, trying to get back into it after about 5 years. So small things are just gone in my brain right now haha..
    Code:
    Inventories:
      Items:
         '1':
           Name:'PVP'
            Material:'DIAMOND_SWORD'
             Slot:6
    Heres my code
    Code:
        public void openCustomGUI(Player p){
            Inventory crafting = Bukkit.createInventory(p, this.getMainConfig().getInt("Inventory-Size"), ChatColor.translateAlternateColorCodes('&', this.getMainConfig().getString("Inventory-Name")));
         
    //        List<ItemStack> list = new ArrayList<ItemStack>();
            for(String ints : this.getMainConfig().getConfigurationSection("Inventories.Items").getKeys(false)) {
                p.sendMessage(ints);
                p.openInventory(crafting);
            }
         
        }
    pretty much all this code does is GETS the 1 in the config.yml anything after that I am completely lost..

    And i plan to add more numbers onto this file. 2, 3, 4, etc etc.
     
  2. Online

    timtower Administrator Administrator Moderator

    @blogget Get the section, get the section of the key.
     
  3. Offline

    blogget

    I understand that, yes but I would like to make in such a way that I dont have to add more section keys if I were to add a secondary element to my YAML
     
  4. Online

    timtower Administrator Administrator Moderator

    @blogget That is not how yml works.
     
  5. Offline

    Strahan

    Well, if you want to add more names but not add more parent keys you'd have to make name a string list instead of a single string. Of course, then it won't associate anymore to material or slot. Why would you not just make more keys? Being hierarchical is the nature of YAML. It's rather simple to achieve, not sure why you wouldn't just use it that way.
     
  6. Offline

    blogget

    I honestly didnt think of that. Rust is bad haha! Ill try that when I can!
     
Thread Status:
Not open for further replies.

Share This Page