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;
}
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);
}
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);
}
}
}
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;
}
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();
}
}
Aggregations