Annotation/Reflection Based Command API that just does what you want it to do without any problems.
- Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository <dependency>
<groupId>com.github.therealdamt</groupId>
<artifactId>commandapi</artifactId>
<version>1.4.0</version>
</dependency>- Gradle
repositories {
...
maven { url 'https://jitpack.io' }
}dependencies {
implementation 'com.github.therealdamt:commandapi:1.4.0'
}- Example main class
publicclassMainextendsJavaPlugin {
@OverridepublicvoidonEnable() { // You also have the default tab completer, and the default help service, new DefaultTabCompleter(); newCommandHandler(this).bind(ItemStack.class, newItemStackProvider())
.register(newFlyCommand(), newItemStackCommand()).helpService(newHelpService())
.tabComplete(newTabCompleter()).registerCommands();
}
}- Example command class
publicclassItemStackCommand {
@Command(value = "kekw", async = true, usage = "/kekw itemStack", description = "Just makes an itemstack lol")
@Permission(permission = "kekw.kekew", message = "no perm noob")
publicvoiditemStackCommand(@SenderPlayerplayer, @Name("itemStack") ItemStackitemStack) {
player.getInventory().addItem(itemStack);
player.sendMessage(ChatColor.GREEN + "Gave ya your itemstack!");
}
}- Example provider
publicclassItemStackProviderimplementsCommandProvider<ItemStack> {
@OverridepublicItemStackprovide(Strings) throwsCommandProviderNullException {
Materialmaterial = Material.getMaterial(s.toUpperCase());
if (material == null)
thrownewCommandProviderNullException(ChatColor.RED + "It seems like you did not provide a valid material.");
returnnewItemStack(material);
}
}- Example Help Service
publicclassHelpServiceimplementsHelpCommandService {
@OverridepublicList<String> get(Commandcommand, List<Command> subCommands) {
returnsubCommands
.stream()
.map(command1 -> command.getUsage() + ", ")
.collect(Collectors.toList());
}
}- Example Tab Completer
publicclassTabCompleterimplementsTabComplete {
@OverridepublicList<String> get(Commandcommand, List<Command> subCommands, String[] args) {
returnsubCommands
.stream()
.map(subCommand -> subCommand.getName() + "\n")
.collect(Collectors.toList());
}
}You have full rights to use this command api within your projects, but if possible to include credits that'd be amazing!
Discord: bingbongwaseem