<commit_before>/*
 * Copyright (c) 2014 <NAME>.
 *
 * All Rights Reserved
 */

package com.skelril.aurora.util.extractor.entity;

import com.skelril.aurora.util.extractor.Extractor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.projectiles.ProjectileSource;

@SuppressWarnings("unchecked")
public class EDBEExtractor<Attacker extends Entity, Defender extends Entity, Thrown extends Projectile>
       implements Extractor<CombatantPair<Attacker, Defender, Thrown>, EntityDamageByEntityEvent> {

    private final Class<Attacker> attackerType;
    private final Class<Defender> defenderType;
    private final Class<Thrown> thrownClass;

    public EDBEExtractor(Class<Attacker> attackerType, Class<Defender> defenderType, Class<Thrown> thrownClass) {
        this.attackerType = attackerType;
        this.defenderType = defenderType;
        this.thrownClass = thrownClass;
    }

    @Override
    public CombatantPair<Attacker, Defender, Thrown> extractFrom(EntityDamageByEntityEvent event) {
        Entity defender = event.getEntity();
        Entity attacker = event.getDamager();
        Projectile projectile = null;

        if (attacker instanceof Projectile) {
            ProjectileSource shooter = ((Projectile) attacker).getShooter();
            projectile = (Projectile) attacker;
            if (shooter == null || !thrownClass.isInstance(projectile)) {
                return null;
            }
            attacker = (Entity) shooter;
        }

        if (defenderType.isInstance(defender) && attackerType.isInstance(attacker)) {
            if (projectile == null) {
                return new CombatantPair<>((Attacker) attacker, (Defender) defender);
            }
            return new CombatantPair<>((Attacker) attacker, (Defender) defender, (Thrown) projectile);
        }
        return null;
    }
}
<commit_msg>Fixed an issue with the EDBEExtractor where shooting from blocks causes CCEs<commit_after>/*
 * Copyright (c) 2014 <NAME>.
 *
 * All Rights Reserved
 */

package com.skelril.aurora.util.extractor.entity;

import com.skelril.aurora.util.extractor.Extractor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.projectiles.ProjectileSource;

@SuppressWarnings("unchecked")
public class EDBEExtractor<Attacker extends Entity, Defender extends Entity, Thrown extends Projectile>
       implements Extractor<CombatantPair<Attacker, Defender, Thrown>, EntityDamageByEntityEvent> {

    private final Class<Attacker> attackerType;
    private final Class<Defender> defenderType;
    private final Class<Thrown> thrownClass;

    public EDBEExtractor(Class<Attacker> attackerType, Class<Defender> defenderType, Class<Thrown> thrownClass) {
        this.attackerType = attackerType;
        this.defenderType = defenderType;
        this.thrownClass = thrownClass;
    }

    @Override
    public CombatantPair<Attacker, Defender, Thrown> extractFrom(EntityDamageByEntityEvent event) {
        Entity defender = event.getEntity();
        Entity attacker = event.getDamager();
        Projectile projectile = null;

        if (attacker instanceof Projectile) {
            ProjectileSource shooter = ((Projectile) attacker).getShooter();
            projectile = (Projectile) attacker;
            if (shooter == null || !attackerType.isInstance(shooter) || !thrownClass.isInstance(projectile)) {
                return null;
            }
            attacker = (Entity) shooter;
        }

        if (defenderType.isInstance(defender) && attackerType.isInstance(attacker)) {
            if (projectile == null) {
                return new CombatantPair<>((Attacker) attacker, (Defender) defender);
            }
            return new CombatantPair<>((Attacker) attacker, (Defender) defender, (Thrown) projectile);
        }
        return null;
    }
}

{'fraction_non_alphanumeric': 0.09628886659979939, 'fraction_numerical': 0.0020060180541624875, 'mean_word_length': 3.3311617806731815, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1090837', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1093, 'n_words': 252}