Skip to main content

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.

CraftCommand is an annotation-driven command framework for Java applications that fundamentally differs from other command libraries in one critical way: it never uses runtime reflection to read or dispatch annotations. While most frameworks inspect your annotated classes at startup and call methods via Method.invoke() on every execution, CraftCommand’s annotation processor reads your @Command-annotated classes at compile time and uses JavaPoet to emit plain Java wrapper classes into your build. At runtime, those generated wrappers call your methods as ordinary Java — with full type safety and zero per-invocation reflection overhead.

How it works

The CraftCommand build pipeline has three distinct phases:
  1. Annotation processing (compile time) — the platform-specific annotation processor scans every class annotated with @Command. For each class it finds, it reads the @Default, @Subcommand, @Optional, and validation annotations on its methods and parameters entirely within the Java compiler’s annotation processing round.
  2. Code generation (compile time) — the processor delegates to JavaPoet to emit a concrete wrapper class named YourCommandClass_<Platform> (e.g. CalculatorCommand_Standalone). This class implements the platform’s command interface directly and contains hand-unrolled argument parsing and dispatch logic — no maps of strings-to-Method objects, no getDeclaredMethods() calls.
  3. Registration (runtime, once) — when you call manager.register(new YourCommand()), StandaloneCommandManager performs a single Class.forName("YourCommandClass_Standalone") lookup to locate the generated wrapper, constructs it via its known constructor signature, and stores it in a HashMap. Every subsequent execute() or tabComplete() call goes straight through the generated code, with no reflection at all.
The net result is command dispatch at near-native speed, deterministic behavior in environments that restrict reflection (GraalVM native image, strict class-loaders), and compile-time errors for mismatched method signatures instead of runtime surprises.

Key features

Compile-Time Code Generation

The annotation processor emits platform-native wrapper classes via JavaPoet during compilation. No annotation scanning, no proxy objects, and no Method.invoke() on the hot path.

Multi-Platform Support

A single set of annotations targets Standalone Java applications, Bukkit/Spigot plugins, and Paper (Brigadier) plugins. Swap the runtime and processor dependency to change platforms.

Pluggable Argument Resolvers

Register custom type providers on the CommandManager to teach the framework how to parse your own types from raw string arguments — including enums, UUIDs, or domain objects.

Built-In Validation

The optional validation module provides parameter-level annotations such as @Min and @ValidateWith. Violations are caught before your method body runs and routed through the configurable ErrorHandler.

Supported platforms

PlatformDescription
StandaloneAny Java 8+ application — CLIs, bots, services, or desktop tools
Bukkit / SpigotMinecraft server plugins using the Bukkit command API
PaperMinecraft server plugins using Paper’s Brigadier integration for richer argument types and client-side completions

Module overview

ModulePurpose
craftcommand-annotationsCore annotations: @Command, @Subcommand, @Default, @Optional, @Suggest, @Greedy, @Resolve, @Name
craftcommand-runtimeCore runtime implementation and base classes used by all platform runtimes
craftcommand-processorCommon base code shared by all platform annotation processors
craftcommand-standalone-runtimeRuntime for standalone Java apps — StandaloneCommandManager, StandaloneCommand
craftcommand-standalone-processorAnnotation processor that generates *_Standalone wrapper classes
craftcommand-bukkit-runtimeRuntime for Bukkit/Spigot plugins
craftcommand-bukkit-processorAnnotation processor that generates Bukkit command wrappers
craftcommand-paper-runtimeRuntime for Paper plugins with Brigadier support
craftcommand-paper-processorAnnotation processor that generates Paper/Brigadier command wrappers
craftcommand-validation-annotationsValidation annotations: @Min, @Max, @ValidateWith, etc.
craftcommand-validation-processorAnnotation processor that weaves validation checks into generated wrappers
craftcommand-bomBill of Materials — import once to manage all CraftCommand module versions
CraftCommand targets Java 8 and above and is published to Maven Central under the io.github.projectunified group ID. The BOM (craftcommand-bom) is the recommended way to keep all module versions in sync — see the Installation guide for details.

Build docs developers (and LLMs) love