Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

41 Commits

Repository files navigation

CommandAPI

Annotation/Reflection Based Command API that just does what you want it to do without any problems.

Importing

  • 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'
}

How to use

  • 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());
}
}

Credits

You have full rights to use this command api within your projects, but if possible to include credits that'd be amazing!

Contact

Discord: bingbongwaseem

About

Annotation/Reflection Based Bukkit Command API. Containing many features such as help-service, command providers, tab completion, and many more!

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages