BlockState arguments

The BlockStateArgument is used to represent data about blocks in the world. These refer to any blocks that have data or states, such as dispensers, signs, doors and pistons. The BlockStateArgument creates a Bukkit BlockState object when used.
Example – Setting a block
Example – Setting a block
Say we want a simple command to set the block that you're looking at. We'll use the following command syntax:
mccmd
/set <block>And then we can simply set our block using setBlockData():
java
new CommandAPICommand("set")
.withArguments(new BlockStateArgument("block"))
.executesPlayer((player, args) -> {
BlockState blockState = (BlockState) args.get("block");
Block targetBlock = player.getTargetBlockExact(256);
// Set the block, along with its data
targetBlock.setType(blockState.getBlockData().getMaterial());
targetBlock.getState().setBlockData(blockState.getBlockData());
})
.register();