Search code examples
yamlconfigminecraftbukkit

plugin Config wont load correctly


I'm running a two plugins on spigot 1.8.9 called minigameslib and openskywars. To set up the randomizing of chests its required to setup a config

# Just copy paste if you want more chests. The percentages must add up to 100!
config:
  enabled: true
  chests:
    chest1:
      items: 5*64;5*64;5*64;5*64;262*64;278*1;5*64%30
      percentage: 5
    chest2:
      items: 5*64;262*64;267*1
      percentage: 20
    chest3:
      items: 5*64;262*64
      percentage: 25
    chest4:
      items: 5*64
      percentage: 50

Thats the default config file. It's named chests.yml

I'm atttempting to change the file to contain the following:

# Just copy paste if you want more chests. The percentages must add up to 100!
config:
  enabled: true
  chests:
chest1:
  items:298*1;303*1;304*1;301*1;276*1;3*64;1*64;368*2;262*16;322*4;
  percentage: 4
chest2:
  items:298*1;315*1;300*1;317*1;367*1;3*64;1*64;322*4;364*12
  percentage: 4
chest3:
  items:298*1;299*1;312*1;305*1;272*1;1*64;79*1;261:3#ARROW_DAMAGE*1
  percentage: 4
chest4:
  items:298*1;307*1;308*1;309*1;272*1;3*64;261*1;364*12
  percentage: 4
chest5:
  items:298*1;311*1;316*1;313*1;283*1;1*64;326*1;262*16
  percentage: 4
chest6:
  items:302*1;315*1;312*1;301*1;272*1;33:5#KNOCKBACK*1
  percentage: 4
chest7:
  items:302*1;299*1;304*1;309*1;272*1;3*64;79*1;364*12
  percentage: 4
chest8:
  items:302*1;303*1;316*1;313*1;283*1;1*64;261:5#ARROW_DAMAGE*1;364*12
  percentage: 4
chest9:
  items:302*1;311*1;308*1;305*1;367*1;3*64;79*1;368*5;33:
  percentage: 4
chest10:
  items:302*1;307*1;300*1;317*1;276*1;1*64;326*1;262*16;364*12
  percentage: 4
chest11:
  items:306*1;299*1;316*1;309*1;283*1;3*64;322*4
  percentage: 4
chest12:
 items:306*1;307*1;308*1;301*1;272*1;3*64;262*16;261:1#ARROW_DAMAGE*1;364*12
  percentage: 4
chest13:
  items:306*1;303*1;312*1;313*1;276*1;1*64;326*1
  percentage: 4
chest14:
  items:306*1;315*1;304*1;305*1;367*1;3*64;368*1
  percentage: 4
chest15:
  items:306*1;311*1;300*1;317*1;272*1;322*4
  percentage: 4
chest16:
  items:310*1;307*1;316*1;301*1;276*1;261*1
  percentage: 4
chest17:
  items:310*1;311*1;304*1;309*1;272*1;3*64;261:1#ARROW_DAMAGE*1
  percentage: 4
chest18:
  items:310*1;315*1;312*1;305*1;283*1;262*16;322*4;364*12
  percentage: 4
chest19:
  items:310*1;303*1;308*1;317*1;367*1;3*64;79*1
  percentage: 4
chest20:
  items:310*1;299*1;300*1;313*1;272*1;1*64;364*12
  percentage: 4
chest21:
  items:314*1;303*1;312*1;317*1;367*1;3*64;368*2;33:5#KNOCKBACK*1;364*12
  percentage: 4
chest22:
  items:314*1;307*1;316*1;305*1;283*1;326*1;364*12
  percentage: 4
chest23:
  items:314*1;311*1;300*1;301*1;276*1;1*64;261:1#ARROW_DAMAGE*1
  percentage: 4
chest24:
  items:314*1;299*1;304*1;313*1;272*1;3*64;262*16;364*12
  percentage: 4
chest25:
  items:314*1;315*1;308*1;309*1;272*1;79*1;261*1;322*4
  percentage: 4

Im not sure if my syntax for yml files is wrong or the item ids are wrong. The enchanting ids are Here, and the plugin page is here. The program resets back to the original config every time its run, making small changes and its fine. I would like to get this long list working if I can.

I hope you have more like than I do. Thanks in advance.


Solution

  • A yaml file needs a space after the colon. Also indentation is dictative for what object belongs to what. You made chests a top level opbject

    You have

    # Just copy paste if you want more chests. The percentages must add up to 100!
    config:
      enabled: true
      chests:
    chest1:
      items:298*1;303*1;304*1;301*1;276*1;3*64;1*64;368*2;262*16;322*4;
      percentage: 4
    

    it should be

    # Just copy paste if you want more chests. The percentages must add up to 100!
    # top level. no spaces
    config:
    # secondary, two spaces. Could also be one space. 
    # All following secondary level elements need to have the equal amount of spaces
      enabled: true
    # secondary two spaces
      chests:
    # Tertiary: 4 spaces. All following tertiary elements under this secondary 
    # element need to have 4 spaces.
        chest1:
    # Quaternary element. 6 spaces. All following  quaternary elements under this
    # tertiary element needs to have 6 spaces
    # Also note the space after the colon: Yaml needs this to discern where the
    # variable starts
          items: 298*1;303*1;304*1;301*1;276*1;3*64;1*64;368*2;262*16;322*4;
          percentage: 4
    

    Without clarifying comments

    # Just copy paste if you want more chests. The percentages must add up to 100!
    config:
      enabled: true
    
      chests:
        chest1:
          items: 298*1;303*1;304*1;301*1;276*1;3*64;1*64;368*2;262*16;322*4;
          percentage: 4