Itemstack arguments

The ItemStackArgument class represents in-game items. As expected, this should be casted to Bukkit's ItemStack object. The ItemStack which is returned by the ItemStackArgument always has a size of 1.

Example - Giving a player an itemstack

Say we want to create a command that gives you items. For this command, we will use the following syntax:

/item <itemstack>

With this syntax, we can easily create our command:

new CommandAPICommand("item")
    .withArguments(new ItemStackArgument("itemstack"))
    .executesPlayer((player, args) -> {
        player.getInventory().addItem((ItemStack) args[0]);
    })
    .register();