When using PlayerInteractAtEntityEvent, it does not cancel the interaction with regards to opening the Wandering Trader and regular Villager gui. Even when cancelled, the gui will still open.
Further, the event will fire twice when clicking on Villagers while not doing so for wandering traders.
Here is the code I used to detect the bug:
@EventHandler public void onVillagerClick(PlayerInteractAtEntityEvent event) { event.setCancelled(true); Bukkit.broadcastMessage("isCanceled: " + event.isCancelled()); }
The Bukkit#broadcastMessage successfully broadcasts that the event is cancelled, but the opening of the gui stays.
This is a fresh build of the BuildTools.
For those looking for a solution, I added a BukkitRunnable#runTaskLater to close the gui one tick later which closes the villager gui almost immediately.
- duplicates
-
SPIGOT-3609 Cancelling PlayerInteractAtEntityEvent doesn't cancel villager trading menu
- Resolved