Weird InventoryClickEvent behavior

Discussion in 'Plugin Development' started by Greenlock28, Aug 13, 2014.

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

    Greenlock28

    I am running this code in my plugin (Bukkit 1.7.9-r0.2-beta and higher):

    Code:java
    1. @EventHandler(priority=EventPriority.LOW)
    2. public void onInventoryClick(InventoryClickEvent event) {
    3. if (event.getCurrentItem() != null &&
    4. event.getCurrentItem().hasItemMeta() &&
    5. event.getCurrentItem().getItemMeta().hasDisplayName() &&
    6. event.getCurrentItem().getItemMeta().getDisplayName().equals("ยง6Wallet")) {
    7. event.setCancelled(true);
    8. }
    9. }


    This event handles itself fine the first time that I click my "Wallet": the item falls back into its slot as if nothing ever happened. If I click the same item again directly afterwards, however, I can pick it up. Inserting debug stuff indicates that the event is actually never fired again the second time.

    If I attempt to pick up the Wallet (first click; the event fires) and then click another empty slot, the event is fired when I click the Wallet again. I suppose that means that some sort of ghost item is on the cursor or something after I cancel the event. Setting the player's item-on-cursor to 'null' after cancelling the event doesn't have any effect on the behavior, however.

    Thoughts?
     
  2. Offline

    Greenlock28

    That is helpful to know, however it does not seem to fix the problem.

    Is this perhaps a bug that I need to report?
     
Thread Status:
Not open for further replies.

Share This Page