Search in sources :

Example 36 with PotionEffect

use of org.bukkit.potion.PotionEffect in project CommandHelper by EngineHub.

the class BukkitMCLivingEntity method getEffects.

@Override
public List<MCEffect> getEffects() {
    List<MCEffect> effects = new ArrayList<>();
    for (PotionEffect pe : le.getActivePotionEffects()) {
        MCEffect e;
        if (Static.getServer().getMinecraftVersion().lt(MCVersion.MC1_8)) {
            e = new MCEffect(pe.getType().getId(), pe.getAmplifier(), pe.getDuration(), pe.isAmbient(), true);
        } else {
            e = new MCEffect(pe.getType().getId(), pe.getAmplifier(), pe.getDuration(), pe.isAmbient(), pe.hasParticles());
        }
        effects.add(e);
    }
    return effects;
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) ArrayList(java.util.ArrayList)

Example 37 with PotionEffect

use of org.bukkit.potion.PotionEffect in project CommandHelper by EngineHub.

the class BukkitMCAreaEffectCloud method addCustomEffect.

@Override
public void addCustomEffect(MCLivingEntity.MCEffect effect) {
    PotionEffect pe = new PotionEffect(PotionEffectType.getById(effect.getPotionID()), effect.getTicksRemaining(), effect.getStrength(), effect.isAmbient(), effect.hasParticles());
    aec.addCustomEffect(pe, true);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect)

Example 38 with PotionEffect

use of org.bukkit.potion.PotionEffect in project MagicPlugin by elBukkit.

the class Mage method updatePassiveEffects.

protected void updatePassiveEffects() {
    protection.clear();
    strength.clear();
    weakness.clear();
    attributes.clear();
    spMultiplier = 1;
    cooldownReduction = 0;
    costReduction = 0;
    consumeReduction = 0;
    List<PotionEffectType> currentEffects = new ArrayList<>(effectivePotionEffects.keySet());
    LivingEntity entity = getLivingEntity();
    effectivePotionEffects.clear();
    addPassiveEffects(properties, true);
    if (activeClass != null) {
        addPassiveEffects(activeClass, true);
        spMultiplier = (float) (spMultiplier * activeClass.getDouble("sp_multiplier", 1.0));
    }
    if (activeWand != null && !activeWand.isPassive()) {
        addPassiveEffects(activeWand, false);
        effectivePotionEffects.putAll(activeWand.getPotionEffects());
    }
    // Don't add these together so things stay balanced!
    if (offhandWand != null && !offhandWand.isPassive()) {
        addPassiveEffects(offhandWand, false);
        effectivePotionEffects.putAll(offhandWand.getPotionEffects());
        spMultiplier *= offhandWand.getSPMultiplier();
    }
    for (Wand armorWand : activeArmor.values()) {
        if (armorWand != null) {
            addPassiveEffects(armorWand, false);
            effectivePotionEffects.putAll(armorWand.getPotionEffects());
        }
    }
    if (entity != null) {
        for (PotionEffectType effectType : currentEffects) {
            if (!effectivePotionEffects.containsKey(effectType)) {
                entity.removePotionEffect(effectType);
            }
        }
        for (Map.Entry<PotionEffectType, Integer> effects : effectivePotionEffects.entrySet()) {
            PotionEffect effect = new PotionEffect(effects.getKey(), Integer.MAX_VALUE, effects.getValue(), true, false);
            CompatibilityUtils.applyPotionEffect(entity, effect);
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) PotionEffect(org.bukkit.potion.PotionEffect) PotionEffectType(org.bukkit.potion.PotionEffectType) ArrayList(java.util.ArrayList) Wand(com.elmakers.mine.bukkit.wand.Wand) LostWand(com.elmakers.mine.bukkit.api.wand.LostWand) Map(java.util.Map) HashMap(java.util.HashMap)

Example 39 with PotionEffect

use of org.bukkit.potion.PotionEffect in project MagicPlugin by elBukkit.

the class PotionEffectAction method perform.

@Override
public SpellResult perform(CastContext context) {
    Entity entity = context.getTargetEntity();
    if (!(entity instanceof LivingEntity)) {
        return SpellResult.NO_TARGET;
    }
    LivingEntity targetEntity = (LivingEntity) entity;
    context.registerPotionEffects(targetEntity);
    boolean effected = false;
    if (addEffects != null && addEffects.size() > 0) {
        effected = true;
        CompatibilityUtils.applyPotionEffects(targetEntity, addEffects);
    }
    if (removeEffects != null) {
        Collection<PotionEffect> currentEffects = targetEntity.getActivePotionEffects();
        for (PotionEffect effect : currentEffects) {
            PotionEffectType removeType = effect.getType();
            if (removeEffects.contains(removeType) && effect.getDuration() < Integer.MAX_VALUE / 4) {
                targetEntity.removePotionEffect(removeType);
                effected = true;
            }
        }
    }
    return effected ? SpellResult.CAST : SpellResult.NO_TARGET;
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) PotionEffect(org.bukkit.potion.PotionEffect) PotionEffectType(org.bukkit.potion.PotionEffectType)

Example 40 with PotionEffect

use of org.bukkit.potion.PotionEffect in project MagicPlugin by elBukkit.

the class PotionEffectAction method getMappedPotionEffects.

private Collection<PotionEffect> getMappedPotionEffects(ConfigurationSection parameters) {
    ConfigurationSection section = parameters.getConfigurationSection("add_effects");
    if (section != null) {
        Collection<String> keys = section.getKeys(false);
        Collection<PotionEffect> effects = new ArrayList<>(keys.size());
        int ticks = parameters.getInt("duration", 500) / 50;
        for (String key : keys) {
            int strength = section.getInt(key, 0);
            PotionEffectType type = PotionEffectType.getByName(key);
            if (type != null) {
                effects.add(new PotionEffect(type, type.isInstant() ? 1 : ticks, strength, ambient, particles));
            }
        }
        return effects;
    } else {
        return Collections.emptyList();
    }
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) PotionEffectType(org.bukkit.potion.PotionEffectType) ArrayList(java.util.ArrayList) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Aggregations

PotionEffect (org.bukkit.potion.PotionEffect)224 Player (org.bukkit.entity.Player)61 PotionEffectType (org.bukkit.potion.PotionEffectType)39 Location (org.bukkit.Location)37 LivingEntity (org.bukkit.entity.LivingEntity)37 EventHandler (org.bukkit.event.EventHandler)36 ItemStack (org.bukkit.inventory.ItemStack)34 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)23 PotionMeta (org.bukkit.inventory.meta.PotionMeta)18 Vector (org.bukkit.util.Vector)16 Random (java.util.Random)14 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)11 ItemMeta (org.bukkit.inventory.meta.ItemMeta)10 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)9 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)9 Material (org.bukkit.Material)7 Enchantment (org.bukkit.enchantments.Enchantment)7 Projectile (org.bukkit.entity.Projectile)7 PotionData (org.bukkit.potion.PotionData)7