Skip to content

Tab Completion of Custom Commands

TheIntolerant edited this page Dec 19, 2024 · 15 revisions

Thanks to @TheIntolerant, for this tutorial!

Making your custom commands show via tab completion is complex and would require ChatControl to register the commands, which it does not do!

Here I will show three ways to make custom commands work in tab completion. Please note that for commands to start working via tab completion, a full server restart is required after making these changes.



In these examples we are going to make a short admin chat command "/ach" that can be tabbed, you can do this three ways.

Solution 1 (Simple)

Use commands.yml to create a custom command.

In this example, we are making a command to chat in the admin channel.
The command is /ach <message>
For togglable commands, see Solution 2, as it is not possible to make these types of commands in commands.yml alone.



Step 1. Locate commands.yml

Open the commands.yml file in the root/server directory. This is where you will make your custom command.


Step 2. Create Custom Command In commands.yml

Once you have opened the file add the custom command under aliases, then place the actual command below.
In this example our actual command is /channel send admin <message> and the alias is /ach <message>
See here for an example!

command-block-overrides: []
ignore-vanilla-permissions: false
aliases:
  ach:
  - channel send admin $1-

Step 3. Restart The Server

Restart the server to make these changes go into full effect.



Solution 2 (Moderate)

Use commands.yml to create a custom command BUT ChatControl controls how the command functions.
In this example, we are making a togglable command for the admin channel, which will switch users between two channels.
The command is /ach


Step 1. Locate commands.yml

Open the commands.yml file in the root/server directory. This is where you will make your custom command.


Step 2. Create Custom Command In commands.yml

Once you have opened the file add the custom command under aliases, then add a random command under the custom command.
See here for an example!

command-block-overrides: []
ignore-vanilla-permissions: false
aliases:
  ach:
  - minecraft:say fake alias

Note: The command /minecraft:say fake alias will get overwritten by ChatControl!
Ensure the "random command" is already registered (works with tab completion). We recommend using a vanilla command such as /minecraft:say or /say etc.


Step 3. Add Rules To command.rs For The Custom Command

Open the /plugins/ChatControlRed/rules/command.rs file and add the desired rules. See below for an example!

# This rule only executes when the player 
# is not in the admin channel for reading.
match ^[/]ach\b
dont verbose
then warn You are now writing to the admin channel!
ignore channel admin write
then command channel join admin write
then deny

# This rule only executes when the player
# is in the admin channel for writing.
match ^[/]ach\b
dont verbose
then warn You are no longer writing to the admin channel!
require channel admin write
then command channel join standard write
then deny

Due to the then deny operator, the alias in commands.yml won't ever execute the "/say" command you put in there.
ChatControl will cancel the event if you add then deny inside the ChatControl file.


Step 4. Restart The Server

Restart the server to make these changes go into full effect.



Solution 3 (Simple to Complex)

Use a third-party plugin, which can "register commands" or create "custom commands". The level of complexity will depend on the plugin you choose to use. Usually, these plugins should register the commands making them work with tab completion! However, it will be up to you to work out if a plugin does this or not by testing it yourself.

For example, CustomCommands. Please note, this is developed by someone else! If you need help you will need to contact them!