Solved Removing item on cursor after an InventoryClickEvent

Discussion in 'Plugin Development' started by Cryptite, Jan 30, 2014.

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

    Cryptite

    Perhaps it's best that I start with the real-world case. Say I have an inventory filled with snowballs (could pretend we're playing Minesweeper here). Upon clicking one of of the snowballs, I'd like to then change that slot's item to a different Material - easy enough. However upon doing that, now I have a snowball 'in hand/on the cursor'. I've tried a variety of things here and there but none of them seem to succeed in actually clearing the snowball in hand completely. I've tried setItemOnCursor (with and without a tick delay), cancelling the event, etc. No luck.

    Any ideas how one might accomplish this?
     
  2. Offline

    mattrick

    Cryptite
    Have you tried setItemInCursor(null); ?
     
  3. Offline

    Cryptite

    Yep, that was one of the first things I tried.
     
  4. Offline

    DoctorDark

    Cryptite

    Try closing the inventory, then opening the inventory the player was in again.
     
    Cryptite likes this.
  5. Offline

    MOMOTHEREAL

    mattrick An ItemStack cannot be null.
    DoctorDark Yes, that works. But if the server lags it could be a little awkward :p
     
  6. Offline

    Havime

    Could you cancel the event and remove the item from their inventory?
     
  7. Offline

    mattrick

    MOMOTHEREAL
    No, set the ItemInHand to null, not new ItemStack(null)
     
  8. Offline

    Cryptite


    This worked. Somewhat inelegant, but it works.
     
Thread Status:
Not open for further replies.

Share This Page