[CLASS] Easy custom configuration class

Discussion in 'Resources' started by Zeelia, Mar 22, 2012.

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


    Hello everyone!
    I'm not sure if I'm posting this on the correct sub forum so please move it to the appropriate place.

    I have just assembled an easy-to-use class which implements custom configuration files.
    It's just a quick and easy compilation of the tutorial/information on the wiki.
    It's compatible with the new configuration system and Bukkit version 1.2.3.

    To use it, simply replace the clsMain with whatever name your main class has (the class which extends JavaPlugin).

    private clsConfiguration config = null;
    public void onEnable(){
        config = new clsConfiguration(this, "custom.yml");
        //config.GetConfig(); //Create the config file
        //config.SaveConfig(); //Write settings in memory to the config file
    Attachment: clsConfiguration.txt

    I hope this helps you! It's nothing difficult but if you have troubles creating custom config files or just want to save some time, this class is really easy to use.

    Attached Files:

    mrZcr4fter and Tauryuu like this.
  2. Offline


  3. Offline


    Moved to Resources!
  4. Offline


    Does this have support for Comments?
    Like, if I have comments in my settings file, and I edit some data in it, does it keep the comments? (The bukkit API doesn't)
  5. Offline


    It's based on bukkit's API, I would say it's merely a framework of the bukkit API.
    And as such, it would NOT keep the comments, since bukkit does not.

    I would guess it's because bukkit write the file from scratch every time it wants to save the file, thus deleting anything that has been edited from outside the API. But this is just my guess.
  6. Offline


    Zeelia Do I have to place this class within each file I need to access the config from?

    I couldn't access this class from non-main files. ._.

    EDIT: I was being stupid. nvm ._.
  7. This looks like you are just taking bukkits code, and giving them different names...
    I think this should be removed because people should just use the Bukkit API instead of a cheap copy.
  8. Offline


    This is a class to easily make, access, and change config files without copying that chunk of code for each file. It's a wrapper for the Bukkit API.

    If you have no idea about what you're talking about, don't say it.
    bobacadodl likes this.
  9. Im just saying, its better to learn the bukkit config. Not saying the code isn't good or anything, i just think new coders would be better off with the bukkit code. :)
  10. Offline



    I have a couple of questions in regards to proper use and or practice of the configuration class.

    If I wanted to use the same config in other classes, what would be the proper way to do so? Would it be wrong/improper to declare the config as public in the main class?

    And related to the question above... if, as shown in the example, the config is declared as private, would using config = new clsConfiguration(this, "custom.yml"); multiple times open multiple instances of the config file into memory or would it just overwrite the existing config in memory

    Just want to avoid repetitive code and/or wasting memory... and, as always be a task master to myself to learn good habits! ;)

    As always... thanks for any guidance given!
  11. Offline


    THANKS! I wanted this so bad! I was kind of too lazy to make it myself, THANK YOU SO MUCH!!
Thread Status:
Not open for further replies.

Share This Page