Config

Discussion in 'Plugin Development' started by RoxioCZ, Feb 23, 2019.

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

    RoxioCZ

    Hi,
    I want my plugin to create message_en.yml inside Languages folder(also created by the same plugin) and have premade messages there that would be ready to call every time I need them.
     
  2. Offline

    timtower Administrator Administrator Moderator

    @RoxioCZ And what part do you need help with then?
     
    RoxioCZ likes this.
  3. Offline

    RoxioCZ

    Emm, I'm kinda able to work with the default config but I hev no idea how to work with the custom one(creating, accesing, etc..).
     
  4. Offline

    Colinus999

    Here are some code snippets that might help you:

    Opening a YAML config (open)

    Code:
    File configFile = new File(myPlugin.getDataFolder());
    YamlConfiguration conf = YamlConfiguration.loadConfiguration(infoFile);
    try {
        conf.load(infoFile);
    } catch(IOException e) {
        // Error when loading file
    } catch(InvalidConfigurationException e) {
        // Error when parsing YAML
    }

    Saving a YAML config (open)

    Code:
    try {
        conf.save(configFile);
    } catch(IOException e) {
        // Error while writing to file
    }

    Reading from this is the same as reading the regular YAML config.
     
    Chr0mosom3 likes this.
  5. Offline

    Chr0mosom3

    @RoxioCZ, thread solved or do you need help with something more?
     
  6. Offline

    RoxioCZ

    Im ok, I think u can lock this thread. Thanks
     
Thread Status:
Not open for further replies.

Share This Page