@Override public void removeEffects() { for(PotionEffect pe : le.getActivePotionEffects()) { le.removePotionEffect(pe.getType()); } }
/** * Returns the {@link PotionEffect} of a given {@link PotionEffectType} for a given {@link LivingEntity}, if present. * * @param entity the entity to query * @param type the type to search * @return the {@link PotionEffect} or null if not present */ public static PotionEffect getOrNull(LivingEntity entity, PotionEffectType type){ if(canUseGetPotionEffectsMethod){ return entity.getPotionEffect(type); } return entity.getActivePotionEffects().stream() .filter(potionEffect -> potionEffect.getType().equals(type)) .findAny() .orElse(null); } }
@Override public boolean removeEffect(MCPotionEffectType type) { PotionEffectType t = (PotionEffectType) type.getConcrete(); boolean hasIt = false; for(PotionEffect pe : le.getActivePotionEffects()) { if(pe.getType() == t) { hasIt = true; break; } } le.removePotionEffect(t); return hasIt; }
protected void removeActiveEffects() { LivingEntity entity = getLivingEntity(); if (entity == null) return; Collection<PotionEffect> activeEffects = entity.getActivePotionEffects(); for (PotionEffect effect : activeEffects) { if (effect.getDuration() > Integer.MAX_VALUE / 2) { entity.removePotionEffect(effect.getType()); } } }
@Override public List<MCEffect> getEffects() { List<MCEffect> effects = new ArrayList<>(); for(PotionEffect pe : le.getActivePotionEffects()) { MCEffect e = new MCEffect(BukkitMCPotionEffectType.valueOfConcrete(pe.getType()), pe.getAmplifier(), pe.getDuration(), pe.isAmbient(), pe.hasParticles(), pe.hasIcon()); effects.add(e); } return effects; }
@Override public SpellResult perform(CastContext context) { Entity entity = context.getTargetEntity(); if (entity == null || !(entity instanceof LivingEntity)) { return SpellResult.NO_TARGET; } LivingEntity targetEntity = (LivingEntity)entity; Collection<PotionEffect> currentEffects = targetEntity.getActivePotionEffects(); for (PotionEffect effect : currentEffects) { if (negativeEffects.contains(effect.getType())) { context.registerPotionEffects(targetEntity); targetEntity.removePotionEffect(effect.getType()); } } return SpellResult.CAST; }
Collection<PotionEffect> currentEffects = targetEntity.getActivePotionEffects(); for (PotionEffect effect : currentEffects)
for (PotionEffect effect : ((LivingEntity) entity).getActivePotionEffects()) { ((LivingWatcher) watcher).addPotionEffect(effect.getType());
private void giveHP(final LivingEntity livingEntity) { if (!livingEntity.isDead() && livingEntity.getHealth() < livingEntity.getMaxHealth()) { this.applyHealing(livingEntity); } else { this.healing = false; } for (final PotionEffect effect : livingEntity.getActivePotionEffects()) { if (ElementalAbility.isNegativeEffect(effect.getType())) { livingEntity.removePotionEffect(effect.getType()); } } }
public static void applyPotionEffect(LivingEntity entity, PotionEffect effect) { // Avoid nerfing existing effects boolean applyEffect = true; Collection<PotionEffect> currentEffects = entity.getActivePotionEffects(); for (PotionEffect currentEffect : currentEffects) { if (currentEffect.getType().equals(effect.getType())) { if (effect.getAmplifier() < 0) { applyEffect = false; break; } else if (currentEffect.getAmplifier() > effect.getAmplifier() || effect.getDuration() > Integer.MAX_VALUE / 4) { applyEffect = false; break; } } } if (applyEffect) { entity.addPotionEffect(effect, true); } }
Collection<PotionEffect> effects = living.getActivePotionEffects(); for (PotionEffect effect : effects) { if (effect.getType().equals(PotionEffectType.DAMAGE_RESISTANCE) && effect.getAmplifier() >= damageResistanceProtection) {
Collection<PotionEffect> effects = li.getActivePotionEffects(); for (PotionEffect effect : effects) { if (negativeEffects.contains(effect.getType())) {
LivingEntity li = (LivingEntity)entity; if (hasPotionEffects) { Collection<PotionEffect> currentEffects = li.getActivePotionEffects(); for (PotionEffect effect : currentEffects) { li.removePotionEffect(effect.getType());
private void addEffect(final PotionEffect effect) { for (final PotionEffect peffect : this.entity.getActivePotionEffects()) { if (peffect.getType().equals(effect.getType())) { if (peffect.getAmplifier() > effect.getAmplifier()) { if (peffect.getDuration() > effect.getDuration()) { return; } else { final int dt = effect.getDuration() - peffect.getDuration(); final PotionEffect neweffect = new PotionEffect(effect.getType(), dt, effect.getAmplifier()); new TempPotionEffect(this.entity, neweffect, System.currentTimeMillis() + peffect.getDuration() * tick); return; } } else { if (peffect.getDuration() > effect.getDuration()) { this.entity.removePotionEffect(peffect.getType()); this.entity.addPotionEffect(effect); final int dt = peffect.getDuration() - effect.getDuration(); final PotionEffect neweffect = new PotionEffect(peffect.getType(), dt, peffect.getAmplifier()); new TempPotionEffect(this.entity, neweffect, System.currentTimeMillis() + effect.getDuration() * tick); return; } else { this.entity.removePotionEffect(peffect.getType()); this.entity.addPotionEffect(effect); return; } } } } this.entity.addPotionEffect(effect); }
Collection<PotionEffect> currentEffects = targetEntity.getActivePotionEffects(); for (PotionEffect effect : currentEffects) { if (negativeEffects.contains(effect.getType())) {
LivingEntity li = (LivingEntity)entity; this.health = li.getHealth(); this.potionEffects = li.getActivePotionEffects(); this.airLevel = li.getRemainingAir(); this.maxHealth = CompatibilityUtils.getMaxHealth(li);