-
Notifications
You must be signed in to change notification settings - Fork 41
Customizing Aliases
One of the more frequent requests is "Can you remove X alias? It conflicts with Y plugin's X." This is a bit unreasonable - OpenInv cannot be aware of all the plugins you're trying to run. It is possible, but it makes OpenInv's setup much more complex and error-prone. The good news is, you already can add your own aliases without any code changes required to OI! Bukkit has its own commands.yml
available for that.
In your server root directory (where your server .jar is kept) you'll find commands.yml
. Like any YAML file, be careful to use spaces for indentation instead of tabs. You may wish to use an editor that has the ability to display whitespace characters to make your life easier.
Note All the examples on this page will use 2 spaces for indentation for readability, but the default file uses 4 spaces. Spacing doesn't matter... as long as you're consistent.
By default, your commands.yml
contains no command block overrides and a single alias, /icanhasbukkit
, which executes /version
with any parameters provided.
command-block-overrides: []
aliases:
icanhasbukkit:
- "version $1-"
There's a command you want to use that OpenInv is overriding, and you don't like that. You need an alias, just like /icanhasbukkit
from the defaults.
aliases:
oi:
- "helloplugin:oi $1-"
Note the similarities between this example and the default. Specifying the alias is oi
overrides OpenInv's /oi
. Then, in the list of commands to execute, you tell Bukkit you want to run specifically the /oi
from HelloPlugin
instead, and you want to pass it all of the parameters if they exist. That's it! You're done. Restart your server, and /oi Player
will execute /helloplugin:oi Player
!
Because the Bukkit aliasing system is executing a list of commands, it has some drawbacks:
- Aliases do not have permissions, so all users can see them when tab completing commands.
- This is a "feature": Bukkit is not sure which (if any) of the commands the user executing it is supposed to be running, so it always attempts to run them all and is always available, even if the user has access to none of the commands.
- This can be mitigated by any plugin that can obtain the Command from the server's CommandMap, i.e. PermissionsSetup. The aliases can have their permissions set, Bukkit just doesn't provide a way to do so from the file.
- Aliases use the default tab completer, which tab completes online players' names.
- The most frequently requested modified aliases are for privatized normal chat; most use cases will not be affected by a loss of tab completion.
The command-block-overrides
is a list of commands which command blocks will use the Mojang version of when a Bukkit and Mojang version are available. This basically just adds the minecraft:
prefix if the sender is a command block.
Ex:
command-block-overrides:
- "summon"
- "time"
This configuration ensures that command blocks execute minecraft:summon
and minecraft:time
if bukkit:summon
or mytimerplugin:time
exists and overrides the default summon
or time
command.
Arguments in modifiers are 1-indexed.
Modifier | Description |
---|---|
$X |
The argument at X index. |
$X- |
The argument at X index and all subsequent arguments. |
$$X |
An argument that is required for the alias to function. |
$$X- |
An argument that is required for the alias to function and all subsequent arguments. |
\$ |
A $ character. |
Example | YAML | Usage |
---|---|---|
Execute a command using only the specified arguments. |
|
/say2 Hello world! It is I! -> /say Hello world!
|
Execute another command, passing all arguments. |
|
/s Hello world! -> /say Hello world!
|
Execute a command with a required argument. |
|
|
Execute a command with a required argument that consumes all subsequent arguments. |
|
|
Use a $ character in an alias. |
|
/money 10 -> /say $10
|