Organizing my plugin (config file etc)

Discussion in 'Plugin Development' started by zajacmp3, Jun 21, 2012.

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



    I just made a plugin for myself. It will be only for me so I don't really need to make any changes now, but if I ever publish something I would like to know.

    Where should I locate configuration file for my plugin.
    Could it be inserted into ? Is it appropriate?
    Or should I make a folder in plugins named after my plugin and there insert a config file and all other needed files?
  2. Offline


    you should use JavaPlugin.getConfig(), JavaPlugin.saveConfig(), JavaPlugin.loadConfig()
  3. Offline


    If you are using the methods given by Bukkit to make a config file, then what i will do is make a folder inside the plugins folder, and that folder will be called the same name as your plugin. So if you plugin has any other files that it has, such as a file used for data storage then put them in that folder.

    To make the config file using the methods Bukkit provide, you should use this in your main class which extends JavaPlugin:

    public void onEnable(){
      FileConfiguration config = this.getConfig();
      config.addDefault("path.subpath", "derp");
    To find this folder, then you can use the following method which is accessable in your main class which extends JavaPlugin.

    File file = new File(getDataFolder(), "file.yml");

    Using the getDataFolder method is preferable because 1) if the plugins were located somewhere else it would still work. 2) It prevents mistakes when hard coding the path.
  4. Offline


    Thanks for the intel :)


    I got it right, and it is working!
Thread Status:
Not open for further replies.

Share This Page