CarouselSelector
  • Introduction
  • Introduction
    • Installation
  • In Game Documentation
    • Commands
    • Custom player head
    • Click animations
    • Custom model data
  • API Documentation
    • JavaDoc
    • CarouselSelectorPlugin.class
    • CarouselSelector.class
    • Open a 3D-Menu
Powered by GitBook
On this page

Was this helpful?

  1. API Documentation

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);
        }
    }
}
PreviousCarouselSelector.class

Last updated 1 year ago

Was this helpful?