Solved Listing in Config

Discussion in 'Plugin Development' started by Markyroson, May 28, 2015.

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

    Markyroson

    How do I add information (ie multiple player names) to the config.yml like the following within Java? I know how to setup the command (/list add <player>) but not sure how to get it into the config. Any ideas?

    Admin: Joe, Bob, Dave
     
  2. Offline

    Agentleader1

    Would you prefer something like this;

    Code:
    Admin:
      - Joe
      - Bob
      - Dave
    In what you said, it's simpler but less organized. Grab config.getString("Admin") then set it to what it's grabbed with the next added player;

    Code:
    String current = config.getString("Admin");
    config.set("Admin",current + ", nextPlayer");
     
  3. Offline

    Markyroson

    How would you do it in the per line way you mentioned?
     
  4. Offline

    Agentleader1

    @Markyroson
    I may be incorrect, but making a new List<string> then setting "Admin" in config to that list.
     
    Markyroson likes this.
  5. Offline

    xDeeKay

    Not sure if you've figured it out yet, but here's how I do it:
    Code:
    List<String> list = plugin.getConfig().getStringList("path");
    list.add(name);
    plugin.getConfig().set("path", list);
    plugin.saveConfig();
     
    Markyroson and 87pen like this.
  6. Offline

    Markyroson

    I am not on computer at moment or home for that matter (on mobile) so no haha. Won't be able to do it until this evening ;) Thanks!
     
Thread Status:
Not open for further replies.

Share This Page