Whats the best way to store nested Lists (lists inside of lists)?

Discussion in 'Plugin Development' started by uvbeenzaned, Sep 25, 2012.

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

    uvbeenzaned

    How can I save lists that I have lists in a flat file and recall them later? I am trying to have one array list of locations for each player inside of one big list to keep everything organized. Do I need to find another way to do it? Are there going to be issues? I am currently using the default Bukkit configuration features.


    Thanks in advance! :)
     
  2. Two-Dimnesional Arrays?
    /Blame me if it's not what you're looking for/
     
  3. Offline

    uvbeenzaned

    Well yeah that's what I'm looking for essentially and I know how to use them but what I really want to know is how to save them in a text file and then recover them easily later.
     
  4. Well, i think you'll need to make for, and then save them, let's wait for someone's else opinion.
     
  5. Offline

    uvbeenzaned

    Ok thanks for the help anyway!
     
  6. Offline

    SirTyler

    Well there is no standard way, you just have to write your own way to save and load them based on your own personal preference.

    How I would do it is save it like so:
    Code:
    {
    1[1],1[2],1[3],
    2[1],2[2],2[3].
    }
    Where the first value is the first dimension of the array and the value inside the brackets is the second dimension of the array. After that is just reading all the values and figuring out how much memory to allocate and what goes where.
     
  7. Offline

    Sagacious_Zed Bukkit Docs

    The Configuration API should be able to have a path set to l and written out.
    for example
    let l be of type List<List<? extends ConfigurationSerializable>>
    Code:
    getConfig().set("list", l);
     
  8. Offline

    SirTyler

    Wouldn't setting the value l (assuming it is a list in this case) attempt to save the name of it and not the actual values?
     
  9. Offline

    Sagacious_Zed Bukkit Docs

    No, collections should be written with the value. In this case a List of a List of ConfigurationSerializable items.
     
  10. Offline

    uvbeenzaned

    Well thanks. These are the ways I was planning to do this. I thought there might be a different way but that sounds good. Thanks for the quick replies!
     
Thread Status:
Not open for further replies.

Share This Page