Like in other events you can query the cause for certain types.
To see if a player caused the death, you do:
@Listener
public void onEntityDeath(DestructEntityEvent.Death event) {
Optional<Player> optPlayer = event.getCause().first(Player.class);
if (optPlayer.isPresent()) {
Player player = optPlayer.get();
// The player caused the entity to die
} else {
// The entity died from a non-player cause
}
}
You can also use the new event filtering
@Listener
public void onEntityDeath(DestructEntityEvent.Death event, @First Player player) {
// Only gets called when the player was the cause
}