InventoryCloseEvent

Discussion in 'Plugin Development' started by CheesyFreezy, Jun 5, 2016.

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

    CheesyFreezy

    Hey,

    I am currently making a crates plugin. It works the same as the CS:GO crates where you need a key to open a crate. You will see all kinds of random items that you can get from the crate and at some point it will stop spinning. This whole process is begin done in a custom inventory or GUI as some people call it. The thing is: I want to make that when a player is currently spinning and they try to close the inventory it won't let them do it, because else they will lose a key and don't get an item from the spinning.

    Hopefully you guys will understand me!
     
  2. Offline

    Xerox262

    @CheesyFreezy Use the InventoryCloseEvent then cancel it to make it stay open
     
  3. Offline

    CheesyFreezy

    You can't cancel it. I'm not that new to the whole Java/BukkitAPI
     
  4. Offline

    Xerox262

  5. Offline

    CheesyFreezy

  6. Offline

    Xerox262

    @CheesyFreezy I'm an idiot, what about opening the inventory inside the close event?

    Ofcourse use an If before that.
     
  7. Offline

    CheesyFreezy

    I tried that, but because the inventory keeps on changing the plugin will bug out for some reason.
     
  8. Offline

    Xerox262

    @CheesyFreezy Bug out how? Have you tried delaying it by a tick so it's not right after the closing?
     
  9. Offline

    CheesyFreezy

    Because the inventory keeps on updating. It is an inventory where items keep cycling.
     
  10. Offline

    Xerox262

    @CheesyFreezy What if you change it so it doesn't cycle items while no one's looking? Using Inventory#getViewers()
     
  11. Offline

    CheesyFreezy

    What do you mean?
     
  12. Offline

    Xerox262

    @CheesyFreezy How're you swapping the items in the inventory? Surround it with an if, check the inventory viewers and if it has at least 1 then the inventory isn't closed.
     
  13. Offline

    CheesyFreezy

    I know how to check how to check if the inventory is closed or not, but I just want to know how to make that players can't close the inventory.
     
  14. Offline

    Xerox262

    @CheesyFreezy Yes, but if you make it stop updating, then you can reopen it when it's closed without buggyness.
     
Thread Status:
Not open for further replies.

Share This Page