Solved EntityDamageEvent

Discussion in 'Plugin Development' started by josha28, Aug 14, 2017.

Thread Status:
Not open for further replies.
  1. What is wrong with this
    @Override
    public void onEnable() {

    }

    @Override
    public void onDisable() {

    }
    @EventHandler
    public void onFall(EntityDamageEvent e) {

    Player player = (Player) e.getEntity();
    if (e.getCause().equals(DamageCause.FALL)) {
    player.sendMessage("You broke your legs");
    }
    }
    }

    it didn't message me
     
    Last edited: Aug 14, 2017
  2. Offline

    Zombie_Striker

    @josha28
    Do you have the @EventHander tag? Are you sure you registered the class?

    Also, use == for comparing enums.
     
  3. You need to use the @EventHandler annotation, and you also need to register the event in the onEnable method. Do the following:

    Code:
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
     
Thread Status:
Not open for further replies.

Share This Page