Solved Open another GUI when clicking on an item in a GUI

Discussion in 'Plugin Development' started by Brojoc, Jul 7, 2014.

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

    Brojoc

    Hello, I know how to make so that when you click an item in a GUI you for example get a "kit". But is there a way to do so that if you click an item, it will open a new inventory with new things (a new GUI)? And if so, how?
     
  2. Offline

    micrlink

    add
    Code:
    event.willClose(false);
    to the main menu
    and if you want the inventory to close after some are clicked add:
    Code:
    if(event.getName().equalsIgnoreCase("close")){
      event.getPlayer().closeInventory();
    }
     
  3. Offline

    Brojoc

    Thats not what I mean. When I have opened a GUI, there are some items and if I click one of them it will bring me to a new GUI with other different items. Like for example if I click the "easy level" button, a new GUI will show up with for example different maps you can choose.
     
  4. Offline

    fireblast709

    micrlink Where did you find event.willClose(boolean)?
     
  5. Offline

    micrlink

    sorry setWillClose(boolean)

    fireblast709 in the IconMenu.java class
     
  6. Offline

    fireblast709

    micrlink In other words a 3rd party GUI library, which might be worth noting
     
  7. Offline

    Brojoc

    Well i'm not using IconMenu.
     
  8. Offline

    micrlink

  9. Offline

    fireblast709

    micrlink I actually wondered how you concluded that he was using it xD.
    Brojoc InventoryClickEvent, schedule a task that closes the inv, and inside there schedule another task that opens the new inv.
     
  10. Offline

    Brojoc

    Doesnt work when I use InventoryClickEvent. What am I doing wrong here?
    Code:
    @EventHandler
    public void onPlayerClick (InventoryClickEvent evt){
       
        Player p = (Player) evt.getWhoClicked();
       
        if (!evt.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
        if (evt.getCurrentItem().getItemMeta() == null) return;
        if (evt.getCurrentItem().getItemMeta().getDisplayName().contains("Score")){
        p.closeInventory();
        p.openInventory(invvip);
    
     
  11. Offline

    Skye

    What I found works smoothest for switching to other inventory menus from within one is to rebuild the array of contents, and then set the inventory's contents to it.
     
  12. Offline

    caderape

    public Inventory gui;
    gui = "this tittle"
    And in ur event, if (player.getinventory.getname.equalignorecase(gui.getname){}
    if (e.getrawslot == 0 && e.getcurrentitem.gettype != null)
    player.openinventory(bukkit.createinventory(null, 9, "title"));

    then when player will click in the first slot, so the slot 0, it will open another inventory
     
Thread Status:
Not open for further replies.

Share This Page