Solved Getting a list from config.

Discussion in 'Plugin Development' started by CraZy_, Jul 30, 2020.

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

    CraZy_

    So , i have a problem with getting a list from config.

    I'm trying to get this:
    (my config file)
    Code:
    arenas:
      arena1:
        name: arena1
        status: unready
        spawn1: none
        spawn2: none
        arena_location: none
      arena2:
        name: arena2
        status: unready
        spawn1: none
        spawn2: none
        arena_location: none
    
    And im trying to achieve that by something like:
    (i want to read only these "arena1" and "arena2" as strings, in this example i reading only count of the list but it's not changes anything because it's not work)
    Code:
                
    List<String> s = config.getStringList("arenas");
                                int count = s.size();
                                sender.sendMessage(ChatColor.GREEN +"arenas count: " + count);
    But i always getting the count is 0. Propably because the "arena1" and "arena2" are not strings but some kind of objects. But also that way of thinking didnt help me manage to get these values.
     
    Last edited: Jul 30, 2020
  2. Offline

    Seyviyer

    Because they are not a string list. They are keys of the arenas section. So try getKeys() from it.
     
    CraZy_ likes this.
  3. Offline

    CraZy_

    Thanks a lot! :D
     
Thread Status:
Not open for further replies.

Share This Page