Skip to content
Maarten Magits edited this page May 21, 2021 · 4 revisions

Getting started

MmCommands provides a way for developers to spend less time implementing the overhead of their commands by offering an easy API that takes care of dispatching, auto-completion, permission handling and so much more!

1 Including dependency

To use this API, you will need to add it as a dependency to your project.

Maven

<repositories>
    <repository>
        <id>MmPlugins</id>
        <url>https://github.com/Mmaarten23/Maven/raw/master</url>
    </repository>
    ...
</repositories>
<dependencies>
    <dependency>
        <groupId>com.mmaarten</groupId>
        <artifactId>MmCommands</artifactId>
        <!--insert version here-->
        <version>1.0.0</version> 
    </dependency>
</dependencies>

Gradle

repositories {
    maven { url 'https://github.com/Mmaarten23/Maven/raw/master' }
}
dependencies {
    compileOnly "com.mmaarten:MmCommands:1.0.0"
}

2 Plugin.yml

This API is a handler for a registered plugincommand. If you do not yet have a command registered, please do so now by following this pattern inside of the plugin.yml:

commands:
  # the name for your command. Used as /base
  base: 
    description: Base command

More info about which attributes you can specify can be found here.

3 Registering handler

Inside your main plugin class (the class in your plugin that extends JavaPlugin), you now want to register an instance of the MmCommandHandler as executor for the plugincommand. In most cases, this registering will happen inside of the onEnable() method. Your main class should look something like this:

package com.mmaarten.myplugin;

import com.mmaarten.mmcommands.MmCommandHandler;

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        Bukkit.getPluginCommand().setExecutor(new MmCommandHandler())
    }
}

This will attach a default MmCommandHandler to the plugincommand. This in itself will not add too much functionality but it is the first step to working with this API.

Clone this wiki locally