Opening a GUI / Double Chest GUI

Discussion in 'Plugin Development' started by DatCookiez, Jan 15, 2014.

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


    Hey guys!

    I was just wondering if there were any threads on how to open a GUI, can't seem to find any, I'm looking to make something when I right click a stick for example, it opens an inventory (double chest size) and it has other items in there which players can then click to get different kits etc.

  2. Offline


    yes there is . Here it is in simple form.

    Well i hope you know how to use listeners .

    Create a listener that waits for the clicking of the stick and make it run this.

    Inventory inv = Bukkit.getServer().createInventory(null, 54, "Kit Selector");

    the 54 tells it to be a double chest size . The "Kit Selector " just names the inventory.

    then in the same listener run .

    XvBaseballkidvX likes this.
  3. Offline


    Thank you, but how would I add items into this inventory?
  4. Offline


  5. Offline


  6. Offline


    I had no idea how to listen towards the stick, but I just guessed and got it straight away :) Just trial and error TheLexoPlexx
  7. Offline


    TheLexoPlexx One teaches how to make the menus, the other is a utility to manage all of that with ease and cleaner code. However iconmenu has a listener bug and you have to destroy the listeners every open. Its better and simpler to just make your own. And if you can't figure it out from that, well then please learn Java.
  8. Offline


    Also, does anyone know how to check if a player clicks on an item in this GUI slot? I need to send a message and items to that player when they click a certain item in the GUI
  9. Offline


    That isn't a bug, it's how the class is supposed to work. It's just that too many people don't seem to read the description in the initial post. I quote:
  10. Offline


    Create an inventory with:
    1. Inventory GUI = Bukkit.createInventory(<Player player>, <Integer size>, <String name>);

    Then to add an item:
    1. GUI.setItem(<Integer slot>, <ItemStack item>);

    To register clicks in the inventory create a Listener that registers the InventoryClickEvent.
    Check if the name of the inventory corresponds with your GUI that's all that's to it! :)
    1. if(e.getInventory().getName().equals(<GUI name>)){
    2. if(e.getSlot() == <Specific slot>){
    3. YOUR CODE
    4. }
    5. }
    TheLexoPlexx likes this.
  11. Offline


    Could I be able to make a separate class and register the .getSlot() to that class?
  12. Offline


    THATS what I wanted. And I was jus too stupid to make it. THANKS mate![​IMG]
Thread Status:
Not open for further replies.

Share This Page