YML List Set

Discussion in 'Plugin Development' started by Ridan, May 10, 2014.

Thread Status:
Not open for further replies.
  1. Dear, Ive been trying and searching for how i set, add and remove lines
    from a list in the config.
    Ive tried doing stuff like
    words.set(1, "hi");
    etc..
    But nothing works, ALWAYS returns just one huge error
    this is what i have now: (Part of my plugin)
    Code:java
    1. List<String> words = this.getConfig().getStringList(args[1]);
    2. if(line > words.size()){
    3. sender.sendMessage("&4" + line + " is out of range! " + args[1] + " only has " + words.size() + " lines");
    4. return true;
    5. }
    6. String text = "";
    7. for(int a = 3; a > args.length; a++){
    8. text += args[a] + " ";
    9. }
    10. words.set(line, text);
    11. this.getConfig().set(args[1], words);
    12. saveConfig();
    13. sender.sendMessage("&4" + args[1] + " succesfully updated!");
    14. return true;
     
  2. Offline

    minoneer

    Well, that "huge error" is your key to success. Because it doesn't only tell you THAT something is not working, it even tells you WHAT is not working.

    Check out this post - it explains very well how to read a stacktrace: http://forums.bukkit.org/threads/ho...ubleshoot-your-own-plugins-by-yourself.32457/

    If you still can't figure it out after reading that - post your error here. Maybe we can help you then :)
     
  3. Ridan
    This is how you add to the list. You can use the same idea to remove from the list.

    Code:java
    1. List<String> list = getConfig().getStringList("some.list");
    2.  
    3. list.add(someValue);
    4.  
    5. getConfig().set("some.path", list);
     
  4. Thanks, already helped me alot. But, how can i "edit" a line in the list?
    That would help me alot
    Thanks,
    - Ridan
     
Thread Status:
Not open for further replies.

Share This Page