Bibo38Lib

13.2k Downloads

This is my personal library for developing Bukkit Server Plugins!

I have written it to help me faster writing Plugins by using a set of large features like auto generated Plugin help Pages and you will need it for most of my Plugins!

Installation

  • Download the Jar-File and put it in your plugins folder
  • Restart or reload your Server
  • Enjoy my Plugins

Soft Dependencies

Bibo38lib uses the following plugins if installed:

  • Vault
  • SpoutPlugin (won't be needed at this time, but there is also some code in the Library)

Plugins using Bibo38Lib

Following Plugins from me use and need Bibo38lib:

API

How to start coding with my library

Download my library form dev.bukkit or clone it from Github and add it to your Project Build Path like the Bukkit API!

Permissions

Bibo38lib support easy Permissions using Vault. Here is an usage example:

Permissions perm = new Permissions("myplug");
boolean canUse = perm.hasPerm(player, "use"); // check if player has the Permission myplug.use

If a Player has not the Permission, a message will be automatical displayed!

Economy

Economy is as easy as Permissions using Vault:

Economy myeco;
try
{
    myeco = new Economy();
} catch(NullPointerException e)
{
    // No Economy or no vault found!
}

myeco.giveMoney(player, -200); // Remove 200 from Players money
myeco.giveMoney(player, 200); // Give the Player 200
myeco.setMoney(player, 100); // Set the players money to 100

You must only check for an NullPointerException if the Server has no Economy or no Vault installed!

Commands

You can easy write Commands using a special class:

public class CmdListener implements CommandListener
{
    @ACommand(maxArgs = 0, description = "Resets the Player Count to the normal Values", permissions = "reset")
    public void reset(CommandSender cs, String[] args)
    {
        // /myplug reset
    }

    @ACommand(maxArgs = 1, minArgs = 1, usage = "[players]", description = "Adds or removes an amount of Players automatically", permissions = "autoadd", playerNeed = true)
    public void autoAdd(CommandSender cs, String[] args)
    {
        // Adds the command /myplug autoadd with one argument
    }

    @ACommand(maxArgs = 0, description = "Removes the Plugin in a clean way!")
    public void remove(CommandSender cs, String[] args)
    {
        // /myplug remove
    }
}

You use Annotations to set the Command Description an other things like permissions or max arguments. Even if the command doesn't need Arguments or a CommandSender you must put them into the method. To register the Command you must invoke the following Command in your onEnable() method

new Command(this, "myplug", new CmdListener());

And if you put the command myplug into your plugins.yml file you can use it and you have an automatical help included: /myplug help

WebServer

Bibo38Lib includes a full Webserver(port 2345) for hosting files from your Plugin, so that other users can download them:

WebServer server = Startfunc.getMain().getSpout().getServer();
try {
    String url = server.addFile(this.getResource("pic.png"), "pic", "png");
    System.out.println("You can download the picture here: " + url);
} catch (IOException e) {}

or you can register a function, which will get called, if a special page is requested:

public class TestPlugin extends JavaPlugin implements WebService
{
    public void onEnable()
    {
        WebServer server = Startfunc.getMain().getSpout().getServer();
        server.registerService("info.htm", this);
    }

    public void recive(String file, Header header, OutputStream out, InetAddress addr)
    {
        if(file.equals("info.htm") && header.getMethod().equals("GET"))
        {
            try {
                Header back = new Header(200, 1.0);
                back.setHeader("Content-Type", "text/plain; charset=UTF-8");
                out.write(back.toString().getBytes());

                out.write("Your User Agent: ".getBytes());
                out.write(header.getHeader("User-Agent").getBytes());
            } catch (IOException e) {}
        }
    }
}

JavaDocs

I haven't created the Javadocs and they are also in the sources in German, which I will fix in the next time!

Source Code

GitHub