Solved How do i set a new line

Discussion in 'Plugin Development' started by Random_Tomato, Nov 12, 2017.

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

    Random_Tomato

    How do you set a new line when saving a string to a list?

    Code:
                if (player.hasPermission("bigbrother.addword")){
                    List<String> list = new ArrayList<String>();
                    list.add(args[1]);
                    plugin.getConfig().set("Banned Words", list);
                    plugin.saveConfig();
                    player.sendMessage("Word added mate");   
                }
    basically this just replaces the string that is already there
     
  2. Offline

    Zombie_Striker

    @Random_Tomato
    1. Set list equal to the list from the config.
    2. If list is null, create a new arraylist.
    3. Then add the arg and reset the list.
     
  3. Offline

    Random_Tomato

  4. Essentially, rather than doing = new ArrayList<>()..., do = config.getStringList("whatever");
    Of course, you'll have to check that it isn't null, and if it is create a new list, but that's the main part of it.

    Sent from my SM-G903F using Tapatalk
     
Thread Status:
Not open for further replies.

Share This Page