YAML file doesn't save

Discussion in 'Plugin Development' started by MgMaor, Apr 16, 2014.

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

    MgMaor

    Code:java
    1. public static void saveConfig(Player player) {
    2. File file = new File(folder.toString() + "/" + player.getName() + ".yml");
    3. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);;
    4. try {
    5. cfg.save(file);
    6. }
    7. catch (Exception e) {
    8. e.printStackTrace();
    9. }
    10. }
     
  2. Offline

    Shadowwolf97

    Perhaps it wont save the file if there is no content within the file?
     
  3. Offline

    Jozeth

    MgMaor
    Code:java
    1. try {
    2. if (!file.exists()) {
    3. try {
    4. file.createNewFile();
    5. } catch (IOException e) {
    6. e.printStackTrace();
    7. }
    That's if there's no file present.
     
Thread Status:
Not open for further replies.

Share This Page