API Reference Help

Discussion in 'Plugin Development' started by RenditionsRule, Feb 3, 2015.

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


    Hello BukkitDev Community. I am developing my own API to handle certain methods that would otherwise be a hassle for me and stumbled onto the fact that I need a Configuration reference to use in my external plugins. I just wanted to know if the following code would work to the standard I want...

    ConfigHandler.java Snippet:
        Plugin plugin = null;
        public ConfigHandler(Plugin p) {
            this.plugin = p
    BladeAPI.java Snippet:
    public static ConfigHandler config = new ConfigHandler(this);
    Now as you can see, In my BladeAPI class I am opening up a new instance of ConfigHandler and setting the 'plugin' variable of it to that class. I want them to be able to use extended methods by doing "BladeAPI.config.<method>".

    I am unsure as to if I am doing this right which is why I am posting.
    Last edited: Feb 3, 2015
  2. Offline


    @RenditionsRule What you're doing is fine (and nice to see that some people seem to understand that static isn't the solution for everything), but the static-parameter for your ConfigHandler instance isn't needed tho.

    Anyway...why dont you simply try it out? Especially this is shown by an IDE already. Somehow allot of people are asking and asking without experimenting :eek: that's the fun part :) But yes, it should work like you did it. But you should consider to use a getter for your handler-instance instead.
  3. Offline


    @PreFiXAUT Thank you for your help. I would test the code but as of right now, my IDE is shot so I'm having to do all this in Notepad++.

    I was very sceptical about the static part of ConfigHander because I knew the variable was in a class that I could reach from external sources.

    I also prefer to use a Class Constructor when trying to reach variables that can't be accessed in any other way besides static.
Thread Status:
Not open for further replies.

Share This Page