MCPcopy Index your code
hub / github.com/CommandAPI/CommandAPI

github.com/CommandAPI/CommandAPI @11.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 11.2.0 ↗ · + Follow
5,211 symbols 19,413 edges 679 files 1,416 documented · 27%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

CommandAPI logo A Bukkit/Spigot API to use the command UI introduced in Minecraft 1.13

GitHub Maven Central Join us on Discord

CodeFactor GitHub Workflow Status (master) GitHub Workflow Status (dev/dev) Spiget Download Size

Spiget Downloads GitHub all releases Modrinth Downloads

Support and Project Discussion:

Downloads & Documentation:

Other

Compatible Minecraft versions:

The list of what version of the CommandAPI you'll need to run on a specific version of Minecraft is as follows:

| Minecraft version | Compatible versions | Latest compatible

version | Minimum Java

version required

to run latest version | |---------------------|-----------------------------|------------------------------|-----------------------------------------------------------| | 1.13.x | v1.0 - 5.12, 8.3.0 - 8.8.0 | 8.8.0 | 16 | | 1.14.1, 1.14.2 | v2.0 - 5.12, 8.3.0 - 8.8.0 | 8.8.0 | 16 | | 1.14.3, 1.14.4 | v2.1 - 5.12, 8.3.0 - 8.8.0 | 8.8.0 | 16 | | 1.15.x | v2.3a - 5.12, 8.3.0 - 9.3.0 | 9.3.0 | 16 | | 1.16.1 | v3.0 - 5.12, 8.3.0 - 9.4.2 | 9.4.2 | 16 | | 1.16.2 | v4.0 - 5.12, 8.3.0 - 9.4.2 | 9.4.2 | 16 | | 1.16.3 | v4.2 - 5.12, 8.3.0 - 9.4.2 | 9.4.2 | 16 | | 1.16.4 | v5.2 - 5.12, 8.3.0 - 9.4.2 | 9.4.2 | 16 | | 1.16.5 | v5.7 - 7.0.0, 8.3.0 - 9.7.0 | 9.7.0 | 16 | | 1.17 | 6.0.x - 9.7.0 | 9.7.0 | 16 | | 1.17.1 | 6.1.x - 9.7.0 | 9.7.0 | 16 | | 1.18, 1.18.1 | 6.5.2 - 9.7.0 | 9.7.0 | 16 | | 1.18.2 | 6.5.4 - 9.7.0 | 9.7.0 | 16 | | 1.19 | 8.3.0 - 9.7.0 | 9.7.0 | 16 | | 1.19.1 | 8.5.0 - 9.7.0 | 9.7.0 | 16 | | 1.19.2 | 8.5.1 - 9.7.0 | 9.7.0 | 16 | | 1.19.3 | 8.7.0 - 9.7.0 | 9.7.0 | 16 | | 1.19.4 | 8.8.0 - 9.7.0 | 9.7.0 | 16 | | 1.20 | 9.0.2 - 11.1.0 | 11.1.0 | 17 | | 1.20.1 | 9.0.3 - 11.1.0 | 11.1.0 | 17 | | 1.20.2 | 9.2.0 - 11.1.0 | 11.1.0 | 17 | | 1.20.3, 1.20.4 | 9.3.0 - 11.1.0 | 11.1.0 | 17 | | 1.20.5, 1.20.6 | 9.4.0 - 11.1.0 | 11.1.0 | 17 | | 1.21 | 9.5.0 - 11.1.0 | 11.1.0 | 17 | | 1.21.1 | 9.5.2 - 11.1.0 | 11.1.0 | 17 | | 1.21.2, 1.21.3 | 9.6.0 - 11.1.0 | 11.1.0 | 17 | | 1.21.4 | 9.7.0 - 11.1.0 | 11.1.0 | 17 | | 1.21.5 | 10.0.0 - 11.1.0 | 11.1.0 | 17 | | 1.21.6 | 10.1.0 - 11.1.0 | 11.1.0 | 17 | | 1.21.7 | 10.1.1 - 11.1.0 | 11.1.0 | 17 | | 1.21.8 | 10.1.2 - 11.1.0 | 11.1.0 | 17 | | 1.21.9, 1.21.10 | 11.0.0 - 11.1.0 | 11.1.0 | 17 | | 1.21.11 | 11.1.0 | 11.1.0 | 17 | | 26.1.X | 11.2.0 | 11.2.0 | 17 |


