My code sends the message twice

Discussion in 'Plugin Development' started by TomásCg2702, May 25, 2023.

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


    Hello! Does anyone know why my code sends the message to the chat twice when I click on an animal instead of doing it only once? Thank you!
    package me.tomas.prueba;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    public class Prueba extends JavaPlugin implements Listener {
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
        public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
            Player player = event.getPlayer();
            Entity entity = event.getRightClicked();
            player.sendMessage(player.getDisplayName() + " a clickeado a un/a " + entity.getName());
  2. Online

    timtower Administrator Administrator Moderator

    @TomásCg2702 Main hand and off hand, you can do a check for it.
  3. Offline


    How can I do that?
  4. Offline


    event.getHand() == EquipmentSlot.HAND
Thread Status:
Not open for further replies.

Share This Page