Solved strList.remove not working

Discussion in 'Plugin Development' started by mazentheamazin, Feb 15, 2014.

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

    mazentheamazin

    Hey,

    I am currently getting a string list and wishing to remove as well as add people to the list, however it is not working. There are no methods in console, this is the method I am using:
    Code:java
    1. //GetConfig variable:
    2. YamlConfiguration getConfig;
    3.  
    4. public TwitPlayer(String p) {
    5. player = p;
    6. File f = new File(EssCore.getPlugin().getDataFolder() + "twitter/users/", p + ".yml");
    7. getConfig = YamlConfiguration.loadConfiguration(f);
    8. }
    9.  

    Removing player from the list:
    Code:java
    1. public boolean unfollowPlayer(String playerName, String displayName) {
    2. List<String> following = getConfig.getStringList("following");
    3. if(!following.contains(playerName)) {
    4. return false;
    5. }else{
    6. following.remove(playerName);
    7. Bukkit.broadcastMessage("" + getConfig.getStringList("following").contains(playerName));
    8. try {
    9. getConfig.save(new File(EssCore.getPlugin().getDataFolder() + "/twitter/users/", player + ".yml"));
    10. } catch (IOException e) {
    11. e.printStackTrace();
    12. }
    13. return true;
    14. }
    15. }

    No errors in console, but its not working. Any help is appreciated.

    Thanks,
    Mazen

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    mazentheamazin

  3. mazentheamazin
    What would happen if you write a message, but never send it?

    Confusing hints aside, you're removing a name from the ArrayList, not the config. That's the first part, the second part is to update the config file by adding the 'following' list to it.
     
  4. Offline

    mazentheamazin

    Assist
    Wow, that was a stupid mistake. Thanks soo much for the help!
     
Thread Status:
Not open for further replies.

Share This Page