Skip to content

Demonstration of creating a sub-command system

Notifications You must be signed in to change notification settings

avighnash/command-handler

Repository files navigation

Command Handling

A simple, clean, and easy to use command system. Currently only compatible with the Bukkit API (And of course it's forks: Paper/Spigot).

You may include this via Maven, or add the jar itself.

Maven:

a) Add the repository...

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

b) Add the dependency...

<dependency>
    <groupId>com.github.OutdatedVersion</groupId>
    <artifactId>child-commands</artifactId>
    <version>2.1</version>
</dependency>

Usage:

After including the depdency you may create commands as you wish. Be sure to start up the handler, or it won't work!

new CommandHandler(<Your plugin instance>);

Then commands are like so:

// Main Command
import com.perceivedstudios.command.Command;
import org.bukkit.entity.Player;

public class KittensCmd extends Command
{

    public KittensCmd()
    {
        super("kittens");
    }

    @Override
    public void execute(Player player, String[] args)
    {
        // Stuff
    }
    
}

Of course you may also have 'sub-commands'.

import com.perceivedstudios.command.ChildCommand;
import org.bukkit.entity.Player;

public class ExtraKittensCmd extends ChildCommand
{

    public ExtraKittensCmd(Command parent)
    {
       super(parent, "extra");
    }
    
    @Override
    public void execute(Player player, String[] args)
    {
        player.sendMessage("kittttennnnnnssss!");
    }

}
public KittensCmd()
{
    super("kittens");
    
    new ExtraKittensCmd(this);
}

This should be what you need to get started. If you have any issues please do not hesitate to contact me on the Spigot forums.

About

Demonstration of creating a sub-command system

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages