Cancel Fire ticks from Arrow

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);
                }
            }
        }

I see your searching for at the root of the cause.

Have you tried searching for the “first” Player/Arrow/IndirectEntityDamageSource

Thanks, that did the trick, i will post the updated code if someone need it in the future.

 @Listener(order = Order.FIRST, beforeModifications = true)
     public void onPlayerIgnite(IgniteEntityEvent event ){
         Optional<Arrow> optArrow = event.getCause().first(Arrow.class);
         if( optArrow.isPresent() ){
             Arrow arrow = optArrow.get();
             Optional<UUID> optPlayer = arrow.getCreator();
             if( optPlayer.isPresent() ){
                 UUID shooterId = optPlayer.get();
                 Optional<Player> shooterOpt = Sponge.getServer().getPlayer(shooterId);
                 Player shooter = shooterOpt.get();
                 Player target = (Player) event.getTargetEntity();
                 if(plugin.getPartyManager().areInSameParty(shooter, target)){
                     event.setCancelled(true);
                 }
             }
         }
     }