Aliases

Aliases for commands can be added by using the withAliases() method when registering a command. Aliases allow you to run the same command with a different 'name' from the original registered command name.

Example - Using aliases for /getpos

In this example, we register the command /getpos that returns the command sender's location. We apply the aliases /getposition, /getloc, /getlocation and /whereami as well, using the withAliases() method.

new CommandAPICommand("getpos") // Declare your aliases .withAliases("getposition", "getloc", "getlocation", "whereami") // Declare your implementation .executesEntity((entity, args) -> { entity.sendMessage(String.format("You are at %d, %d, %d", entity.getLocation().getBlockX(), entity.getLocation().getBlockY(), entity.getLocation().getBlockZ()) ); }) .executesCommandBlock((block, args) -> { block.sendMessage(String.format("You are at %d, %d, %d", block.getBlock().getLocation().getBlockX(), block.getBlock().getLocation().getBlockY(), block.getBlock().getLocation().getBlockZ()) ); }) // Register the command .register();