getStringList().add() problems

Discussion in 'Plugin Development' started by Bjornke, Jul 1, 2012.

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

    Bjornke

    Having some huge issues with this. I do not get any errors, however the config.yml does not reflect the addition to the list.

    If it helps here is some code from the plugin:

    Code:
    this.getConfig().getStringList("chests").add(chestloc.toString());
    This throws absolutely NO errors, and yes, I do save the configuration immediately after. However, I see no reflections on the list in the config. I even changed it to this to test what the hell was going on:

    Code:
    this.getConfig().getStringList("chests").add("TEST");
    this.saveConfig();
    Still, nothing happened. No errors, no nothing. Acted as if nothing had ever been done.

    if it matters, in my loadConfig() method I have this:

    Code:
    this.getConfig().options().copyDefaults(true);
    this.saveConfig();
    Also, I'm using the Bukkit API 1.2.5-4.1 SNAPSHOT version

    Any ideas??

    The plugin is suppose to add chests to a list that get's loaded in the beginning. They are treasure chests for a role play plugin I'm working on. The admin is suppose to be able to add additional chests, however nothing happens at all. The existing chests that I put into the list manually get parsed and loaded into an ArrayList no problem, and I load the list as a StringList. No idea why I cannot add to the list in-game.
     
  2. Offline

    PandazNWafflez

    List<String> list = getConfig().getStringList("chests");
    list.add(blah);
    getConfig().set("chests", list);
    saveConfig();
     
    adventuretc likes this.
  3. Offline

    ClintonM0

    This is crazy. I've been searching all over the forums and this one-reply thread solved everything
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    The reason behind this is because getStringList returns a copy of the underlying list.
     
Thread Status:
Not open for further replies.

Share This Page