Hi, i’m working on a Party plugin which disable friendly fire through the DamageEntityEvent listener.
One issue i came accross is the Arrow Flame enchant. I can’t find any way to cancel the fire event for the target player.
I tried with the event IgniteEntityEvent but it doesn’t seem to return a player or a projectile, but instead the World itself as the Source/Cause which doesn’t help me to recognize the nature of the fire.
That is the piece of code so far, which cancels only the damage:
Object root = event.getCause().root();
if(root instanceof IndirectEntityDamageSource) {
IndirectEntityDamageSource src = (IndirectEntityDamageSource) root;
Entity indirectSource = src.getIndirectSource();
if(indirectSource instanceof Player){
Player damager = (Player) indirectSource;
Player target = (Player) event.getTargetEntity();
if(plugin.getPartyManager().areInSameParty(damager, target)){
event.setCancelled(true);
}
}
}