API Example

Let's get this right now! You can make as many extentions as you want to the GroupCore API, but do not distribute! Send them a link to the download page of this mod instead and you are perfectly fine!

Okay, let's begin!

What are we going to do?
  1. Take a look at how to setup the API
  2. Take a look at how to use the API

Okay, so first of all you will need to add the jar file to your project libraries (maybe a guide for that later)

Now how do you use this in your project? Here a example of how to set it up!

public GroupCoreAPI api;

public void onEnable(){
    if(Bukkit.getPluginManager().isPluginEnabled("GroupCore")){
        this.api = groupcore.Core.GetAPI();
        this.api.RegisterHook(this);
        
    }else{
        this.info("GroupCore is required!");
    }
}

That is basicly all you need to do to implement the API!

So how do I register this dynamic command?

Make a class like this

public class NewClass implements GroupCommand{

    @Override
    public int GetMinArgs() {
        // Get the minimum amout of arguments for this command
    }

    @Override
    public void Process(PlayerCommandPreprocessEvent pcpe, ArrayList<String> al) {
        // If the command was successfull, proced!
    }

    @Override
    public String GetErrorMessage() {
        // If the command failed for some reason, what message should be sent?
    }

    @Override
    public String GetDescription() {
        // The description for the command in the /help list
    }

    @Override
    public String GetName() {
        // The name of the command to show in the help list!
    }
    
}
Then to register the command
this.api.GetCommandHandler().RegisterCommand("/command", new NewClass());

All the work is done for you behind the scenes and you have a fully registed command!


Comments

Posts Quoted:
Reply
Clear All Quotes