Solved How to add strings, and get strings from a list

Discussion in 'Plugin Development' started by Duuckky, May 8, 2014.

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

    Duuckky

    Hello, I'm having trouble figuring out how to add strings to a list, as well as getting them from a list.
     
  2. Offline

    Not2EXceL

    this is basic java. learn that then come back to bukkit
     
  3. Offline

    Duuckky

    Sorry I mean how to add string and get string from a configuration file.
     
  4. Offline

    xTigerRebornx

  5. Offline

    reider45

    Code:java
    1. List<String> list = new ArrayList<>();
    2. list.add("some string(s)");
    3.  
    4. getConfig().set("ListName", list);
    5. saveConfig();


    Congrats, you've now created your first list.. ;)
    Now to get a string for example from the list,
    Code:java
    1. getConfig().getList("ListName").get("something from the list");
     
  6. Offline

    Duuckky

    Okay thanks, this is working but there is one problem... when I try to add multiple things to the config file, they overwrite each other.
     
  7. Offline

    reider45

    getConfig().getList("ListName").set("string", "something"); right? I don't have my IDE right now, if they're overriding each other you must be setting the same value 2 times make sure that the "string" above is different everytime -- if you could paste some code that'd be great as I'm not sure exactly what your asking
     
Thread Status:
Not open for further replies.

Share This Page