Itemstack arguments
The ItemStackArgument
class represents in-game items. As expected, this should be casted to Bukkit's ItemStack
object.
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 structure:
/item <itemstack>
With this structure, we can easily create our command:
new CommandAPICommand("item")
.withArguments(new ItemStackArgument("itemstack"))
.executesPlayer((player, args) -> {
player.getInventory().addItem((ItemStack) args[0]);
})
.register();