onEntityDeath broken with R5?

Discussion in 'Plugin Development' started by bajsko, Jul 30, 2012.

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

    bajsko

    Hello. My plugin, Kill Announcer depends on the onEntityDeath event, but in R5, it seems like it not is working?, Look:
    Code:
    @EventHandler
      public void onEntityDeath(EntityDeathEvent event) {
        if ((event.getEntity() instanceof Player)) {
          Player player = (Player)event.getEntity();
          EntityDamageEvent deathCause = player.getLastDamageCause();
          if (deathCause.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK) {
            Entity entity = ((EntityDamageByEntityEvent)deathCause).getDamager();
            if ((entity instanceof Player)) {
            //blablabla my code
     
    } else if((entity instanceof Monster)) {
     
    //for example,
    getServer().broadcastMessage("poop");
     
    }
    ofc, i add the listener,

    Code:
     PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new MyListener()); //for example
    
    whats happening, is that nothing is being broadcasted, whatsoever. If i get killed by a monster, nothing happens, i got no error in the console. Wtf? This is stoping me from releasing an update for R5, so i would be thankful for an answer.
     
  2. Offline

    raGan.

    I use EntityDeath too and it works fine for me.
     
  3. Offline

    Firefly

    It seems like you should be listening to multiple events instead of casting all these events and such, as well as checking damage causes. The method is rather sloppy and hard to maintain. I suggest you split it up into multiple events.
     
  4. Offline

    bajsko

    Thanks for your answer. I'll try it later
     
Thread Status:
Not open for further replies.

Share This Page