Module: command_rewrite
Overview
This module allows defining regex to rewrite the command line issued by a player.
Color Boxes
◉ How it works?
-
Intercept the
issued command stringpackets. -
Apply the defined rewrite rules to
the command stringin top-down order.
NOTE: The command_rewrite occurs at the very beginning of the command lifecycle.
You will not receive command suggestions or command exceptions at this stage.
The rewrite rules are applied directly to the raw command string.
◉ Command Lifecycle
-
Issuing – The command is sent as
a raw string. At this stage, no command suggestions or exceptions are available. -
Parsing – The command string is parsed into
a command node. At this point, command suggestions and exceptions can be provided. -
Execution – The
actionsassociated with the command node areexecuted, producing the intendedeffectsof the command.
◉ The different compared to command_alias module and command_bundle module.
-
The
command aliasmodule allows you to definenew command, and redirects it intoan existing command. -
The
command bundlemodule allows you to definenew command, and define the argument and body of the new command. -
The
command rewritemodule didn't define any new command. It just works innetwork packetlevel, and modifies theissued command stringfrom the command source player.
◉ You can use this module to shorten the command string.
Like, rewrite the command string /home into /home tp default.
And provide a shortcut, for /home tp default command.
Configurations
The following JSON content is provided for reference only. It must NOT be copied directly into the configuration directory, as it does not represent valid JSON syntax.
- File Name:
config.json - File Content:
Click to see the default content...
{
/* Defined `rewrite` entries. */
"rules": [
{
/* The `regex` expression used to match the `target string`. */
"regex": "\\?"
/* The `pattern` used to replace the `matched target string`. */,
"replacement": "help"
}
]
}