Example of use

This is an example of what you can do using SmartCommands.

Initialize the API

SmartCommandsAPI api = new SmartCommandsAPI.ApiBuilder().build(this);

Create your command

In this example, I will create a /item command so the name of my command is item.

commands.json
{
  "item": {
    "description": "A command to customize your items.",
    "usage": "/item",
    "resource": "commands/command_item.json",
    "resourceOnly": false,
    "aliases": ["it"],
    "issuers": ["PLAYER"],
    "tabComplete": true
  }
}

Add contents to your command

command_item.json
"commandUsage": {
  "name": {
    "component": {
      "text": "&6/item name &e[name] &7to rename your item.",
      "showText": "&bClick to suggest",
      "suggestCommand": "item name",
      "color": "GRAY"
    },
    "permission": "item.name",
    "type": "Usage.class"
  },
  "clear": {
    "component": {
      "text": "&6/item clear &7to remove all the attributes of your team.",
      "showText": "&bClick to execute",
      "runCommand": "item clear",
      "color": "GRAY"
    },
    "permission": "item.clear",
    "type": "Usage.class"
  },
  "lore": {
    "list": {
      "component": {
        "text": "&6/item lore list &7to show the lore your the item.",
        "showText": "&bClick to execute",
        "runCommand": "item lore list",
        "color": "GRAY"
      },
      "permission": "item.lore.list",
      "type": "Usage.class"
    },
    "add": {
      "component": {
        "text": "&6/item lore add &e[line] &7to add a line to your item lore.",
        "showText": "&bClick to suggest",
        "suggestCommand": "item lore add",
        "color": "GRAY"
      },
      "permission": "lore.add",
      "type": "Usage.class"
    },
    "remove": {
      "component": {
        "text": "&6/item lore remove &e[line] &7to remove a line to your item lore.",
        "showText": "&bClick to suggest",
        "suggestCommand": "item lore remove",
        "color": "GRAY"
      },
      "permission": "lore.remove",
      "type": "Usage.class"
    }
  }
}

Register your command

CommandManager manager = api.getCommandManager();
manager.registerCommand("item", new CommandItem());

Results

Advanced command aid system

Here, you can see an example of use of the advanced aid system combined with the page system.

In these examples, I made a mistake in the syntax of my command so the system will automatically show me the closest commands to the one I sent.

You can also click on the commands found by the system to execute them or suggest them.

Automatic tab completer

Here is an example of use of the automatic tab completer. As you can see it, it automatically found the possible completions and send them to me.

Last updated