[SPIGOT-3609] Cancelling PlayerInteractAtEntityEvent doesn't cancel villager trading menu Created: 15/Oct/17 Updated: 28/Oct/19 Resolved: 28/Oct/17 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Stef van Schie | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | entity, event | ||
Environment: |
Version 1.12.2, Spigot. |
Issue Links: |
|
Description |
When cancelling a PlayerInteractAtEntityEvent when clicking on a villager, the trading menu still opens. I assume this is incorrect behaviour as the setCancelled method, should cancel the event like nothing happened. Here is the code I used to test this: @EventHandler(priority = EventPriority.MONITOR) public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent e) { System.out.println("Cancelled"); e.setCancelled(true); } "Cancelled" does appear in the console, but the trading menu still opens. |
Comments |
Comment by Stef van Schie [ 15/Oct/17 ] |
Yeah, if this isn't possible to easily implement, deprecating the method or just mentioning that it doesn't always work like expected would definitely be useful. |
Comment by Black Hole [ 15/Oct/17 ] |
That would mean to change a lot of vanilla packet handling code to meet that expectation. So I think it's better to add some JavaDoc. |
Comment by Stef van Schie [ 15/Oct/17 ] |
Well the PlayerInteractAtEntityEvent is called as well, so it's a bit weird that the implementation for setCancelled doesn't work. Even if two packets are sent, I would expect both of the setCancelled methods to be working, not just one of them. |
Comment by Black Hole [ 15/Oct/17 ] |
The client send two packets, leading to two events: one PlayerInteractEntityEvent and one PlayerInteractAtEntityEvent. Only the PlayerInteractEntityEvent matters for villagers. |