Solved Arraylist with spaces

Discussion in 'Plugin Development' started by OverDodo, Apr 28, 2017.

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

    OverDodo

    So I want to create a WarnList, stored in the PlayerConfigFile. It all works but my output doesn´t make andy spaces or \n! How can I do that? I want for every reason a new line! Sorry for my bad english! Here is my code:

    PHP:
    ArrayList<String> list = new ArrayList<String>();
                        list.
    add(f.getString("warnreasons"));
                        list.
    add("/n" reason);
                       
                        
    f.set("warnreasons", list);
     
  2. Online

    timtower Administrator Administrator Moderator

    @OverDodo It is a list, get the list, add an item to it.
    Don't use getString on it.
     
  3. Offline

    OverDodo

    "f" is the FileConfiguration which I use to edit the PlayerConfig. It has nothing to do with the List.
     
  4. Offline

    Caderape2

    @OverDodo warnreasons is a string list i guess.
    config.getStringList("warnreasons).add(reason);
    then save it
     
  5. Offline

    OverDodo

    It is an ArrayList.. Could you please provide me a code, how I do that? I tried this now:

    f.getStringList("warnreasons").add("\n" + reason);
    cm.saveConfig();


    cm is my ConfigManager for Players btw. help plz :c
     
  6. Offline

    Caderape2

    @OverDodo You don't need the \n. It's a list, it's one line for an add.
    when you display it, you will just have to loops contents of the list
     
  7. Online

    timtower Administrator Administrator Moderator

    @OverDodo get the list, set it in a temporary variable.
    Add a reason to it.
    Set it in the config.
    Save it.
     
Thread Status:
Not open for further replies.

Share This Page