Support and Project Discussion:
Downloads & Documentation:
Announcements:
đź’° The CommandAPI now has a donation link! Feel free to buy me a coffee here!
Compatible Minecraft versions:
1.13 versions | 1.13 | 1.13.1 | 1.13.2 | |||
1.14 versions | 1.14 (v2.0+) |
1.14.1 | 1.14.2 | 1.14.3 (v2.1+) |
1.14.4 | |
1.15 versions | 1.15 (v2.3a+) |
1.15.1 | 1.15.2 | |||
1.16 versions | 1.16.1 (v3.0+) |
1.16.2 (v4.0+) |
1.16.3 (v4.2+) |
1.16.4 (v5.2+) |
1.16.5 (v5.7+) |
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
-
Better arguments - Easily switch from Location arguments to raw JSON, fully supported with built-in error checking
-
Support for proxied command senders - Run your command as other entities using
/execute as ... run command
-
Argument tooltips - Let your users know exactly what their command will do
-
Support for the
/execute
command - Let your command to be executed by the built in/execute
command -
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 -
You don't need Brigadier - You don't need to import Brigadier in your projects to use the CommandAPI
-
No tracking - The CommandAPI don't collect any stats about its plugin; what you see is what you get!
In addition to all of the above:
- Built-in command converter - Convert regular plugin commands into
/execute
-compatible ones - no coding experience required! - Optional compile-time annotation-based framework - Don't like writing lots of code with builders? You don't have to if you don't want to!
- Insanely detailed documentation - Trust me, you've never seen a plugin documentation look so good.
(I always like to see code examples on GitHub repos, so here's what CommandAPI code looks like):
Simple command registration
new CommandAPICommand("enchantitem")
.withArguments(new EnchantmentArgument("enchantment"))
.withArguments(new IntegerArgument("level", 1, 5))
.executesPlayer((player, args) -> {
Enchantment enchantment = (Enchantment) args[0];
int level = (int) args[1];
//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("target", EntitySelector.ONE_PLAYER));
arguments.add(new PotionEffectArgument("potioneffect").safeOverrideSuggestions(
(sender, prevArgs) -> {
Player target = (Player) prevArgs[0];
//Convert PotionEffect[] into PotionEffectType[]
return target.getActivePotionEffects().stream()
.map(PotionEffect::getType)
.toArray(PotionEffectType[]::new);
})
);
new CommandAPICommand("removeeffect")
.withArguments(arguments)
.executesPlayer((player, args) -> {
EntityType entityType = (EntityType) args[0];
player.getWorld().spawnEntity(player.getLocation(), entityType);
})
.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();
Annotation-based commands
@Command("warp")
public class WarpCommand {
// List of warp names and their locations
static Map<String, Location> warps = new HashMap<>();
@Default
public static void warp(CommandSender sender) {
sender.sendMessage("--- Warp help ---");
sender.sendMessage("/warp - Show this help");
sender.sendMessage("/warp <warp> - Teleport to <warp>");
sender.sendMessage("/warp create <warpname> - Creates a warp at your current location");
}
@Default
public static void warp(Player player, @AStringArgument String warpName) {
player.teleport(warps.get(warpName));
}
@Subcommand("create")
@Permission("warps.create")
public static void createWarp(Player player, @AStringArgument String warpName) {
warps.put(warpName, player.getLocation());
new IntegerArgument("");
}
}
Command conversion (no compilation required)
plugins-to-convert:
- Essentials:
- speed <speed>[0..10]
- speed <target>[minecraft:game_profile]
- speed (walk|fly) <speed>[0..10]
- speed (walk|fly) <speed>[0..10] <target>[minecraft:game_profile]
The CommandAPI can be built easily, but requires copies of the Spigot server jars to be present locally on your machine in order to be compatible with any Minecraft version. The CommandAPI is built using the Maven build tool - if you don't have it, you can download it here.
-
Clone the repository using your preferred method, or with the command below:
git clone https://github.com/JorelAli/CommandAPI.git
-
Go into the folder named
CommandAPI
(Not to be confused with the folder namedCommandAPI
, which is what is cloned). You want the folder which containspom.xml
. -
Ensure you have the required spigot server jars (see below)
-
Run
mvn
To build the CommandAPI, the following versions of Spigot are required:
1.13 versions | 1.13 | 1.13.1 | 1.13.2 |
1.14 versions | 1.14 | 1.14.3 | 1.14.4 |
1.15 versions | 1.15 | ||
1.16 versions | 1.16.1 | 1.16.2 | 1.16.4 |
These versions of Minecraft must be installed in your local machine's Maven repository (~/.m2
). The easiest way to do this is to build them manually using Spigot's BuildTools, as it automatically adds it to the .m2
local repository folder.
- Download the
BuildTools.jar
file from here - Make sure you have maven installed on your machine. If not, it can be downloaded from here
- If on Windows:
- Download the
downloadSpigot.bat
file (right click this link, save as...) and place it in the same folder as theBuildTools.jar
- Double click on the
downloadSpigot.bat
file to run it
- Download the
- If on Linux/MacOS:
- Download the
downloadSpigot.sh
file (right click this link, save as...) and place it in the same folder as theBuildTools.jar
- Open up a terminal in your folder and make the
downloadSpigot.sh
file executable by usingchmod u+x ./downloadSpigot.sh
- Run the
downloadSpigot
file using./downloadSpigot.sh
- Download the
- Download the
BuildTools.jar
file from here and place it in a separate directory - Use the command
java -jar BuildTools.jar --rev <VERSION>
to download the specific version of the Spigot.jar you need. For example, to download Spigot for 1.14.4, usejava -jar BuildTools.jar --rev 1.14.4
The CommandAPI has somewhat reached a "stable" point in its lifecycle. It can basically do everything that it needs to do and has been able to keep up-to-date with the latest Minecraft versions (e.g. 1.16.5 support released within a day of 1.16.5 being released). The original goal was to release CommandAPI v6.0 sometime early 2021. As you can see, this hasn't happened yet.
So what went wrong? I over-planned v6.0. The plans for v6.0 was so excessive that it brought down motivation and has made such an update seem forever out of reach. For example, this was the list of all features planned for v6.0:
- A better (refined and rewritten) annotation system
- Optional arguments
- A way to add suggestions to existing suggestions
- Help page support
- Namespace support
- More powerful argument sanitization with earlier fail detection
- A continuous integration suite for public access to dev builds
- A testing suite to determine correctness and accuracy of the CommandAPI
- A rewrite of custom arguments
- More full plugin examples
- Conflicting argument research and documentation on how to avoid them
So where do we go from here? It's simple - we do one feature at a time and release one update for each feature. That way, we get more of the new stuff that people want and less of the "absolutely no development is going on". This is the current roadmap for the CommandAPI (as of 22nd Feb 2021):
-
CommandAPI v5.9: "Quick" version updating
Another proof of concept that I want to bring into fruition. Currently, the CommandAPI's version system goes along the lines of: When a new version of Minecraft comes out, you need to update your version of the CommandAPI with the latest version. This is an acceptable solution - it's not unreasonable for the CommandAPI to require a version-specific update when a new version comes out. The downside with this is the CommandAPI is always in constant development, so API changes occur (e.g. deprecation/refactoring of methods etc.) and bugs may be present in later versions. So to avoid this, releases from this point onwards which add additional support for future Minecraft versions will also release with a supported version
.class
file which can be shoved into your existing setup of the CommandAPI which will allow you to have support for newer versions of Minecraft without needing to update.(Of course, this isn't recommended, but it may benefit a few people and I think it's an interesting thing to add).
-
CommandAPI v5.10: PaperSpigot support and deprecations
PaperSpigot have recently announced that they are moving away from the BungeeCord API and it is pretty important that the CommandAPI updates in order to keep up with things. Additionally, PaperSpigot have changed their supported Java version to Java 11, from Java 8. Despite this, to ensure backwards compatibility with older Java versions, the CommandAPI will remain compiled for Java 8.
Lastly, in this update I want to deprecate a few methods to do with argument suggestions. The CommandAPI has a number of ways of populating argument suggestions using constant values, but more often than not this causes expected issues. As such, these will be deprecated in this version in favour of the existing lambdas. (Don't worry, updating is really really easy!)
-
CommandAPI v5.11: CustomArgument improvements
The CustomArgument class is fairly flexible, but nowhere near flexible enough. In this update, more attention will be focused on the CustomArgument class to provide it the ability to extend from all other argument types as a base.
-
CommandAPI v5.12: Annotation improvements
The CommandAPI's annotation system has always been a bit limited and was primarily introduced as a proof-of-concept. In this update, the CommandAPI's annotation system will be improved to be (ideally) as powerful as the non-annotation system and have slightly better type safety.
-
CommandAPI v5.13: Argument conflict detection
The CommandAPI simply uses the Brigadier system under the hood. This system is prone to argument conflicts, which is where certain arguments are given priority over other arguments. (For example "hello" and "123" are both valid string arguments, but if you have a command that has a string argument or an integer argument, Brigadier may ignore the integer argument). In this update, the CommandAPI will try to spot potential conflicts and add a warning in the console. The research required for this is also required in order to implement optional arguments (which is not coming out in this release).
-
CommandAPI v5.14+: TBD
Version | Date | Features / Changes |
---|---|---|
5.8 | January 2021 |
|
5.7 | January 2021 |
|
5.6 | January 2021 |
|
5.5 | January 2021 |
|
5.4 | December 2020 |
|
5.3 | November 2020 |
|
5.2 | November 2020 |
|
5.1 | October 2020 |
|
5.0 | October 2020 |
|
4.3c | October 2020 |
|
4.3b | September 2020 |
|
4.3a | September 2020 |
|
4.3 | September 2020 |
|
4.2 | September 2020 |
|
4.1 | September 2020 |
|
4.0 | August 2020 |
|
3.4 | July 2020 |
|
3.3 | July 2020 |
|
3.2 | July 2020 |
|
3.1 | July 2020 |
|
3.0 | June 2020 |
|
2.3a | December 2019 |
|
2.3 | August 2019 |
|
2.2 | July 2019 |
|
2.1 | July 2019 |
|
2.0.1 | May 2019 |
|
2.0 | May 2019 |
|
1.8.2 | January 2019 |
|
1.8.1 | December 2018 |
|
1.8 | December 2018 |
|
1.7.2 | December 2018 |
|
1.7.1 | December 2018 |
|
1.7 | December 2018 |
|
1.6 | November 2018 |
|
1.5 | October 2018 |
|
1.4 | October 2018 |
|
1.3 | October 2018 |
|
1.2 | August 2018 |
|
1.1 | August 2018 |
|
1.0 | August 2018 |
|