This is an event handling function that monitors players commands and changes them based on settings from a config file.
This function loads command replacements from file called playercmd.txt (unless file name is changed in the plugin config file), located in the CommandsEX directory in your plugins folder. If the config file doesn't exist, it will be created automatically.
Should there be a need to manually remove this feature from the JAR file, the following file must be removed: com/github/zathrus_writer/commandsex/handlers/Handler_replaceplayercommand.class
CommandsEX uses regular expressions to match commands against texts provided in the config file. You can use any regular expression supported by Java and test them here (basic stuff) or here (advanced stuff).
The actual format of your config file must follow this principle:
For scripting (e.g. to replace 1 command with multiple others), use the following syntax:
/player command/ =={
1st command to execute
2nd command to execute
....
}
Please note that the closing bracket -> } <- must always be at the beginning of a line.
The {ci} and {cc} switches are special to CommandsEX. They must be listed at the beginning of the regular expression. As the example above states, if {ci} is used, CommandsEX will search for the command given ignoring letter case. This way, you can easily catch typos like "/helP", "/Help" etc.
The {cc} switch will check if the command entered by a player is uppercase and if it is, CommandsEX will automatically make the command replacement uppercase as well.
If required, CommandsEX provides you with a way to execute commands as if the player was typing them into console.
To do so, you simply need to prefix the right-hand side replacement command with the word sudo, which stands for "Super-User Do" and comes from the Unix platform.
Example:
This example will make a player that types "/makemeop" into chat an Operator.
CommandsEX supports back references following java's model (e.g. $1 - $9), adding reference $p for player's name (not display name, but the real user name).
These are some more examples of how back references work:
Command words (regexes matching against the chat which execute commands) run the commands before the chat message is broadcast, instead of afterward. The commands are still run in response to what you say in chat, it just doesn't seem like it...
This functionality has been merged from the former Commander plugin, developed by tustin2121
Wiki: CommandsEX CraftBukkit plugin Wiki
Wiki: Configuration