Solved Help with custom yml

Discussion in 'Plugin Development' started by johnny boy, Feb 17, 2017.

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

    johnny boy

    So I have this bit of code here:
    Code:Java
    1.  
    2. File errorFile = new File(this.getDataFolder(), "error.yml");
    3. FileConfiguration errorLog = YamlConfiguration.loadConfiguration(errorFile);


    And when I try and do errorLog.saveConfig(); it does not work. No error messages just nothing shows up. I haven't ever used custom configs until now, so maybe saving is different??

    EDIT:

    Would it be this:
    Code:Java
    1.  
    2. try {
    3. errorLog.save("error.yml");
    4. } catch (IOException e) {
    5. e.printStackTrace();
    6. }
     
    Last edited by a moderator: Feb 17, 2017
  2. Offline

    Zombie_Striker

    @MemeplexOwner
    Are you setting any values in the config? Are you sure the file exists? What do you mean by "does not work"?
     
  3. Offline

    johnny boy

    @Zombie_Striker I think I got it. Is it this:
    Code:Java
    1.  
    2. try {
    3. errorLog.save("error.yml");
    4. } catch (IOException e) {
    5. e.printStackTrace();
    6. }
     
  4. @MemeplexOwner
    You are forgetting to include the path to the plugin's data folder. Just pass the file just like you did when loading it.
     
  5. Offline

    johnny boy

    this.getDataFolder()??
     
    ipodtouch0218 likes this.
  6. @MemeplexOwner
    Yes, create a new File object just like you did when loading the config.
     
  7. Offline

    johnny boy

    Got it. This is the finished result.
    Code:Java
    1.  
    2. errorLog.save(getDataFolder() + File.separator + "error.yml");
    3.  


    You can't do
    Code:Java
    1.  
    2. errorLog.save(getDataFolder(), "error.yml");
    3.  


    And I'm gonna figure out why now.

    EDIT: Cause "," is not a slash... XD Marking thread as solved.
     
    Last edited by a moderator: Feb 17, 2017
Thread Status:
Not open for further replies.

Share This Page