Skip to main content
RefineryCore’s command framework (xyz.refineryteam.refinerycore.api.command) lets you define a command as a single class with annotated methods, instead of hand-writing a CommandExecutor and TabCompleter and manually parsing args[0].

Defining a command

Annotate a class extending RefineryCommand with @Command, then annotate methods with @DefaultHandler (runs with no subcommand) or @Subcommand (runs for a named subcommand):
RefineryCoreCommand.java

@Command

Applied to the class. Fields:

@Subcommand

Applied to a method. Matched against args[0] (case-insensitive).

@DefaultHandler

Applied to a method that runs when no argument matches a registered subcommand (including zero arguments). A command can have at most one.

@PlayerOnly

Applied to a @Subcommand or @DefaultHandler method to reject non-player senders. Calls onPlayerOnly(context) (overridable) instead of running the method.

@Cooldown

Applied to a @Subcommand or @DefaultHandler method to rate-limit it per player:
KitCommand.java
  • Console senders and non-player senders always bypass the cooldown.
  • bypassPermission (optional) lets specific senders skip the cooldown entirely.
  • message (optional) customizes the rejection message; the %time% placeholder is replaced with the remaining seconds. Default: <red>Wait <white>%time%s</white> before using this again.
Cooldowns are tracked per (class, method, player) via a shared CooldownManager instance internal to the command bridge — you don’t need to manage this yourself.

Registering a command

Register your command instance through getCommandRegistry() (available via RefineryPluginImplementation), typically in onEnable():
Plugin.java
CommandRegistry reflectively registers the command directly into the server’s CommandMap — you do not need to declare the command in plugin.yml or paper-plugin.yml.

CommandContext

Every handler method receives a CommandContext (or takes no arguments, if you don’t need it) with helpers for reading arguments and replying:
GiveCommand.java
Key methods:

Overridable behavior

RefineryCommand provides default implementations you can override:
MyCommand.java

Help menu

Calling instance.onHelp(context) — triggered automatically when a sender runs <command> help — renders a formatted, hoverable/clickable help menu built from every @Subcommand method’s metadata, via HelpMenu. Customize the header/footer text with @HelpInfo on the command class:
KitsCommand.java
Each entry shows the subcommand’s usage, description, and permission node on hover, and clicking suggests the command in chat.

Tab completion

Provide completions on @Subcommand — one spec string per argument position, matched by index:
GiveCommand.java
Supported completion specs: Subcommand names themselves are also tab-completed automatically (filtered by the sender’s permission for each subcommand).