Purpose

This project provides an API to help Bukkit/Spigot developers use the Minecraft 1.13 command UI, which includes:

  • Better commands - Prevent players from running invalid commands, making it easier for developers - you won't get dodgy input!

better commands

  • Better arguments - Choose from over 50 arguments including location arguments, raw JSON, enchantments, lists, particles... all fully supported with built-in error checking!

better arguments

  • Support for proxied command senders - Run your command as other entities using /execute as ... run command

proxied senders

  • Argument tooltips - Let your users know exactly what their command will do using argument tooltips

argument tooltips

  • Support for the /execute command - Let your command to be executed by the built in /execute command, as well as command blocks!

  • Support for Minecraft's functions - Allow your command to be executed from Minecraft's functions and tags

  • No plugin.yml registration - Commands don't need to be registered in the plugin.yml file anymore

  • No need for Brigadier - You don't need to import Brigadier in your projects to use the CommandAPI

  • No tracking - The CommandAPI doesn't collect any stats about its plugin; what you see is what you get!

Still not convinced? In addition to all of the above, the CommandAPI also provides:

  • Built-in command converter - Convert other plugin commands into /execute-compatible ones - no code required!
  • Tree-structure command registration - Like Brigadier's code format? We've got you covered with CommandTree
  • Kotlin DSL - Prefer writing plugins in Kotlin? The CommandAPI has an optional Kotlin DSL just for you
  • Powerful suggestion generation - Generate new suggestions for each argument, or add to existing suggestions
  • Safe suggestion generation - The CommandAPI offers compile-time type safety for specific arguments
  • Precise permission support - Apply permissions to specific arguments - you need perms to even see the argument
  • Fast updates - Consistently supports new Minecraft versions within a week of their release
  • Insanely detailed documentation - Trust me, you've never seen a plugin documentation look so good.

Code examples

Simple command registration

new CommandAPICommand("enchantitem")
    .withArguments(new EnchantmentArgument("enchantment"))
    .withArguments(new IntegerArgument("level", 1, 5))
    .executesPlayer((player, args) -> {
        Enchantment enchantment = (Enchantment) args.get("enchantment");
        int level = (int) args.get("level");

        //Add the enchantment
        player.getInventory().getItemInMainHand().addEnchantment(enchantment, level);
    })
    .register();

Potion removing, suggesting potions that a player has currently

List<Argument<?>> arguments = new ArrayList<>();
arguments.add(new EntitySelectorArgument.OnePlayer("target"));
arguments.add(new PotionEffectArgument("potioneffect").replaceSafeSuggestions(SafeSuggestions.suggest(info -> {
    Player target = (Player) info.previousArgs().get("target");

    //Convert PotionEffect[] into PotionEffectType[]
    return target.getActivePotionEffects().stream()
            .map(PotionEffect::getType)
            .toList().toArray(new PotionEffectType[0]);
})));

new CommandAPICommand("removeeffect")
    .withArguments(arguments)
    .executesPlayer((sender, args) -> {
        Player player = (Player) args.get("target");
        PotionEffectType effect = (PotionEffectType) args.get("potioneffect");
        player.removePotionEffect(effect);
    })
    .register();

Subcommands

new CommandAPICommand("perm")
    .withSubcommand(new CommandAPICommand("group")
        .withSubcommand(new CommandAPICommand("add")
            .withArguments(new StringArgument("permission"))
            .withArguments(new StringArgument("groupName"))
            .executes((sender, args) -> {
                //perm group add code
            })
        )
        .withSubcommand(new CommandAPICommand("remove")
            .withArguments(new StringArgument("permission"))
            .withArguments(new StringArgument("groupName"))
            .executes((sender, args) -> {
                //perm group remove code
            })
        )
    )
    .withSubcommand(new CommandAPICommand("user")
        .withSubcommand(new CommandAPICommand("add")
            .withArguments(new StringArgument("permission"))
            .withArguments(new StringArgument("userName"))
            .executes((sender, args) -> {
                //perm user add code
            })
        )
        .withSubcommand(new CommandAPICommand("remove")
            .withArguments(new StringArgument("permission"))
            .withArguments(new StringArgument("userName"))
            .executes((sender, args) -> {
                //perm user remove code
            })
        )
    )
    .register();

Command trees

