Search in sources :

Example 1 with ActiveSpellEffect

use of com.solinia.solinia.Models.ActiveSpellEffect in project solinia3-core by mixxit.

the class Utils method getActiveSpellEffectsRemainingValue.

public static int getActiveSpellEffectsRemainingValue(LivingEntity livingEntity, SpellEffectType effectType) {
    int totalRemaining = 0;
    SoliniaEntitySpells effects;
    try {
        effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(livingEntity);
        for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
            for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
                if (!(effect.getSpellEffectType().equals(effectType)))
                    continue;
                totalRemaining += effect.getRemainingValue();
            }
        }
    } catch (CoreStateInitException e) {
    // skip
    }
    return totalRemaining;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaEntitySpells(com.solinia.solinia.Models.SoliniaEntitySpells) SoliniaActiveSpell(com.solinia.solinia.Models.SoliniaActiveSpell) ActiveSpellEffect(com.solinia.solinia.Models.ActiveSpellEffect)

Example 2 with ActiveSpellEffect

use of com.solinia.solinia.Models.ActiveSpellEffect in project solinia3-core by mixxit.

the class Utils method getActiveSpellEffects.

public static List<ActiveSpellEffect> getActiveSpellEffects(LivingEntity livingEntity, SpellEffectType effectType) {
    List<ActiveSpellEffect> returnEffects = new ArrayList<ActiveSpellEffect>();
    SoliniaEntitySpells effects;
    try {
        effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(livingEntity);
        for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
            for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
                if (!(effect.getSpellEffectType().equals(effectType)))
                    continue;
                returnEffects.add(effect);
            }
        }
    } catch (CoreStateInitException e) {
    // skip
    }
    return returnEffects;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) SoliniaEntitySpells(com.solinia.solinia.Models.SoliniaEntitySpells) ActiveSpellEffect(com.solinia.solinia.Models.ActiveSpellEffect) SoliniaActiveSpell(com.solinia.solinia.Models.SoliniaActiveSpell)

Example 3 with ActiveSpellEffect

use of com.solinia.solinia.Models.ActiveSpellEffect in project solinia3-core by mixxit.

the class Utils method reduceDamage.

public static double reduceDamage(ISoliniaLivingEntity defender, double damage) {
    if (damage <= 0)
        return damage;
    int spellMitigateMeleeDamage = 0;
    for (ActiveSpellEffect effect : Utils.getActiveSpellEffects(defender.getBukkitLivingEntity(), SpellEffectType.MitigateMeleeDamage)) {
        spellMitigateMeleeDamage += effect.getRemainingValue();
    }
    // We should check this in advance really
    if (spellMitigateMeleeDamage < 1)
        return damage;
    double damage_to_reduce = damage * (spellMitigateMeleeDamage / 100);
    return (damage - damage_to_reduce);
}
Also used : ActiveSpellEffect(com.solinia.solinia.Models.ActiveSpellEffect)

Aggregations

ActiveSpellEffect (com.solinia.solinia.Models.ActiveSpellEffect)3 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)2 SoliniaActiveSpell (com.solinia.solinia.Models.SoliniaActiveSpell)2 SoliniaEntitySpells (com.solinia.solinia.Models.SoliniaEntitySpells)2 ArrayList (java.util.ArrayList)1