Getting Inventory in InventoryClickEvent

Discussion in 'Plugin Development' started by ZephireNZ, Apr 30, 2014.

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

    ZephireNZ

    I'm wanting to work out which inventory (top or bottom) a player clicked in the InventoryClickEvent. I know that you can use getRawSlot() to get the slot that's specifically for that view, and I know that can then be used to get the item at that slot. However, is there any way to work out which inventory was clicked?
     
  2. Offline

    joeygallegos

    ZephireNZ Use click events to check if the item (with lore check for better results) was clicked, then use usep.closeInventory(current); then p.openInventory(next);

    Edit: misunderstood question
     
  3. Offline

    hintss

    if getRawSlot() is < the size of the top inv, then they clicked the top one
     
  4. Offline

    Plo124

    joeygallegos
    If you close the inventory then open it quickly, the mouse location is reverted to the center. This is terrible if you are trying to update the lore on an item and resend the inventory like that.

    ZephireNZ
    I think you can do event.getInventory().getTopInventory()
     
  5. Offline

    ZephireNZ

    Plo124 I was meaning which part of the inventoryview they clicked (ie whether they clicked their own inventory, or the chest, for example)
     
  6. Offline

    Plo124

    ZephireNZ
    Their inventory is the bottom inventory, the chest is the top.
     
  7. ZephireNZ Other than with the raw slot, I don't believe you can.
     
  8. Offline

    desht

    Take a look at http://jd.bukkit.org/dev/apidocs/org/bukkit/inventory/InventoryView.html#convertSlot(int):
     
  9. Offline

    ZephireNZ

    desht Ah, that looks like it'll do the trick! Thanks :D
     
Thread Status:
Not open for further replies.

Share This Page