new CommandTree("perm")
    .then(new MultiLiteralArgument("group", "user")
        .then(new MultiLiteralArgument("add", "remove")
            .then(new StringArgument("permission")
                .then(new StringArgument("groupName")
                    .executes((sender, args) -> {
                        // args = ["group" or "user", "add" or "remove", permission, groupName]
                    })
                )
            )
        )
    )
    .register();
<su

Extension points exported contracts — how you extend this code

NativeProxyCommandSender (Interface)
A simple representation of Minecraft's CommandListenerWrapper, in the form of Bukkit's ProxiedCommandSender [13 implementers]
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/wrappers/NativeProxyCommandSender.java
ChainableBuilder (Interface)
@param The class extending this class, used as the return type for chain calls [15 implementers]
commandapi-core/src/main/java/dev/jorel/commandapi/ChainableBuilder.java
PaperNMS (Interface)
(no doc) [24 implementers]
commandapi-platforms/commandapi-paper/commandapi-paper-core/src/main/java/dev/jorel/commandapi/nms/PaperNMS.java
MockSpigotNMS (Interface)
(no doc) [3 implementers]
commandapi-platforms/commandapi-spigot/commandapi-spigot-test-toolkit/src/main/java/dev/jorel/commandapi/nms/MockSpigotNMS.java
ConsoleCommandExecutor (Interface)
A normal command executor for a ConsoleCommandSender
commandapi-platforms/commandapi-velocity/commandapi-velocity-core/src/main/java/dev/jorel/commandapi/executors/ConsoleCommandExecutor.java
AScoreHolderArgument (Interface)
Annotation equivalent of the ScoreHolderArgument
commandapi-annotations/src/main/java/dev/jorel/commandapi/annotations/arguments/AScoreHolderArgument.java
SpongeExecutable (Interface)
(no doc)
commandapi-platforms/commandapi-sponge/commandapi-sponge-core/src/main/java/dev/jorel/commandapi/SpongeExecutable.java
ConfigurationAdapter (Interface)
(no doc)
commandapi-plugin/src/main/java/dev/jorel/commandapi/config/ConfigurationAdapter.java

Core symbols most depended-on inside this repo

get
called by 1046
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/arguments/parser/function/ThrowingSupplier.java
register
called by 387
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandTree.java
executesPlayer
called by 345
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/BukkitExecutable.java
withArguments
called by 327
commandapi-core/src/main/java/dev/jorel/commandapi/AbstractCommandAPICommand.java
apply
called by 276
commandapi-platforms/commandapi-paper/commandapi-paper-core/src/main/java/dev/jorel/commandapi/arguments/CustomArgument.java
setOptional
called by 233
commandapi-core/src/main/java/dev/jorel/commandapi/arguments/AbstractArgument.java
getSource
called by 226
commandapi-core/src/main/java/dev/jorel/commandapi/commandsenders/AbstractCommandSender.java
get
called by 223
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkit.java

Shape

Method 4,362
Class 510
Function 213
Interface 113
Enum 13

Languages

Java94%
Kotlin6%
Python1%

Modules by API surface

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-26.1/src/main/java/dev/jorel/commandapi/nms/NMS_26_1.java106 symbols
commandapi-platforms/commandapi-paper/commandapi-paper-nms/commandapi-paper-api/src/main/java/dev/jorel/commandapi/nms/APITypeProvider.java102 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test-toolkit/src/main/java/dev/jorel/commandapi/nms/MockNMS.java92 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/nms/NMS.java92 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.20/src/main/java/dev/jorel/commandapi/test/ArgumentNMS.java88 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.20.5/src/main/java/dev/jorel/commandapi/test/ArgumentNMS.java88 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.20.3/src/main/java/dev/jorel/commandapi/test/ArgumentNMS.java88 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.20.2/src/main/java/dev/jorel/commandapi/test/ArgumentNMS.java88 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-1.21.9/src/main/java/dev/jorel/commandapi/nms/NMS_1_21_R6.java61 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-1.21.6/src/main/java/dev/jorel/commandapi/nms/NMS_1_21_R5.java61 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-1.21.11/src/main/java/dev/jorel/commandapi/nms/NMS_1_21_R7.java61 symbols
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-1.21.5/src/main/java/dev/jorel/commandapi/nms/NMS_1_21_R4.java59 symbols

For agents

$ claude mcp add CommandAPI \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact