Solved Open an Inventory inside of an Inventory

Discussion in 'Plugin Development' started by TheDiamond06, Mar 21, 2016.

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

    TheDiamond06

    I am trying to open an inventory when the player is inside of one. I have a GUI where if I click back it will go back to the previous inventory GUI. However, all it does is close all GUI's. Here is the code I am using and I have debugged to make sure that it is reading the code this far:
    Code:
            Player p = (Player) e.getWhoClicked();
            p.playSound(p.getLocation(), Sound.CHEST_CLOSE, 1, 1);
            p.openInventory(amMenu);
    
    amMenu is a real menu and is working. This menu is opened before they can get to the second menu. When they go back from the second menu I need to to go back to the first menu. The code above is what I am using. However, like I said before it just closes all menus.

    Things to mention: The event is cancelled, the code is getting to the piece I showed above.

    NOTE: I have tried checking google and nothing I could find would help me with this.
     
  2. When opening another inventory, make sure you close opened ones first!
    Code:
    player.closeInventory();
    player.openInventory(amMenu);
    
     
  3. Offline

    TheDiamond06

    Doing this is not needed, I have already tried this and had no luck. That was a thing I forgot to mention.
     
  4. Offline

    Lordloss

    @Sulphate thats totally wrong.

    @TheDiamond06 the code you showed dont seem to be the cause, i think the open event gets cancelled from somewhere else, or the inventory gets closed instantly. Please give the rest of the code.
     
  5. Offline

    TheDiamond06

    I have found the problem. Since you said show the rest of the code I realized that I did not return the code after this snippet. Now the problem is solved. That was a huge mistake on my part.
     
Thread Status:
Not open for further replies.

Share This Page