Chest Menu

Discussion in 'Plugin Development' started by Henriksen1000, Sep 23, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Henriksen1000

    Basically, I want to learn coding, I have learned some codes and now, I really want to know how I code a Chest Menu, like, you typing a command and it opens a Chest Menu with things you can click and hower and not movable. What is the codes I need to use to make it? btw, I know Chest Commands.
     
  2. Offline

    teej107

    @Henriksen1000
    1. InventoryClickEvent
    2. Check to see if the inventory is the correct inventory, the cancel the event
    3. Compare the ItemStack clicked and then run code.
     
  3. Offline

    stefvanschie

    @Henriksen1000
    Use Bukkit.createInventory() and use InventoryClickEvents (as said above) to check the clicking.
     
  4. Offline

    Davesan

    I usually write my own InventoryView object (which extends the mentioned interface), so when the event is called I check if the inventory is instance of my class. If it does, then I continue to handle it. This way the inventories can be any inventory, and the check is not instance-based, but class based, which is like 'universal' and faster than like checking if a list of inventories contains the one in the event.
    Code:
    public class MyInventoryView implements InventoryView { ... }
    
    ...
    public void onInventoryClick(InventoryClickEvent e) {
      if (!(e.getView() instanceof MyInventoryView)) return;
      //handle the custom menu whatever inventory it contains
      e.setCancelled(true);
      //do whatever you want.
      //the click informations like index is in the event (e) argument
      //in case of premade menus you usually use only the (raw)index
      //not even caring about which item you clicked
    }
    ...
     
  5. Offline

    Henriksen1000

    I still don't understand how I make a GUI like this and how I add items in it...
     
  6. Offline

    CrystallFTW

Thread Status:
Not open for further replies.

Share This Page