Player interaction: RIGHT_CLICK_AIR events always arrive cancelled?

Discussion in 'Plugin Development' started by desht, Feb 28, 2012.

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

    desht

    RIGHT_CLICK_AIR events have always been a little funny, but I'm sure they were working well until recently. I know at one point they didn't work at all, and then they worked fine, and now...

    My PlayerInteractEvent handler is getting the events, but when the event type is RIGHT_CLICK_AIR, event.isCancelled() is always true, so my plugin takes the reasonable course of ignoring it. I know it's not being cancelled by any other plugin, since I've tested on a server with no other plugins. So it seems like Bukkit's doing this. Why?

    Anyone else seen this behaviour, can confirm or deny it?

    This is with 1.1-R4 (1938). The R5 change log doesn't suggest any event-related fixes.

    Update: LEFT_CLICK_AIR events always arrive cancelled too, and the behaviour persists in R5 build 1964. I'll post a report on leaky but it would be nice to know I'm not the only one seeing this.

    Update 2: looking at the Bukkit source, it seems this might be deliberate. PlayerInteractEvent#isCancelled() returns true if useInteractedBlock() == Result.DENY, and useInteractedBlock() returns the value of useClickedBlock, which is initialised to Result.DENY by the constructor when the clickedBlock == null, i.e. whenever you (left or right) click air. This seems a bit bizarre, anyone feel like explaining it? :) Conflating the plugin-specified cancellation state of the event with default DENY/ALLOW flags has a code smell about it.
     
Thread Status:
Not open for further replies.

Share This Page