How to check if the config.yml exists

Discussion in 'Plugin Development' started by flevas, Jan 6, 2014.

Thread Status:
Not open for further replies.
  1. How can you check if the config.yml exists?
    I'm using
    Code:java
    1. File config = new File("/Reporter/config.yml");
    2. if(config.exists()){ System.out.println(this + "configuration file has been loaded!"); }
    3. else { System.out.println(this + " can't load the config! This will cause problems!"); }

    But the path seems to not working. Any other method?
     
  2. Create the file with the datafolder as the parent and it will be correct.
    Code:
    new File(<plugin_main>.getDataFolder(), "config.yml");
     
  3. Offline

    metalhedd

    normally, you don't. you just call saveDefaultConfig() which will copy the config.yml from inside your plugin jar and place it in ./plugins/<PluginName>/config.yml from that point on you access it with getConfig()
     
Thread Status:
Not open for further replies.

Share This Page