Solved More Config Files

Discussion in 'Plugin Help/Development/Requests' started by phil14052, Mar 26, 2015.

Thread Status:
Not open for further replies.
  1. Hi
    I just want to know what way is the best way to make more config files like "Config.yml, PlayerData.yml and Reasons.yml"
    And if you can then can i just edit the files and with no need to use code to put the lines (If you can say that)?
    And at last can you guys come with examples?

    //Phil14052
     
  2. Offline

    TeddyDev

    This is the method i usually use,


    Code:
        private static File file;
        private static FileConfiguration cfg;
    
        public static void loadConfig() {
            file = new File(<MAIN CLASS>.getDataFolder() + "/" + "PlayerData.yml");
            cfg = YamlConfiguration.loadConfiguration(file);
        }
    
        public static void saveConfig() {
            try {
                cfg.save(file);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        public static FileConfiguration getConfig() {
            return cfg;
        }
    INFO:
    To get the config and get/set variables, use: CLASS.getConfig()
     
  3. Offline

    nverdier

    @phil14052 I have a library, "EnviousAPI", and it has a Config class. You can easily create many configs with it. Link is in signature, or here.
     
  4. @nverdier Looks nice but i cant find the download link?
     
  5. @phil14052 Bottom of the page > GitHub link > Download ZIP

    But GitHub is currently down so you will have to wait.
     
  6. Offline

    nverdier

  7. @bwfcwalshy So i get a zip. So how should i put that into the plugin?
    Kinda new with library's

    Guys i found out how to use it Thxs!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page