Solved InventoryClickEvent help

Discussion in 'Plugin Development' started by KingFaris11, Apr 23, 2014.

Thread Status:
Not open for further replies.
  1. Hi, I'm creating a GUI (Inventory). To create an inventory instance I use:
    Code:
    this.inventory = Bukkit.getServer().createInventory(this.player, 9, this.inventoryTitle);
    Although, in the InventoryClickEvent - it is also called when a player clicks on their inventory and not JUST the chest inventory as opening this inventory would show both inventories. How can I detect if the player clicked on the top inventory (the chest inventory) and not the bottom inventory (player's inventory)?
    I've tried:
    Code:
    if (event.getInventory().getTitle().equals(this.inventoryTitle) && event.getInventory().getSize() == 9) {
    But that still runs even when the player clicks on their inventory.
     
  2. Offline

    agent6262

    try
    Code:java
    1. event.getView().getTopInventory()
     
  3. Will test - seems logical - awesome! BRB.

    Edit: But how would I check if the inventory where the item is clicked is the top inventory?

    I've been given this to work with:
    Code:
    event.getRawSlot() < event.getView().getTopInventory().getSize()
    Going to test.

    Works - thanks for your suggestion agent6262

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Mr.PuddinPop

    wat u need to do is this:

    Code:java
    1. public boolean void(){
    2. return static;
    3. }
    4.  


    taht is wat i do
     
    KingFaris11 likes this.
  5. Even more logical! Works!!!!!!
     
Thread Status:
Not open for further replies.

Share This Page