InventoryClickEvent not always being called

Discussion in 'Plugin Development' started by Kazzababe, Jul 31, 2013.

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

    Kazzababe

    My situation:
    I have a custom inventory and I have the player open it. I want it to be cancelled if they click on certain slots in the inventory. More often then not, when they click those spots, it is cancelled like I'd like it to be, but there's always that one rare occasion where if I click enough, the item will get placed into the inventory instead of being cancelled like it should.
     
  2. Offline

    xTrollxDudex

    Kazzababe
    Why the checks? There is something else that can click the inventory? Try just sending click to the person who clicked without checkimng
     
  3. Offline

    Kazzababe


    I added a message to be sent to the console before checking if the humanentity was a player, and it's for sure being called. Now to figure out why it's not registering it's a player.
     
  4. Offline

    xTrollxDudex

    Kazzababe
    Try sending on one line?
    PHP:
    ((Playerevent.getWhoClicked()).sendMessage("CLICK!")
     
  5. Offline

    Kazzababe

    xTrollxDudex
    Well, new problem.
    Is there another method of cancelling this event? I have event.setResult(Result.DENY); and event.setCancelled(true);
    I've used them each separately and both of them at the same time, and there is always that one time when it doesn't get cancelled like I want it to.

    My situation:
    I have a custom inventory and I have the player open it. I want it to be cancelled if they click on certain slots in the inventory. More often then not, when they click those spots, it is cancelled like I'd like it to be, but there's always that one rare occasion where if I click enough, the item will get placed into the inventory instead of being cancelled like it should.
     
  6. Offline

    xTrollxDudex

    Kazzababe
    Try closing the inventory them cancelling it
     
  7. Offline

    Kazzababe

    xTrollxDudex
    What good would that do? The inventory should stay open as I'd rather it not be that the player has to re-open it every time.
     
  8. Offline

    xTrollxDudex

    Kazzababe
    Well if the inventory is closed you can't exactly glitch an item into it (or can you?). You can always reopen the inventory after closing it :)
     
  9. Offline

    Kazzababe

    xTrollxDudex
    Hmmm, maybe, but I'd still just like to know why just cancelling the event isn't working.
     
  10. Offline

    xTrollxDudex

    Kazzababe
    Eventually after clicking very fast java can't keep up?
     
  11. Offline

    Kazzababe

    xTrollxDudex
    I don't think thats it. I could wait for 10 seconds in between each click and eventually it would still happen.
     
  12. Offline

    xTrollxDudex

    Kazzababe
    Hmmm. Maybe bukkit sided? It still is in development
     
  13. Offline

    Kazzababe

  14. Offline

    ampayne2

    I think the actual item wouldn't be in your inventory, like jukebox cd glitching etc.
    Its just a "ghost" item that only appears to the player and will go away if they relog, reopen their inventory, or update it in some way. Shouldn't be a problem if the server knows you don't actually have the item.
     
  15. Kazzababe
    There is a plugin out there i believe that allows your to set ItemMeta that won't be visible to players. So you could give those items a hidden thing saying like "NoTake!" and check if item entering the player inventory has that ItemMeta.
    P.S. actually come to think about it I don't even know if an event like that exists =/ Oh well hope this helps you think of some solutions.
    Edit: ampayne2 I don't think that is true because shotbow.net server had this problem for a while and the items you could get out of the their inventory menus would be perfectly functionable.
    Edit again: Maybe try looking at IconMenus way of doing things.
     
  16. Offline

    Kazzababe


    I've tested that out with an alternate account and that is most definitely not the case.
     
  17. Offline

    xTrollxDudex

    Kazzababe
    player.getInventory().update()?
     
  18. Offline

    Kazzababe


    Apparantly, it will occasionally bug out if you're comparing inventory name's to make sure they're the same.
    Example:
    Custom inventory name = "Lol"
    When it is checking the InventoryClickEvent, I have it compare event.getInventory().getName() to the custom inventory name. Once I removed that, it work's perfectly but I have no real way of making sure they're the same inventory now.
     
  19. Offline

    dunbaratu

    I've found that sometimes an inventorydrag event is triggered instead of an inventoryclick event, if the user happens to move the mouse slightly while clicking. People have claimed that all drags events also have click events to go with them, but this has not been my experience.
     
    tangster132 and Limeth like this.
  20. Offline

    BDKing88

    Kazzababe
    I'm having the same problem! If I find out whats wrong, I'll comment it :) .
     
  21. Offline

    Kazzababe


    This may be the case in some situtations but I have a message being sent to the player in InventoryClickEvent and everytime it doesn't work, they still get the message.
     
  22. Offline

    Limeth

    That solved my problem! Thanks a lot! ;)
     
Thread Status:
Not open for further replies.

Share This Page