Discussion in 'Plugin Development' started by edocsyl, Dec 15, 2011.

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


    Alright, my specialty.
    Just kidding... What you need to have in order to change the configuration file is a
    reference to your JavaPlugin subclass. Like this:

    Code (Text):
    1. JavaPlugin myPlugin = [...];
    Now in the JavaPlugin class, there's two methods you basically need to focus on.
    That is:

    Code (Text):
    1. myPlugin.getConfig();
    2. myPlugin.saveConfig();
    saveConfig() obviously saves the config. You should call this either after you have
    made an adjustment or in general when the onDisable() method of your plugin is called.
    getConfig() returns a FileConfiguration (see, which you can call methods on.
    That FileConfiguration is either loaded from your config.yml or if that doesn't exist, a new one is created.
    saveConfig() by the way saves to that exact same file, like you might have figured.

    It's actually quite simple. Check the API documentation (the link I posted above)
    for more information about the use of and methods within the FileConfiguration class.

    Have fun, and keep in mind that this should only be used for preferences and in general
    things the server admin should have direct access to. Not more. For example using this technique for saving blocks
    (which would also be very complicated) is a waste of your time and resources.

    Another way to save stuff would be a database, or this:
    You should generally know this tutorial in it's entirety.

    I hope I could help.
Thread Status:
Not open for further replies.

Share This Page