Solved Config List being overwritten

Discussion in 'Plugin Development' started by acer5999, Nov 25, 2014.

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

    acer5999

    I have noticed quite a large bug in my plugin. The config list for players is being overwritten a new location is being added. I am recording clicks on block and on every click there is supposed to be a new entry of a location under the players UUID
    Example:
    Code:
    c08bac84-f1d8-3bfa-b6ee-3d9f0bc97197:
    - e6b31860-846f-4325-adc9-b03d120e5410 -476.0 66.0 579.0 0.0 0.0
    
    but whenever I click a block it overwrites the section leaving me with only one line even if I click 30 different blocks. No Errors.
    Code that handles it:
    Code:java
    1. List<String> list = getConfig().getStringList(p.getUniqueId().toString());
    2. list.add(LocationUtils.serialize(e.getClickedBlock().getLocation()));
    3. getConfig().set(p.getUniqueId().toString(), list);
    4. saveConfig();

    Thanks,
    Acer
     
  2. Offline

    Skionz

    acer5999 Try debugging. Is the list you are grabbing the config returning all of the values that are already in it?
     
  3. Offline

    acer5999

    Already tried and no, it just overwrites
     
  4. Offline

    Skionz

    acer5999 I mean out print the data you grab from the config before adding a new value to it.
     
  5. Offline

    acer5999

    Also tried, it outputs
    Code:
    [e6b31860-846f-4325-adc9-b03d120e5410 -476.0 66.0 579.0 0.0 0.0]
    Then for every click on that block or another it outputs [ ]
    Edit: Skionz

    Never mind, it was my fault, I left a line in there that shouldn't have been that was overwriting it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
Thread Status:
Not open for further replies.

Share This Page