player.closeInventory(); without fireing event

Discussion in 'Plugin Development' started by Banjer_HD, Aug 26, 2017.

Thread Status:
Not open for further replies.
  1. Hello Bukkitors!

    I made a GUI that prompts the player to fill in a number, and if they hit continue I do: "player.closeInventory();"
    But when the player presses ESC it 'cancels' but I dont want them to have a opportunity to cancel, is it possible to not fire the InventoryCloseEvent when I do 'player.closeInventory();' in my code, but it gets fired when the player closes the inventory them selves?

    Thanks for reading!
     
  2. Offline

    Horsey

    I believe you can use ((CraftPlayer) player).getHandle().x(); the method name might have changed, decompile the craftbukkit jar to check.
     
  3. It doesn't seem to work....
     
  4. Offline

    Horsey

    Did you check what the correct method is for your version?
     
  5. I'd simply recommend making a wrapper or hashmap if that's your kind of thing that encloses the player, and a Boolean (If it's a wrapper, make a separate method, rather than ) . when Triggering the PlayerCloseInventory event, get the boolean value, and if it is true, don't cancel it.


    (Set the Boolean value by the item click part of the event)
     
    Last edited: Aug 26, 2017
Thread Status:
Not open for further replies.

Share This Page