use of io.lumine.xikage.mythicmobs.mobs.MythicMob in project MyPet by xXKeyleXx.
the class MythicMobsHook method on.
@EventHandler
public void on(MyPetDamageEvent event) {
try {
if (MythicMobs.inst().getMobManager().isActiveMob(BukkitAdapter.adapt(event.getTarget()))) {
ActiveMob defender = MythicMobs.inst().getMobManager().getMythicMobInstance(event.getTarget());
MythicMob defenderType = defender.getType();
if (defenderType.getIsInvincible()) {
event.setCancelled(true);
return;
}
double damage, baseDamage = damage = event.getDamage();
damage -= defender.getArmor();
if (baseDamage >= 1D && damage < 1D) {
damage = 1D;
}
double modifier = getEntityAttackModifier(defenderType);
damage *= modifier;
event.setDamage(damage);
if (damage == 0) {
event.setCancelled(true);
}
}
} catch (NumberFormatException ignored) {
} catch (Throwable t) {
t.printStackTrace();
}
}
use of io.lumine.xikage.mythicmobs.mobs.MythicMob in project MyPet by xXKeyleXx.
the class MythicMobsHook method canHurt.
@Override
public boolean canHurt(Player attacker, Entity defender) {
try {
if (MythicMobs.inst().getMobManager().isActiveMob(BukkitAdapter.adapt(defender))) {
MythicMob defenderType = MythicMobs.inst().getMobManager().getMythicMobInstance(defender).getType();
if (defenderType.getIsInvincible()) {
return false;
}
if (defenderType.hasFaction() && PREVENT_DAMAGE_TO_FACTIONS.contains(defenderType.getFaction())) {
return false;
}
if (PREVENT_DAMAGE_TO_MOBS.contains(defenderType.getInternalName())) {
return false;
}
double modifier = getEntityAttackModifier(defenderType);
if (modifier == 0) {
return false;
}
}
} catch (NumberFormatException ignored) {
} catch (Throwable t) {
t.printStackTrace();
}
return true;
}
Aggregations