Checking Config

Discussion in 'Plugin Development' started by lionkingist, Aug 2, 2014.

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

    lionkingist

    I have a config file set up like this below. I was wondering if there was a way to check what group a player is in by having his name. This would also have to work if there is multiple groups with any name.
    Code:
    order:
        Group:
            players:
                -player
                -player2
                -player3
     
  2. Offline

    Gerov

    Make an ArrayList of that StringList, and then check if it contains the player's name?
     
  3. Offline

    lionkingist

    I found out how to do it i used a for loop. If anyone is wondering how i did it here is the code.

    Code:java
    1. public String getRank(Player player){
    2. for(String grank : config.getConfigurationSection("order").getKeys(false)){
    3. List<String> check = config.getStringList("order."+grank+".players");
    4. if(check.contains(player.getName())){
    5. return grank;
    6. }
    7. }
    8. return null;
    9.  
    10. }
     
Thread Status:
Not open for further replies.

Share This Page