A command API for Spigot/Bukkit for 1.14
Shard was created because, as I was making a lot of commands, I realized how tedious it is to make subcommands. Shard supports not only subcommands, but more vanilla style commands with no subcommands. This library was highly based on Lucko's command API for LuckPerms.
- Simple subcommand structure
- New tab completion API
- Vanilla style commands for simple command uses
Shard is not currently deployed anywhere, so you must install it manually:
mvn clean install
Once installed, you can add it to your project:
<dependencies>
<dependency>
<groupId>adiitya.spigot</groupId>
<artifactId>shard</artifactId>
<version>@VERSION@</version>
</dependency>
</dependencies>
Creating a simple command:
import adiitya.shard.SingleCommand;
import adiitya.shard.completion.TabCompleter;
import java.util.List;
import org.bukkit.command.CommandSender;
public class ExampleCommand extends SingleCommand {
public ExampleCommand(JavaPlugin plugin) {
super(plugin, "example", "[page]");
}
@Override
public void execute(CommandSender sender, List<String> args) {
int page = args.isEmpty() ? 0 : Integer.parseInt(args.get(0));
// more logic here
}
@Override
public List<String> tabComplete(CommandSender sender, List<String> args) {
return TabCompleter.empty();
}
}
Using the tab completion API:
@Override
public List<String> tabComplete(CommandSender sender, List<String> args) {
return new TabCompleter()
.add(0, new TabCompletion("yes", test -> "yes".startsWith(test)))
.add(0, new TabCompletion("no", test -> "no".startsWith(test)))
.get(args); // this will parse the args and return a list of valid completions
}