Dropping an item while not targeting a block causes spigot to publish a PlayerInteractEvent to the event handlers.
This bug, at least in my opinion, is rather game breaking for most plugins which now execute logic when the player drops as well as at the intended point when the player actually left clicks the air.
Steps to reproduce:
- Get the latest version of spigot
- Register a listener for the PlayerInteractEvent in a plugin
- InGame; Drop an itemstack from your inventory hotbar using the hotkey 'q' (if configured so) while NOT looking at a block.
- Your plugin's listener now received a PlayerInteractEvent with the Action LEFT_CLICK_AIR.
Notes:
As I currently do not have the time to actually fix this myself I did some digging anyway.
My current guess on the culprit (I repeat, guess) would be:
1.15.2 plays a player arm swing animation whenever the player drops an item.
This causes PlayerConnection#a(PacketPlayInArmAnimation) to be executed, which is used to even catch any LEFT_CLICK_AIR interactions.
This method currently does not know if the animation was played because the player left clicked or dropped an item and therefore calls both.
- duplicates
-
SPIGOT-5435 Hand calls twice PlayerInteractEvent when using potions
- Resolved
- is duplicated by
-
SPIGOT-5974 PlayerInteractEvent fired for certain inventory clicks
- Open
-
SPIGOT-5634 PlayerInteractEvent fires when item is dropped
- Resolved
-
SPIGOT-5661 Dropping Item fires wrong event
- Resolved
-
SPIGOT-5904 PlayerDropItemEvent fires PlayerInteractEvent Action LEFT_CLICK_AIR
- Resolved