Loop throught config file

Imagine i have this config file:

Games {

1 {  #id
	name="blabla1"
	
	teams {
		id {
			name="SeiLaTeam1"
			color="RED"
		}
		
		id {
			name="SeiLaTeam2"
			color="BLUE"
		}
	}
	
	spawn {
		world="world"
		x=0
		y=100
		z=0
	}
	
}

2 {  #id
	name="blabla2"
	
	teams {
		id {
			name="blabla2Team1"
			color="RED"
		}
		
		id {
			name="blabla2Team2"
			color="BLUE"
		}
	}
	
	spawn {
		world="world"
		x=0
		y=100
		z=0
	}
	
}

And i don’t know how much ids (#id) it has or either what would be those ids, how could i do loop throught the “Games” array?

I imagined something like this:

for(ConfigurationNode c : node.getNode("Games")."getListsInside()"){ // Do stuff }

What would be that “getListsInside()”?

Use .getChildrenList() or .getChildrenMap() ^^

1 Like

Expanding on that a bit, getChildrenList() is for if you have this

foo = [
  {
    x = 1
    y = 3
  }
  {
    x = 9
    y = 23
  }
]

and getChildrenMap() is if you have this

foo {
  unknownName {
    x = 9
    y = 3
  }
  unknownOtherName {
    x = 23
    y = 288
  }
}
1 Like