[UNSOLVED] FileConfiguration creating white space

Discussion in 'Plugin Development' started by Lathanael, Oct 29, 2011.

Thread Status:
Not open for further replies.
  1. Hi fellow plugin devs!

    I'm currently creating a Plugin to this request. As i need to store information for each player in some way and SQL is not used(maybe later) i decided to use the yml flatfile.
    I create a file with the defaults when a player joins the server or load the file, if there already is one.

    Now if take a look into the new created file, it has several blank lines at the beginning. THe amount equals the amount of total keys stored in the file (i.e. : for each Key-Value pair there is a blank line, Lists count as one pair!)
    And it gets even worse. Each time i save the file to store changes made to the player information it creates even more blank lines.

    Now has any of you experienced the same thing and knows how i can get rid of this annoying "feature"? (Best without creating and using Stream to remove the blanks from the file!)

    cheers
    Lathanael

    PS: You can find the current code on GitHub. (I know some parts a terrible!)
     
  2. Ahhh you decided to develop it in the open :D I may clone and help dev if I get time :p back on topic errrr I haven't experienced that so I'll have a quick look through but I'm curious as to why it's annoying? lol
     
  3. Offline

    DDoS

    Yes I have the same problem with yaml files I use to store player data, I believe it's just a bug, at least it doesn't affect data input, it's probably only a bit annoying for the people editing or viewing the files.
     
  4. DDoS said it. It is uncomfortable to view/edit the data by hand. The internal loading and saving works fine, but if you need to edit something because a user made a mistake or something else went wrong you have to find the lines first because of unneeded garbish in the file! (And even blank lines take up Diskspace which makes the thing worse)
     
  5. Ahhh right there is that but as I've said I haven't had any problems but I don't use it to store player data. Maybe it's the way you do it or maybe it's the data your storing that has a buggy output? This is a typical config for my SpoutBroadcast plugin:
    Code:
    broadcast:
      interval: 60
      defaultColour:
        red: 0
        green: 0
        blue: 255
    player:
      defaultColour:
        red: 255
        green: 0
        blue: 0
    global:
      interval: 60
      defaultColour:
        red: 0
        green: 0
        blue: 255
    colours:
      blue:
        r: 0
        g: 0
        b: 255
      red:
        r: 255
        g: 0
        b: 0
    And this is completely generated by my plugin (unless a user edits something obviously) but I don't use defaults in this plugin as I only recently found the new config API tutorial (I just guessed how to use it when it first came out :p). I haven't tried editing the data after it has been written to the yml file though so it may only be when editing data?
     
  6. Offline

    Qala

    Hi,

    i came across this when working on my own plugin.
    It's an unhandled edge case in the file parser when it reads the yml and tries to figure out where the header ends and the body begins. It only occurs when there is no header in the config file.

    I encountered this on 1.9pre, but the code seems to be the same in 1.8.1, so the bug could be in it, too. But i couldn't reproduce it there.

    I have pushed a fix for 1.9 here: https://github.com/Bukkit/Bukkit/pull/405

    Binary for testing (current HEAD with only my fix applied):
    http://tardis.qalanet.de/mc/20111107/craftbukkit-1.9-pre5-R1-SNAPSHOT.jar

    Could you try if this works for you?

    (edits: typos, added binary link, added 1.8.1 is not affected apparently)
     
  7. Thx will see if the bug is still existing and if it helps ;)
     
  8. Offline

    Qala

Thread Status:
Not open for further replies.

Share This Page