Hey guys ! I have this strange problem happening everytime I do a PlayerInteractEntityEvent. To be clear, I'm trying to send a message to a player when he does a right click on a villager. But everytime, I do it, I receive the message two times... Is there a solution for this ? Here is my code : Code: public void onInteract(PlayerInteractEntityEvent event) { Player player = event.getPlayer(); Entity entity = event.getRightClicked(); if(entity instanceof Villager) { Villager villager = (Villager) entity; String name = villager.getCustomName(); player.sendMessage(main.getConfig().getConfigurationSection("quetes").getString(name+".q1")); } }
What do you mean by register the event twice ? This event is the only I have on my plugin at the moment
PlayerInteractEvent calls for two hands, both off-hand and main hand so you need to check which hand. Code: if (e.getHand() == EquipmentSlot.HAND) { // ... Your code with test }