GuiStateElement element = new GuiStateElement('z', new GuiStateElement.State( change -> { change.getEvent().getWhoClicked().setFlying(true); change.getEvent().getWhoClicked().sendMessage("You are now flying!"); }, "flyingEnabled", // a key to identify this state by new ItemStack(Material.WOOL, 1, 5), // the item to display as an icon ChatColor.GREEN + "Enable flying!", // explanation text what this element does "By clicking here you will start flying" ), new GuiStateElement.State( change -> { change.getEvent().getWhoClicked().setFlying(false); change.getEvent().getWhoClicked().sendMessage("You are no longer flying!"); }, "flyingDisabled", new ItemStack(Material.WOOL, 1, 14), ChatColor.RED + "Disable flying!", "By clicking here you will stop flying" ) ); # Set the current state if (player.isFlying()) { element.setState("flyingEnabled"); } else { element.setState("flyingDisabled"); } gui.addElement(element);