2nd config file not working

Discussion in 'Plugin Development' started by Pitazzo, Aug 12, 2014.

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

    Pitazzo

    Hi guys,
    I've decided to create a second configuration file for my plugin in order to store some data about the users of my server.
    I'd like to store it in the following format:
    players.yml​
    Code:
    Pitazzo:
      - Bastiv|James Smith
      - Retro|Loius Clarck
    Touretes:
      - Bastiv|Agent X
      - Elien|Mr. Y
      - Pitazzo|Henry
    The point, in order to do that, and as far as I know, would be this:
    First, create the file jugadores.yml if it doesn't exist and make it accesible with the Bukkit Config API
    Code:java
    1. public File jugadores;
    2. public static FileConfiguration JugadoresConfig;
    3.  
    4.  
    5. public void loadJugadoresFile() {
    6. jugadores = new File(getDataFolder(), "jugadores.yml");
    7. if (!jugadores.exists()) {
    8. try {
    9. jugadores.createNewFile();
    10. } catch (IOException e) {
    11. e.printStackTrace();
    12. }
    13. }
    14. JugadoresConfig = YamlConfiguration.loadConfiguration(jugadores);
    15. }


    And then just accesing it:

    1. In case the player wasn't in the file yet:
    Code:java
    1. List<String> conocidos = new ArrayList<String>();
    2. conocidos.add("Bastiv|Agente X");
    3. Main.JugadoresConfig.set(player.getName(), conocidos);


    2. In case it already was:
    Code:java
    1. List<String> conocidos = (List<String>) Main.JugadoresConfig.getList(player.getName());
    2. conocidos.add("Bastiv|agent X");
    3. Main.JugadoresConfig.set(player.getName(), conocidos);


    But for some reason, when I try to add some new text to the config it doesn't work, without any error. Moreover, I'm able to read the existant strinngs in the list.

    Any help will be appreciated
     
  2. Offline

    _LB

    Do you ever tell the config to save to the file?
     
Thread Status:
Not open for further replies.

Share This Page