Skip to content

Command Completions

Daniel Ennis edited this page Jul 19, 2017 · 5 revisions

What are Completion Handlers

When a user inputs a command into a system that supports tab completion (All of our supported platforms do), when you type a partial command, ACF can programmatically build suggestions into what the user is wanting to complete to.

This may be sub commands, or input into your defined command such as online players, enum values, etc.

When using your own custom context objects, you can define a matching completion handler to provide completion values.

Completion Configs

Special Completion Handlers are prefixed @ like @foo, you may tack on additional config data by then using : followed by a comma separated list of key/value configs, like so:

@foo:foo=bar,baz=qux

The context handler can then do c.getConfig("foo") to get bar, and c.getConfig("baz") to get qux.

Registering Command Completion Handlers

To register your own custom ones, one would do

manager.getCommandCompletions().registerCompletion("foo", c -> {
   return ImmutableList.of("some", "custom", "completion");
});

Default Completion Values

  • @nothing - returns nothing
  • @range - takes a completion, pass range like so @range:0-20 or @range:20 (assumed 0 start)

Minecraft Specific Completion Values

  • @mobs - list of EntityType enum values (Bukkit)
  • @chatcolors - lists of all the chat colors supported by your platform (Bukkit, Bungee)
  • @worlds - lists all world names (Bukkit)
  • @players - lists all online players that you can see (depending on platform API/vanish) (Bukkit, Bungee(no vanish))