@Listener
public void onEntityDeath(DestructEntityEvent.Death event) {
plugin.logger.error("Event fired");
Optional<Player> playerOptional = event.getCause().first(Player.class);
if (playerOptional.isPresent()) {
plugin.logger.error("Player is present");
Player player = (Player) playerOptional;
When I kill some entity, event get fired, but killer (Cause) is ever absent. Am I doing anything wrong ?
(Using Sponge 630)
@Listener
public void onEntityDeath(DestructEntityEvent.Death event) {
plugin.logger.error("Event fired");
Optional<EntityDamageSource> source = event.getCause().first(EntityDamageSource.class);
if (source.isPresent()) plugin.logger.error("source is present");
if (source.isPresent() && source.get().getSource() instanceof Player) {
plugin.logger.error("Player is present");
Player player = (Player) source.get().getSource();
I just downloaded latest Sponge version (634) and It started to work. Looks like there was some problem (missing implentation?) in version (630) which I has used before. Thanks for your help.