Button clicks can be handled using the onClick(Consumer<Click>) method:
Button button =Button.of(ItemType.DIAMOND).onClick(click -> {Audience clicker =click.clicker(); // who clickedClickType type =click.type(); // click type (left, right, etc)if (clicker instanceofPlayer player) {// check if the clicker is a player } });
val button = Button.of(ItemType.DIAMOND) .onClick { click ->val clicker = click.clicker() // who clickedval type = click.type() // click type (left, right, etc)if (clicker is Player) {// check if the clicker is a player } }