3 blank lines in a new custom configuration

Discussion in 'Plugin Development' started by The Zombie Blarger, Jan 14, 2012.

Thread Status:
Not open for further replies.
  1. Im having an issue dealing with my custom configurations.

    See, when i create a new file, it works fine. However, when i save it using config.save(file); it always had three blank lines. Now this wouldnt particularly be as annoying of a problem as it is, but somehow, whenever those lines do exist, and i save using config.save(file);, it creates more lines.

    The interesting thing about that, is if i manually delete those blank lines, and go about saving and loading and whatever, its fine. No new lines are created... Its really puzzling, and i was wondering if anyone out there knows how to fix this?

    heres a bit of test code that creates the config with extra lines, in case i did something wrong

    1. public class Test {
    2. TestPlugin instance;
    3. Player player;
    4. FileConfiguration config;
    5. public Test(TestPlugin instance, Player player){
    6. this.instance = instance;
    7. this.player = player;
    8. }
    9. public void test(){
    10. File file = new File(instance.getDataFolder()+"\\derp.yml");
    11. try {
    12. file.createNewFile();
    13. instance.log.info("creating new file");
    14. } catch (IOException e) {
    15. e.printStackTrace();
    16. }
    17. config = YamlConfiguration.loadConfiguration(file);
    18. try {
    19. config.save(file);
    20. } catch (IOException e) {
    21. e.printStackTrace();
    22. }
    23. }
    24. }
  2. Offline


    File file = new File(instance.getDataFolder()+"/derp.yml");
  3. no dice. and no offense, but isnt / the escape character? i didnt expect this to work :x
  4. Offline


    Backslash (\) is the escape character, but I'm not surprised if that doesn't work. Use the constructor File(File dir, String filename) instead, e.g.:
    File file = new File(plugin.getDataFolder(), "derp.yml");

    Anyway, the extra lines you seem to be getting is a known issue, I think. Well, at least I know about it! It only happens on Windows for some reason, and I think there is a pull request, or at least a bug report for it.
    Andrew McWatters likes this.
  5. Offline

    Sagacious_Zed Bukkit Docs

  6. yes, i am. wonderful news though, thanks :3

    as with my server, i typically don't like to use non recommended builds for the actual coding, so that's why
Thread Status:
Not open for further replies.

Share This Page