Solved Arraylist from config.yml

Discussion in 'Spigot Plugin Development' started by DEDHACKS, May 17, 2018.

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

    DEDHACKS Previously Price14108

    Hello, I ask you because i would like know something...

    How to recup arraylist String (to reuse them) from file.yml like this :

    Code (Text):
    KitId:
      Name:
      Lore:
      IDBlock:
    And How to make an infinity of "kit" different?
    Like this:
    Code (Text):
    1:
      Name: Cake
      Lore: I'm a cake
      IDBlock: 1

    2:
      Name: Muffin
      Lore: I'm a muffin
      IDBlock: 2

    3:
      Name: Candy
      Lore: I'm a candy
      IDBlock: 3

    Thanks you

    PS: the kit in this post is just for example
     
  2. DEDHACKS

    DEDHACKS Previously Price14108

    But
    But with that how can I sort by name, ids etc?
     
  3. So when you load all the kits, you want to sort them by name?
     
  4. DEDHACKS

    DEDHACKS Previously Price14108

    No, i would like know how to get all the kit, if i create 54 kits in config.yml, I would like recup 54 kit.
     
  5. Use
    Code (Text):
    for(String key : config.getConfigurationSection("").getKeys(false)) { (Returns the config values)
    // kit instance and set values
    config.getString(key + ".Name");
    config.getStringList(key + ".Lore");
    config.getInt(key + ".IDBlock");
    // add to a List
    }
     
  6. DEDHACKS

    DEDHACKS Previously Price14108

    Thx you but what i enter in "(Returns the config values)" ?
     
  7. Benz56

    Supporter

    Use a HashMap.
    Loop over the section and use the section key as the hashmap key and put the section as the value or use your own object to handle the data.
     
  8. Just delete this xd it was only for demonstrating
     
  9. For such things i have a ConfigManager where all values stored in a hashmap and were saved into a config if the server stops :D
    Great for logging too!
     
  10. DEDHACKS

    DEDHACKS Previously Price14108

    Thanks you !
     
Thread Status:
Not open for further replies.

Share This Page