[SPIGOT-2465] EntityDamageEvent not executing for anything other than players? Created: 28/Jun/16  Updated: 29/Jul/16  Resolved: 28/Jun/16

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Tom Hoogstra Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: 1.10.2

Issue Links:
Cloners
is cloned by SPIGOT-2559 CLONE - EntityDamageEvent not executi... Resolved

 Description   

Either my shit is completely toasted, or something has went wrong with recent versions.

My event is properly registered, other events in the same class execute fine, but if I use the following code

@EventHandler
public void onDeath(EntityDeathEvent e){
   Bukkit.broadcastMessage("test");
}

"test" will only be broadcasted when a player dies. I have killed countless sheep, switched classes that the listener is in, everything.



 Comments   
Comment by Tom Hoogstra [ 29/Jun/16 ]

I think I found something that might be causing my problem.
Apparently, when using setHealth(0) on an entity, it will only call the PlayerDeathEvent, however if the entity isnt a player, it won't call anything at all.
I use my own way for handling damage, and I have for a while but I didn't notice this until now. I went and called a EntityDeathEvent after I set the entities health to 0, and it fixed my problem.

Comment by Tom Hoogstra [ 29/Jun/16 ]

Are there any possible settings that could be causing this to happen?

I made a class from scratch which still provides 0 output

public class Test extends JavaPlugin implements Listener{

	 @EventHandler
	    public void death(EntityDeathEvent event)
	    {
	        getServer().broadcastMessage( ReflectionToStringBuilder.toString( event ) );
	    }


	@Override
	public void onEnable() {
		Bukkit.getPluginManager().registerEvents(this, this);
        }
Comment by md_5 [ 28/Jun/16 ]

[09:32:42 INFO]: org.bukkit.event.entity.EntityDeathEvent@51ad3bf5[drops=[ItemStack

{RAW_BEEF x 1}

],dropExp=3,entity=CraftCow,name=<null>,async=false]

    @EventHandler
    public void death(EntityDeathEvent event)
    {
        getServer().broadcastMessage( ReflectionToStringBuilder.toString( event ) );
    }
Comment by Tom Hoogstra [ 28/Jun/16 ]

Sorry, I meant EntityDeathEvent, not EntityDamageEvent.

Generated at Mon Mar 31 01:51:11 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.