Solved How to remove a single entry from a StringList

Discussion in 'Spigot Plugin Development' started by TheGamerPlayz, May 29, 2016.

Thread Status:
Not open for further replies.
  1. How would i remove a single entry from a StringList in a config?
     
  2. Code (Java):
    List<String> list = plugin.getConfig().getStringList("Path");

    list.remove(String entry);

    plugin.getConfig().set("Path", list);
    something like this ?
     
  3. I thought about that, but wouldn't it just add everything twice? Its not removing it from the config as much as removing from a copy of the config, So maybe if I set it to null first?
     
  4. Ok i figured out I just had to get all entries into a list then set the config's list to null remove what i need to and then add it
    Code (Java):


            blue = teams.getStringList("Teams.Blue");
            teams.set("Teams.Blue", null);
             if(!blue.contains(p.getName())){
                  blue.add(p.getName());
                  teams.set("Teams.Blue", blue);
                  td.saveData();
               }
     
     
  5. well I don't get it but since everything's fine mark it as solved if there's more problem what is it ?
     
  6. I am about to close it I was just testing the plugin fully to be sure that this solution is actually solved and not going to confuse others and take up more forums space later =)
     
Thread Status:
Not open for further replies.