Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ProjectUnified/CraftCommand/llms.txt
Use this file to discover all available pages before exploring further.
CommandManager<S> is the abstract base class that every CraftCommand integration is built on. It owns the resolver registry, the error handler, and the command-info exposer map. Platform-specific subclasses — StandaloneCommandManager, BukkitCommandManager, and PaperCommandManager — extend it to add platform registration logic (command-map registration for Bukkit, lifecycle-event deferral for Paper, label-map tracking for Standalone) while inheriting the full resolver and error-handling API.
CommandManager<S> — base class
CommandManager<S> is parameterised on S, the platform’s command-sender type. All resolver lookups and error callbacks carry the same S throughout.
registerResolver
Registers a typed argument resolver for an exact class match.The exact target class to register the resolver under. Later lookups check this key first before
walking the class hierarchy or querying providers.
The resolver instance that converts raw argument strings into values of type
T.registerProvider
Registers a dynamic resolver provider that is consulted when no exact or hierarchy match is found.A provider that receives the target class and returns a resolver, or
null if it cannot handle
that type. Providers are tried in registration order after all registerResolver entries.getResolver
Returns the best resolver for the given type, following the four-step lookup order documented in ArgumentResolver & ArgumentResolverProvider.The class to look up.
ArgumentResolver<S, T>. If no registered resolver or provider matches, a fallback
resolver is returned that casts the sender to T if possible, or throws IllegalArgumentException.
resolveParameter
Resolves a single command parameter for a given type, advancing the shared index holder in place. Generated command wrappers delegate every parameter to this method instead of duplicating resolver lookup, width tracking, optional handling, and missing-argument reporting.The platform-native command sender. Must match the manager’s
S type (e.g. CommandSourceStack
for Paper). The wrapper passes the platform sender directly — not whatever type the user-facing
method declares.The Java class to resolve the argument into.
The full command arguments array available to the resolver.
A single-element array holding the current argument index. The method advances
indexHolder[0]
by the resolver’s getWidth() on success, so successive calls automatically move through args.The parameter name used in the
"missing-argument" error message.When
true and there are not enough arguments, the method returns null (or the resolved
defaultValue) instead of throwing.The string default to resolve when the parameter is optional and arguments are exhausted. Pass
null to return null for optional parameters with no default.T value, or null when the parameter is optional and absent with no
default.
Throws CommandException if a required parameter has insufficient arguments; throws any
exception the resolver itself propagates.
filterSuggestions
Static helper that filters a list of tab-completion candidates to only those starting with the current input, using a case-insensitive prefix comparison.The raw candidate list. A
null value is treated as an empty list.The partial input typed so far. Compared in lowercase.
List<String> containing only entries whose lowercase form starts with the
lowercase form of current.
formatMessage
Formats a localisation message for a given key. The default implementation callsString.format(defaultValue, args). Override this method to provide translations or a custom
message dictionary.
The message key (e.g.
"missing-argument", "validation.min"). See Error Handling — Message keys for the full list.The fallback
String.format-compatible template used when no custom translation is provided.Format arguments applied to the template.
String.format throws, the raw defaultValue is returned.
getErrorHandler / setErrorHandler
Reads or replaces the active error handler.The new error handler. Called by generated wrappers whenever a command or resolver throws.
registerExposer
Registers aCommandInfoExposer produced by the generated wrapper for a given command instance.
Called automatically by register(Object) in each platform subclass.
The user-defined annotated command object (used as the map key).
The generated wrapper, which implements
CommandInfoExposer and returns the command’s info list.getCommandInfo
Returns the list ofCommandInfo records registered for a command instance, or an empty list if
the instance was never registered or its wrapper does not implement CommandInfoExposer.
The annotated command object passed to
register().List<CommandInfo> (never null).
StandaloneCommandManager
StandaloneCommandManager extends CommandManager<Object> for use in plain Java applications with no server runtime. The sender type is Object.
Constructors
RuntimeException, or wraps it in a new RuntimeException otherwise.
register(Object)
Scans for the annotation-processor-generated class namedClassName_Standalone and instantiates
it via reflection. The wrapper is registered via registerCommand, and if it implements
CommandInfoExposer the exposer is stored as well.
An instance of a class annotated with
@Command. The processor must have generated the
corresponding _Standalone wrapper at compile time.IllegalArgumentException if the wrapper class cannot be found or instantiated.
registerCommand
Directly registers aStandaloneCommand wrapper (and all its aliases) into the internal label map.
The command wrapper.
command.getName() and every entry in command.getAliases() are all
stored as lowercase keys.getCommand
Looks up a registered command by its label or any alias. The lookup is case-insensitive.The primary name or alias to look up.
StandaloneCommand, or null if no command is registered under that label.
getCommands
Returns the full label-to-command map. Aliases are also present as independent entries.Map<String, StandaloneCommand> (keys are lowercase).
BukkitCommandManager
BukkitCommandManager extends CommandManager<CommandSender> for Bukkit/Spigot/Paper plugins.
Constructors
Your plugin instance. Used as the namespace when registering to the Bukkit
CommandMap and for
duplicate-command logging.Custom error handler. When omitted, a red-message default is used.
register(Object)
Looks up the generatedClassName_Executor wrapper via reflection and registers it as a Bukkit
Command.
An instance annotated with
@Command. If the object itself is already a Command, it is
forwarded directly to register(Command).IllegalArgumentException if the wrapper class cannot be found or instantiated, or if
the label is already registered (a warning is logged instead of an exception in that case).
register(Command)
Registers a BukkitCommand directly to the server’s CommandMap under the plugin’s namespace.
The Bukkit command to register. Duplicate labels are ignored with a warning.
syncCommand
Calls the server’ssyncCommands() method to push the updated command tree to connected clients
(requires a CraftBukkit-derived server that exposes this method; silently does nothing otherwise).
unregisterAll
Removes every command registered by this manager from the server’sCommandMap and clears the
internal tracking map.
Call
syncCommand() after unregisterAll() if you want clients to see the removal immediately.PaperCommandManager
PaperCommandManager extends CommandManager<CommandSourceStack> for Paper plugins using the
Brigadier command API.
Constructors
Your plugin instance. The constructor immediately attaches a
LifecycleEvents.COMMANDS handler
so that all queued commands are registered when the lifecycle event fires.Custom error handler. When omitted, a red Adventure
Component default is used.register(Object)
Attempts to locate and instantiate theClassName_Paper Brigadier wrapper first. If that class is
not found (e.g. the command uses only features supported by the basic API), it falls back to the
ClassName_PaperBasic wrapper. The resulting wrapper is queued and registered when
LifecycleEvents.COMMANDS fires.
An instance annotated with
@Command. If the object is already a PaperCommand or
PaperBasicCommand, it is forwarded to the appropriate typed overload directly.IllegalArgumentException if neither wrapper class can be found or instantiated.
register(PaperCommand)
Queues a full BrigadierPaperCommand wrapper for registration at the LifecycleEvents.COMMANDS
event.
register(PaperBasicCommand)
Queues aPaperBasicCommand (Paper’s simplified command API) wrapper for registration at the
LifecycleEvents.COMMANDS event.
CommandInfo
CommandInfo is a lightweight data class produced by generated wrappers and exposed through
CommandManager.getCommandInfo(). It describes a single executable entry point (the root command
or any subcommand).
getPath()
List<String> representing the subcommand path from the root label to this
entry. For example, a teleport player subcommand under the tp command returns
["tp", "teleport", "player"].
getUsage()
"player <target>" or "<item> [amount]". Sourced
from the @Command / @Subcommand annotation’s usage attribute.
getDescription()
description attribute.
Returns an empty string if the annotation did not provide one.