Open a 3D-Menu

Here's an example of how to open a 3D menu for a player

public class Main extends JavaPlugin implements Listener {

    private CarouselSelectorPlugin instance;
    
    @Override
    public void onEnable() {
        instance = CarouselSelectorPlugin.getInstance();
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        Action action = event.getAction();
        ItemStack item = event.getItem();
        
        if (item != null && item.getType() == Material.DIAMOND && (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)) {
            Menu menu = new Menu(player, "Menu title");

            this.instance.getApi().open(menu);
        }
    }
}

Last updated