Looping thru config file

Discussion in 'Spigot Plugin Development' started by EvanTheSurfer, May 24, 2016.

  1. Ok so i am making a bases plugin. Each person owns there own base. The format is shown below
    Code (Text):
    EvanOG:    //the owner
      hasBase: true
      height: 11
      width: 11
      length: 11
      x: 3526.0
      y: 90.0
      z: 143.0
      baseSpawn:
        X: 3531.0
        Y: 91.0
        Z: 148.0
      addedPlayers: []
    FireTaco156:   //the owner
      hasBase: true
      height: 11
      width: 11
      length: 11
      x: 678.0
      y: 90.0
      z: 3345.0
      baseSpawn:
        X: 3831.0
        Y: 91.0
        Z: 1548.0
      addedPlayers: []
    When the player type /base list, i want it to return the names of the owners of the bases they are added to. So in that case, i need to loop thru each individual section right? Thanks for anyhelp .
     
  2. To loop through the sections, you can use configurationInstance.getKeys(false). Replace configurationInstance with the FileConfiguration you are using to fetch the data. That will return the keys as Strings (ex. EvanOG etc)
     
    • Agree Agree x 1