Solved player.closeInventory

Discussion in 'Plugin Development' started by Zelerity, Nov 17, 2017.

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

    Zelerity

    Related code can be found here on Pastebin.

    Demostration
    It's much easier to show what happens exactly, rather than typing it out in an attempt to explain.


    Conclution
    Note that this happens when you close the inventory in any way, such as teleporting the player which will automatically close their inventory. Point is, it's not just the player.closeInventory() function.
    I'm sure there's a simple way of solving this that I have missed out on while trying to fix the issue. Suggestions and/or fixes are much appreciated. Cheers in advance.
     
  2. Offline

    Zombie_Striker

    @Zelerity
    Have you tried debugging? Does the event get called if you shiftclick? If it does, does it stop/return anywhere before you can cancel it? Is it just a graphical glitch?
     
  3. Offline

    Zelerity

    @Zombie_Striker
    The clickEvent is definitely called upon shift-clicking. It is designed for any interaction within the UI as far as I'm aware. Could be a graphical glitch, but at the same time - as seen in the video; the item is in the player's inventory, able to be moved around and be used.

    EDITED: I'm getting this error for some reason, not sure why and from what. Error Console Code
     
    Last edited: Nov 17, 2017
  4. Offline

    JustRendering

    I've had this problem. Just use something like world guard, or code it yourself, and make it so your not allowed to drop items. that should work
     
  5. Offline

    Zelerity

    @JustRendering
    I doubt that would solve the issue that I'm experiencing. Players should not be able to get these items out of the inventory itself, at all.
     
  6. Offline

    JustRendering

    i know, but item move event doesn't register everything!
    -hence item drop event
    if the player, your example picks up a item and drops it in less then a tick, the server never knows that the player did inventory click event!
     
  7. Offline

    Zombie_Striker

  8. Offline

    Zelerity

    I believe that I solved it own my own, after playing around with different method for way too long.
    It appears that it was indeed a graphical glitch/bug, all I had to do was to updateInventory() after cancelling the event.

    Anyhow, thank you for taking your time. Have a great day!
     
  9. Offline

    MightyOne

Thread Status:
Not open for further replies.

Share This Page