Cancelling InventoryClickEvent seems to cause double events

Discussion in 'Spigot Plugin Help' started by Kyptoric, Jul 1, 2018.

  1. In short, I'm making a plugin that involves upgrading item by dragging upgrades on top of them. What I want to do is detect whenever an upgrade item is dragged on top of an item that can be upgraded, then apply the upgrade to that item and delete the upgrade item. I tried to do that by cancelling the event once I detected that I needed to apply an upgrade. However cancelling the event seems to make it trigger a second time, so it ends up making it so that my upgrade is applied twice. I am pretty sure cancelling the event is the main cause of this since, if I don't cancel it, no double events happen.

    I've tried alternatives such as not cancelling the event but instead setting the cursor item to air, but that just led to another problem and trying to fix that problem just led to even more problems. In the end, I wasn't able to find an alternative.

    Does anyone have any idea as to why this happens and/or have a solution for it?