> For the complete documentation index, see [llms.txt](https://m3ii0.gitbook.io/amazingtitles_core_1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://m3ii0.gitbook.io/amazingtitles_core_1/plugins-api/creating-custom-subcommand.md).

# Creating Custom SubCommand

## Command handler needs to extend CommandHandler interface

```java
public class APIExample implements CommandHandler {
	
	
	@Override
	public boolean readAndExecute(CommandSender s, String[] args) {
		
		/*
		* 
		* Your command handler
		* @ false - helpMessage() will be sent to command sender
		* @ true - helpMessage() won't be sent to command sender
		* 
		* */
		
		return false;
	}
	
	@Override
	public List<String> readAndReturn(CommandSender s, String[] args) {
		
		/*
		* 
		* Your tab completer
		* 
		* */
		
		return null;
	}
	
	@Override
	public String permission() {
		return "some.permission.to.use";
	}
	
	@Override
	public HandlerType handlerType() {
		return new ExtensionHandlerType();
	}
	
	@Override
	public BaseComponent[] helpMessage() {
		
		/*
		* For this you can use built in TextComponentBuilder!
		* */
		TextComponentBuilder builder = new TextComponentBuilder();
		
		// Appending legacy text (Will be colorized automatically)
		builder.appendLegacy("&aSome text");
		
		// Appending legacy text with hover (Will be colorized automatically)
		builder.appendLegacy("&aSome text", "&bSome Hover");
		
		// Appending legacy text with click (Will be colorized automatically)
		builder.appendLegacy("&aSome text", ClickEvent.Action.OPEN_URL, "some.url");
		
		// Appending legacy text with hover & click (Will be colorized automatically)
		builder.appendLegacy("&aSome text", "&bSome Hover", ClickEvent.Action.OPEN_URL, "some.url");
		 
		// Returning component
		return builder.createMessage();
	}
	
}
```

## Registering your CommandHandler

```java
/*
* Let's register your handler with API!
* @ String - SubArgument (For example now usage is /at clearchat)
* @ CommandHandler - Your handler object
* */
AmazingTitles.registerCommandHandler("clearChat", new ClearChatCommandHandler());
```
