Solved Config only generating half

Discussion in 'Spigot Plugin Development' started by Arjan, Aug 10, 2015.

  1. Hello,

    So I have a default configuration set up in my eclipse and whenever I run my plugin the config only generates a little bit of the default config. And not just to the middle, but some of the top and some of the bottom.
    I'm simply using:
    Code (Text):

    getConfig().options().copyDefaults(true);
    saveConfig();
    What do I miss?

    -Arjan
     
  2. What is your config.yml looking like in your IDE ?
     
  3. IDE:
    Code (Text):

    # Welcome
    # Everything is carefully explained as some configurations are a bit tricky to do properly. If you need support or
    # assistance setting up your configuration, feel free to post a reply or send me (Arjan) a private message.

    ## Usage: true/false
    Enabled: true

    # Loot is seperated into different tiers. Put the amount of tiers you want to have below.
    ## Usage: 1/2/3...
    Tiers: 3

    # All tiers have different colors so you can identify them a bit easier. For every tier you want, pick a color.
    # NOTE: These are colors for the panes, NOT chat colors!
    # Available colors are: WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, GRAY, LIGHT_GRAY, CYAN, PURPLE, BLUE,
    # BROWN, GREEN, RED and BLACK.
    ## For the usage, see the default example(s) below. This should be exactly the same for every tier you have.
    Tier:
        1:
            Color: RED
        2:
            Color: GREEN
        3:
            Color: BLUE

    # You can add as many lootchest types as you like.
    # The chance is the chance in percentage for a tier to spawn in a slot. In the example below, tier one has a 75 percent
    # chance to spawn and tier two a 25 percent chance.
    # NOTE: It should ALWAYS make a full 100 procent.
    ## For the usage, see the default example(s) below. This should be exactly the same for every chest you have.
    LootChest:
        1:
            Name: "Mister Default"
            Tiers: 1,2
            Chances: 75,25
        2:
            Name: "Epicness"
            Tiers: 3
            Chances: 100

    # Now that we have all tiers and chests set up, we're going to move on to the part where we decide what items are rewarded.
    # For a list of accurate item ID's, visit http://minecraft-ids.grahamedgecombe.com/
    # If an item requires an additional number (data value) then use a colon to let the plugin know. The quantity is used to tell the plugin
    # how many of a specific item should be awarded.
    # In this example we have: Glass, Sticky Piston, Red Wool, Gold Block, Furnace, Anvil, Iron Sword, Golden Shovel and a Diamond Chestplate.
    ## For the usage, see the default example(s) below. This should be exactly the same for every chest you have.
    LootChest:
        1:
            Items: 20,29,35:14,41,61,145,267,284,311
            Quantity: 10,2,64,1,2,1,1,1,1
    LootChest:
        2:
            Items: 20,29,35:14,41,61,145,267,284,311
            Quantity: 10,2,64,1,2,1,1,1,1
     
    And the file will look like this:
    Code (Text):

    # Welcome
    # Everything is carefully explained as some configurations are a bit tricky to do properly. If you need support or
    # assistance setting up your configuration, feel free to post a reply or send me (ArjanforGames) a private message.
    #
    Enabled: true
    Tiers: 3
    Tier:
      '1':
        Color: RED
      '2':
        Color: GREEN
      '3':
        Color: BLUE
    LootChest:
      '2':
        Items: 20,29,35:14,41,61,145,267,284,311
        Quantity: 10,2,64,1,2,1,1,1,1

     
     
  4. You are always using the same path LootChest, that will bugg.

    EDIT: And don't use tabs in your yml file.
     
    • Useful Useful x 1
  5. Alright, changed some things so the paths are no longer interfering, although now the commented parts are no longer showing.
    The last commented line generated is '# Do you want LootCrate to be enabled?'.
     
  6. Comments do not stay using the default config methods in Bukkit, only the header. If you want to add all comments, create a config util, or use one that exists already.
     
    • Informative Informative x 1
  7. Thanks both for the help. I'll have a look at some utils out there.

    -Solved
     
  8. Just to post the solution here.
    Replace
    Code (Text):

    getConfig().options().copyDefaults(true);
    saveConfig();
     
    with
    Code (Text):

    saveDefaultConfig();
     
    Comments will now be properly generated!
     
    • Like Like x 1
  9. If I remember correctly, then using saveConfig(); or anything like that will then remove the comments. I had to modify a util to properly get all comments to stay.