Config file without predefined settings

Discussion in 'Plugin Development' started by Tster, Aug 7, 2011.

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

    Tster

    I want a config file where admins can list players, and the onEnable() will put them in a hashmap,
    thanks Tster,
     
  2. Offline

    Warpdrive

    Why not just use a text file and then onEnable use a Scanner to retrieve each line from the file and add them to the HashMap
     
  3. Offline

    IcySeal

    @Warpdrive - Because that can get real messy real fast.
     
  4. Offline

    Warpdrive

  5. Offline

    EdTheLoon

    Use the built in Configuration API to load a stringlist from a config.

    For example:

    Code:
    private File configFile = new File("plugins/PluginFolder" + File.separator + "config.yml");
    private Configuration config = new Configuration(configFile);
    public List<String> names; // To store the list of names
    config.load(); // Load the config
    names = config.getStringList("names", null); // Retrieve the list of names from the config file
    And then iterate through the names, adding each to the hashmap

    Example config:
    Code:
    names:
        - James
        - Ed
        - Jimmy
     
  6. Offline

    Tster

    Other topic:

    So lets say I wanted my config file to be:
    class: - Chance: - Hp:
    What would my code be, write a property class to null, and write an indented property to chance?
     
Thread Status:
Not open for further replies.

Share This Page