Search in sources :

Example 1 with TagReason

use of com.SirBlobman.combatlogx.event.PlayerTagEvent.TagReason in project MyPet by xXKeyleXx.

the class CombatLogXHook method on.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void on(EntityDamageByEntityEvent e) {
    Entity damaged = e.getEntity();
    Entity damager = e.getDamager();
    if ((damager instanceof CraftMyPetProjectile) && (ConfigOptions.OPTION_LINK_PROJECTILES || IGNORE_PLUGIN_SETTINGS)) {
        damager = ((CraftMyPetProjectile) damager).getShootingMyPet();
    }
    if ((damager instanceof MyPetBukkitEntity) && (ConfigOptions.OPTION_LINK_PETS || IGNORE_PLUGIN_SETTINGS)) {
        damager = ((MyPetBukkitEntity) damager).getOwner().getPlayer();
    } else {
        return;
    }
    if (damager != null && damaged instanceof LivingEntity) {
        if (damaged instanceof Player) {
            Player p = (Player) damaged;
            LivingEntity enemy = (LivingEntity) damager;
            TagReason reason = TagReason.ATTACKED;
            CombatUtil.tag(p, enemy, TagType.PLAYER, reason);
        }
        Player p = (Player) damager;
        LivingEntity enemy = (LivingEntity) damaged;
        TagType type = damaged instanceof Player ? TagType.PLAYER : TagType.MOB;
        TagReason reason = TagReason.ATTACKER;
        CombatUtil.tag(p, enemy, type, reason);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) TagType(com.SirBlobman.combatlogx.event.PlayerTagEvent.TagType) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) MyPetBukkitEntity(de.Keyle.MyPet.api.entity.MyPetBukkitEntity) Player(org.bukkit.entity.Player) CraftMyPetProjectile(de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile) TagReason(com.SirBlobman.combatlogx.event.PlayerTagEvent.TagReason) MyPetBukkitEntity(de.Keyle.MyPet.api.entity.MyPetBukkitEntity) EventHandler(org.bukkit.event.EventHandler)

Aggregations

TagReason (com.SirBlobman.combatlogx.event.PlayerTagEvent.TagReason)1 TagType (com.SirBlobman.combatlogx.event.PlayerTagEvent.TagType)1 MyPetBukkitEntity (de.Keyle.MyPet.api.entity.MyPetBukkitEntity)1 CraftMyPetProjectile (de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile)1 Entity (org.bukkit.entity.Entity)1 LivingEntity (org.bukkit.entity.LivingEntity)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1