What's more developer friendly

Discussion in 'Plugin Development' started by Tecno_Wizard, Aug 22, 2016.

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

    Tecno_Wizard

    I'm really sick of writing some of the backend code for my plugins over and over again so I'm packaging it, but I'm doing it in a bit of an odd way. I extended JavaPlugin to make a lot of the functionality hidden, which is working out really well except for a blaring problem. I would love to be able to have it be completely seamless, which means I am trying to use the onEnable method. The problem is, if some data needs to be changed, there isn't a great way to change that data before my utilities initialize and they become immutable.

    Here's what i think my options are right now.

    Code:
    public void onEnable() {
        this.getOptions().set.... blah blah blah, you get the point.
        super.onEnable(); // I do not like this one bit. It's misleading.
    }
    
    // or
    
    public void onEnable() {
        this.getOptions().blah blah blah. You get the point
        this.initializeUtilities();
    }
    If the backend isn't initialized, a FailedInitializationException is thrown. It this clear enough or is there a better way to do this?
     
  2. Offline

    I Al Istannen

    @Tecno_Wizard
    Not totally to this question, but what backend code? I may want to help you, experiencing the same (wrote a command and langauge util before. But no nice way of packaging it too.)

    To the topic, I think the second is MUCH more descriptive.
    You would need to document what super.onEnable() does, but initializeUtilities speaks for itself.

    On the other hand super.onEnable might be automatically generated for you. But I don't think this is a big advantage.
     
  3. Offline

    Tecno_Wizard

    @I Al Istannen, I was thinking calling the super was too ambiguous. I'm going to have a lot of it on github soon so if you'd like to help you're welcome to.

    The backend is an update reminder (not downloader), messaging plugin change logs to moderators when it updates, a mostly premade I18N system, easy yml file loader, message formatter, and clean access to the update checker for those who just want that. Whole thing is modular. I also plan on making a self-cleaning file cache.
     
  4. Offline

    I Al Istannen

    @Tecno_Wizard
    I will have a look once it is up :) We will be away for nearly two weeks though, starting at Wednesday morning. Which makes it a bit more difficult :p

    Update via the curse API?
    What does the Message formatter do?

    Sounds quite useful though :)
     
  5. Offline

    Tecno_Wizard

    @I Al Istannen update is via bukget, formatter adds the plugin prefix to messages automatically.
     
    I Al Istannen likes this.
  6. Offline

    I Al Istannen

    @Tecno_Wizard
    Bookmarked! Thanks for that, had never heard of it :p
    I will have a look once I can see it, maybe I find something I can lend you hand with (or whatever english expression fits... :p)
     
  7. Offline

    Tecno_Wizard

    @I Al Istannen the phrase is "lend you a hand". That works.

    I'll put it on github once it's close to a working state. Things are a bit messy, need to be documented, and need to flow a bit better.
     
  8. Offline

    Tecno_Wizard

Thread Status:
Not open for further replies.

Share This Page