Command aid system

This is a guide to learn how to create an advanced command aid system.

Advanced command aid system

What is it ?

An advanced command aid system is an aid sent to a user when he makes a mistake in a command. This system will search the commands the most closest from the command sent and it will send them to the user to help him.

It will also allow the user to click on the messages sent to execute commands faster or to be sure that their spelling is correct.

Create it

To create an advanced aid system for a command, you must first know what your command will do. In this guide, I will create an item command which will allow users to modify their items in game. So I will create these different commands:

  1. /item name [name]

  2. /item clear

  3. /item lore list

  4. /item lore add [line]

  5. /item lore remove [line]

Now, to create your aid system, we will create one JsonObject per argument of the command and in the order in which they must be written by the user. Let's create it for the first command.

You can see that name if an argument of my command so I will create an object called "name" is the commandUsage section.

{
  "item": {
    "commandUsage": {
      "name": {}
    }
  }
}

Arguments can also be written in square brackets or between the symbols < and >. These notations are very important to use the automatic tab completer.

Usage properties

Now, let's add properties and values which will be showed to users and he makes a mistake in our command. The available properties are:

Property

Type

Description

component

EasyComponent

The usage of the command (see here for more information)

permission

String

The permission of the command

type

String

Always Usage.class

The permission property is the permission of the command. It is used by both the command aid system and the automatic tab completer to know if messages and completions can be sent to the user.

type property is mandatory and must always be Usage.class. It says to the system to read the current object as a Usage object and that there are no other under paths.

Example

Let's see an example for the /item name command:

"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"

Now, let's do the same thing for the other commands:

"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"
    }
  }
}

Result

You can see the result by clicking on the page below.

pageExample of use

Last updated