Solved Dynamic Configuration Getting

Discussion in 'Plugin Development' started by Birdgeek3, May 5, 2014.

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

    Birdgeek3

    Hey there,

    I am working on a plugin that works with zones and I want the number of zones to be customisable depending on the desired amount. So far in the config I have
    Code:
    affectedMobs:
    - CREEPER
    - SKELETON
    zones:
      zone1:
        range: 500
        attributes:
        - DAMAGE_RESISTANCE
        - INVISIBILITY
      zone2:
        range: 1500
      zone3:
        range: 2500
    
    Is there any way that I can get the number of zones? something like
    Code:
    getConfig().getSubAmount("zones");
    
    In this example, it would return 3 since there are 3 zones listed under zone ("zone1, zone2, zone3")
    I am looking for a numerical value that will tell the code how many zones the user has configured that way the code can change in a dynamic way.

    Thanks.
     
  2. Offline

    xTigerRebornx

    Birdgeek3 you can use ConfigurationSection#getKeys() then get the length of that.
     
  3. Offline

    JungleSociety

    Birdgeek3
    I usually just take the objects in the list and put them into a list, then list.getSize() will return the size.
     
  4. Offline

    Birdgeek3

    This worked perfectly! Thank you very much!
     
Thread Status:
Not open for further replies.

Share This Page