Util Custom Config Creation - Simplest Way

Discussion in 'Resources' started by StarCastFilms, Jul 30, 2015.

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

    StarCastFilms

    Ok, So I set out to make the best Custom Config Utility I could and I hope you think I did.

    Here are some of the Pros to using this Utility over other ones.
    1. No Need For having an instance of JavaPlugin in every class that uses it.
    2. Only one instance of the Config will be made.
    3. Everything is in one class. No need to add methods anywhere else to make it work.
    It's AMAZING!!

    There are two versions. One is player based and the other is name based.

    Versions:
    Player Based
    Name Based

    Basic Usage Example: HERE

    To create a custom config do:

    Code:
    ConfigManager cm = ConfigManager.getConfig(Player); //Player Based Way
    ConfigManager cc = ConfigManager.getConfig(UUID); //Player Based Way
    Config c = Config.getConfig(String); //Name Based Way
    
    cm.getConfig(); //Gets the config so u can do .set()
    c.getConfig(); //Same as above
    

    All the methods are described in great detail. (Hover over the method) So, please don't ask what it does.

    Here is a video on it and it explains how to use most of the methods. Pleas Note that I have further updated the class since the making of the video.



    Any problems with this please post. And I will get to fixing it as soon as possible.
     
    Last edited: Sep 3, 2015
  2. Online

    timtower Moderator Moderator

    @StarCastFilms Using statics for this isn't the best practice out there.
    What if 2 plugins use this?
     
  3. Offline

    StarCastFilms

    @timtower Each plugin should use it's own version of the Class. And if they were using it from another plugin they would be trying to get a config from within that JavaPlugin of that plugin. Did that make sense?
     
    Last edited: Jul 30, 2015
  4. Offline

    meguy26

    @StarCastFilms
    See if I had seen this tutorial I would never have written my own config file format, parser, and structure...
    ;)
     
  5. Offline

    StarCastFilms

    Haha, Well I guess you enjoy it? @meguy26
     
  6. Offline

    rbrick

    Instead of doing this:
    Code:
    private static final JavaPlugin plugin = (JavaPlugin) Bukkit.getPluginManager().getPlugin("PlayerConfig");
    You can simply do:
    Code:
     JavaPlugin.getProvidingPlugin(this.getClass());
    This will get the plugin that the class was loaded with. (or as the JavaDocs puts it "This method provides fast access to the plugin that has provided the given class.")
     
  7. Offline

    StarCastFilms

    @rbrick thanks! I never knew that existed and now that I tested it. I've updated it!
     
Thread Status:
Not open for further replies.

Share This Page