Code (Java): package me.main; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; public class AdminToolEvents implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent e) { ClickType clickType = e.getClick(); if (clickType != ClickType.LEFT) { return; } if (e.getCurrentItem() == null || e.getCurrentItem().getType() != Material.NETHER_STAR) { return; } Player player = (Player) e.getWhoClicked(); openGUI() } }
What exactly is your question? You can check for a rightclick with InventoryClickEvent#isRightClick() which will simply return true when the slot is right clicked.
i just want to do rightclick with a netherstar and open a gui and i dont have a method because i dont know how
Do you want to open a gui when the player clicks a nether star that's in an inventory or when the player uses a nether star in their hand? If the latter, you should use the PlayerInteractEvent.
Get the player from Player p = e.getPlayer(); Then check p.getHand or p.getItemInHand (whatever it is), .equals(Material.NETHER_STAR), then open the GUI.
Create a gui method into another class like public void OpenGui(Player p){ under this section you set up your GUI with items,names,lore ecc then create a class with InventoryClickEvent as DrConfig said previously and call the method from the other class to open your gui like if(p.getiteminhand == Material.Nether_Start){ plugin.guiclassname.OpenGui(p);