Solved config problem lol ty

Discussion in 'Plugin Development' started by DogeDebugger, Jul 14, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    DogeDebugger

    ok i have this in file, which is a bunch of locations. for simplicity they r all the same but they can be anything
    Code:
    whales:
      spawn1: quake, -38, 68, 270
      spawn2: quake, -38, 68, 270
      spawn3: quake, -38, 68, 270
      spawn4: quake, -38, 68, 270
    
    and i want to loop through all the spawns (spawn 1, 2, 3, 4).

    im sure i've done this before but i don't remember and it's killing me :mad:thanks for any help!
     
  2. Offline

    SuperSniper

    Possibly create a new random, and make the highest number 4, then do stuff for each number.

    if(random == 1) {
    //do stuff
    if(random ==2) {
    //do stuff
    etc. etc.
     
  3. He wants to loop through all spawns and not selecting a random one. And this could be way more efficient like this:
    Code:
    String str = getConfig().getString("whales.spawn" + (random.nextInt(4) + 1));
    ^^
    How you actually loop through the configuration section:
    Code:
    for (String key : getConfig().getConfigurationSection("whales").getKeys(false)) {
    // key will be "spawn1", "spawn2" etc.
    }
     
  4. Offline

    DogeDebugger

    never mind lol fixed
     
Thread Status:
Not open for further replies.

Share This Page