Developing Plugins For MidLib

Feb 7, 2015
Developing Plugins For MidLib
  • Now what, here it is!
    I assume you know about Java and how to develop plugins in it.
    Also this tutorial is dedicated to Eclipse.
    Now open up eclipse and create a new Java Project with the name of your plugin.
    After that select your project in the Package Explorer and press Alt+Enter.
    Once done, select Java Build Path and select the Libraries tab.
    After that click on Add External JARs... and add Midnight Libraries.
    After that we are ready to code!

    Create the class and set your Superclass to
    Now lets start coding!
    Right now your plugin should look something like this:
    package my.package.testplugin;
    public class TestPlugin extends JavaPlugin {
        public void onEnable() {
    In your plugin class create a local variable that is the type of: org.badboy6767.midnightlibrary.MidLib.
    It can be whatever modifier you like.

    Then in your onEnable method add this code:
    myMidLibVariable = (MidLib) Bukkit.getPluginManager().getPlugin("MidnightLibrary");
    Now your MibLib variable should not be null anymore.

    The last step to install MidLib is to create your plugin.yml file with all of your plugin data,
    and add:
    depend: [MidnightLibrary]
    And that's it! You have installed MidLib onto your plugin.

    Now code your plugin however you want, however, using MidLib you can add a command dynamically like this:
    myMidLibVariable.registerCommand(new MidnightCommand() {
                public String getName() {
                    // This is your command name
                    return "mytestcommand";
                public Plugin getUser() {
                    // The plugin thats using it
                    return myPlugin;
                public boolean onCall(CommandSender sender, String label, String[] arguments) {
                    // Actions here on when your command is called.
                    return true;
    You created a simple command using MidLib!
  • Loading...
  • Loading...