List from a config

Discussion in 'Plugin Development' started by callum.thepro, Jul 1, 2013.

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

    callum.thepro

    Okay, I guess what I am asking for is simple but i have no idea how to go about it.

    Code:java
    1. arenas:
    2. list:
    3. fish:
    4. location:
    5. x: 0
    6. y: 0
    7. z: 0
    8. world: default
    9. spawns: 0
    10. chicken:
    11. location:
    12. x: 0
    13. y: 0
    14. z: 0
    15. world: default
    16. spawns: 0
    17. pork:
    18. location:
    19. x: 0
    20. y: 0
    21. z: 0
    22. world: default
    23. spawns: 0
    24.  


    Above is a list and from that i want to extract fish, chicken and pork aswell as other things which could potentially be in the same position, for example if i was to add burger in the same format I would like it to put that into a String list which i can loop through for future uses.

    Sorry about bad formatting
     
  2. Offline

    callum.thepro

  3. Offline

    MP5K

    Hello callum.thepro,
    try use this as your config:
    Code:
    arenas:
      list:
       - fish:
          location:
            x: 0
            y: 0
            z: 0
            world: default
          spawns: 0
       - chicken:
          location:
            x: 0
            y: 0
            z: 0
            world: default
          spawns: 0
       - pork:
          location:
            x: 0
            y: 0
            z: 0
            world: default
          spawns: 0
    
    and this code to get the List (im not sure but i think the list is a List<LinkedHashMap<String, Object>>)
    Code:java
    1. getConfig().getList("arenas.list");
     
  4. Offline

    callum.thepro

    I will try that now, thanks for the response.

    Thanks mate, it worked

    This returns me all the values inside of the section, i only want the name of the section, how would i do this

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

Share This Page