Location argument

The LocationArgument class is used to specify a location in the command sender's current world. This allows the user to enter three numbers as coordinates, or use relative coordinates (i.e. the ~ and ^ operators)

The LocationArgument constructor requires a LocationType, which specifies the type of location that is accepted by the command.

LocationType.BLOCK_POSITION

Integer block coordinates. The suggested location is the coordinates of block you are looking at when you type the command. BLOCK_POSITION

LocationType.PRECISE_POSITION

Exact coordinates. The suggested location is the exact coordinates of where your cursor is pointing at when you type the command. PRECISE_POSITION

By default, the LocationArgument will use PRECISE_POSITION.

Example - Break block by coordinates command

LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();

//We want to target blocks in particular, so use BLOCK_POSITION
arguments.put("block", new LocationArgument(LocationType.BLOCK_POSITION));

CommandAPI.getInstance().register("break", arguments, (sender, args) -> {
    ((Location) args[0]).getBlock().setType(Material.AIR);
});