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 org.bukkit.plugin.java.JavaPlugin.
    Now lets start coding!
    Right now your plugin should look something like this:
    PHP:
    package my.package.testplugin;
    import org.bukkit.plugin.java.JavaPlugin;
    public class TestPlugin extends JavaPlugin {
        public void onEnable() {
     
        }
    }
    Right? WELL THATS NOT ENOUGH.
    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:
    PHP:
    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:
    PHP:
    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...