Config List Help

Discussion in 'Plugin Development' started by CoolGuy2001, Aug 18, 2014.

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

    CoolGuy2001

    Hello! I am creating a plugin, and I have created two config sections on a command! I am trying to make it so the second one has a list inside of it! Here is the code I have:

    Code:
    if(args[0].equalsIgnoreCase("create"))
                        {
                            String teamName = args[1];
                            getConfig().createSection(teamName);
                            getConfig().createSection(teamName + ".players");
                            List<String> players = (List<String>) getConfig().getStringList(teamName + ".players");
                            players.add(p.getName());
                            saveConfig();
                        }
    I am not getting an error but the config just makes this:
    Code:
    testTeam:
        players: {}
    It does not make a list with the players name in it, as I need it to. Thanks for looking at this, and I would really appreciate some help! :)
     
  2. Offline

    Forseth11

    Try removing:
    Code:java
    1. getConfig().createSection(teamName);
    2. getConfig().createSection(teamName + ".players");
     
  3. Offline

    Totom3

    Forseth11 Doing this will completely delete the section

    CoolGuy2001 You have to create your List<String> and add the name of the player in it. Then you set it in the config :

    Code:java
    1. List<String> list= new ArrayList();
    2. list.add(p.getName());
    3. getConfig().set(teamName + ".players", list);
     
  4. Offline

    Forseth11

    Totom3 oh I thought he was using:
    Code:java
    1. getConfig().set(teamName + ".players", list);

    My bad.
     
Thread Status:
Not open for further replies.

Share This Page