use of org.bukkit.potion.PotionEffect in project MagicPlugin by elBukkit.
the class CureAction method perform.
@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;
}
use of org.bukkit.potion.PotionEffect in project Spirits by xNuminousx.
the class Infest method infestEntities.
public void infestEntities(Entity entity) {
if (new Random().nextInt(effectInt) == 0) {
if (entity instanceof Player) {
Player ePlayer = (Player) entity;
BendingPlayer bEntity = BendingPlayer.getBendingPlayer(ePlayer);
if (bEntity.hasElement(Element.getElement("DarkSpirit")) && healDarkSpirits) {
LivingEntity le = (LivingEntity) entity;
le.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 120, 1));
ParticleEffect.HEART.display(entity.getLocation().add(0, 2, 0), 0, 0, 0, 0, 1);
}
} else if (entity instanceof Monster) {
LivingEntity le = (LivingEntity) entity;
le.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 120, 1));
ParticleEffect.ANGRY_VILLAGER.display(entity.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1);
} else if (entity instanceof LivingEntity && damageEntities) {
DamageHandler.damageEntity(entity, damage, this);
ParticleEffect.PORTAL.display(entity.getLocation().add(0, 1, 0), 0, 0, 0, 1.5F, 5);
}
}
}
use of org.bukkit.potion.PotionEffect in project Spirits by xNuminousx.
the class Fuse method fuse.
public void fuse(Entity target) {
isFusing = true;
player.setGameMode(GameMode.SPECTATOR);
player.setSpectatorTarget(target);
if (new Random().nextInt(5) == 0) {
Methods.playSpiritParticles(bPlayer, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.2F, 5);
}
if (target instanceof Player) {
enableAvatarState = true;
if (System.currentTimeMillis() > time + dangerDelay) {
if (new Random().nextInt(10) == 0) {
DamageHandler.damageEntity(target, 1, this);
ParticleEffect.MAGIC_CRIT.display(target.getLocation().add(0, 1, 0), 0, 0, 0, 0.2F, 10);
}
}
} else if (target instanceof LivingEntity) {
if (!enableNPCMerge) {
defuse();
remove();
return;
}
if (System.currentTimeMillis() > time + dangerDelay) {
if (new Random().nextInt(10) == 0) {
DamageHandler.damageEntity(target, 1, this);
ParticleEffect.MAGIC_CRIT.display(target.getLocation().add(0, 1, 0), 0, 0, 0, 0.2F, 10);
}
}
LivingEntity le = (LivingEntity) target;
le.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, potDuration * 24, 2));
le.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, potDuration * 24, 1));
le.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, potDuration * 24, 2));
}
}
use of org.bukkit.potion.PotionEffect in project MagicPlugin by elBukkit.
the class CitizensTrait method updateEntity.
protected void updateEntity() {
Entity entity = null;
try {
entity = npc.getEntity();
} catch (Exception ignored) {
}
LivingEntity li = entity instanceof LivingEntity ? (LivingEntity) entity : null;
if (li != null) {
if (invisible) {
li.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
} else {
li.removePotionEffect(PotionEffectType.INVISIBILITY);
}
if (hatItem != null) {
li.getEquipment().setHelmet(hatItem);
}
}
}
use of org.bukkit.potion.PotionEffect in project MagicPlugin by elBukkit.
the class PotionEffectSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target target = getTarget();
if (!target.hasTarget()) {
return SpellResult.NO_TARGET;
}
List<LivingEntity> targetEntities = new ArrayList<>();
Entity targetedEntity = target.getEntity();
if (target.hasEntity() && targetedEntity instanceof LivingEntity) {
targetEntities.add((LivingEntity) targetedEntity);
}
int radius = parameters.getInt("radius", 0);
radius = (int) (mage.getRadiusMultiplier() * radius);
if (radius > 0) {
List<Entity> entities = CompatibilityUtils.getNearbyEntities(target.getLocation(), radius, radius, radius);
for (Entity entity : entities) {
if (entity instanceof LivingEntity && entity != targetedEntity && entity != mage.getEntity()) {
targetEntities.add((LivingEntity) entity);
}
}
}
if (targetEntities.size() == 0) {
return SpellResult.NO_TARGET;
}
int fallProtection = parameters.getInt("fall_protection", 0);
Integer duration = null;
if (parameters.contains("duration")) {
duration = parameters.getInt("duration");
}
Collection<PotionEffect> effects = getPotionEffects(parameters, duration);
for (LivingEntity targetEntity : targetEntities) {
Mage targetMage = controller.isMage(targetEntity) ? controller.getMage(targetEntity) : null;
if (targetMage != null && fallProtection > 0) {
targetMage.enableFallProtection(fallProtection);
}
if (targetEntity != mage.getEntity()) {
// Check for superprotected mages
if (targetMage != null) {
// Check for protected players
if (isSuperProtected(targetMage)) {
continue;
}
if (parameters.getBoolean("deactivate_target_mage")) {
targetMage.deactivateAllSpells(true, false);
}
}
}
if (targetEntity instanceof Player && parameters.getBoolean("feed", false)) {
Player p = (Player) targetEntity;
p.setExhaustion(0);
p.setFoodLevel(20);
}
if (parameters.getBoolean("cure", false)) {
Collection<PotionEffect> currentEffects = targetEntity.getActivePotionEffects();
for (PotionEffect effect : currentEffects) {
if (negativeEffects.contains(effect.getType())) {
targetEntity.removePotionEffect(effect.getType());
}
}
}
if (parameters.contains("heal")) {
registerModified(targetEntity);
double health = targetEntity.getHealth() + parameters.getDouble("heal");
targetEntity.setHealth(Math.min(health, targetEntity.getMaxHealth()));
} else if (parameters.contains("heal_percentage")) {
registerModified(targetEntity);
double health = targetEntity.getHealth() + targetEntity.getMaxHealth() * parameters.getDouble("heal_percentage");
targetEntity.setHealth(Math.min(health, targetEntity.getMaxHealth()));
} else if (parameters.contains("damage")) {
registerModified(targetEntity);
CompatibilityUtils.magicDamage(targetEntity, parameters.getDouble("damage") * mage.getDamageMultiplier(), mage.getEntity());
} else {
registerPotionEffects(targetEntity);
}
if (parameters.contains("fire")) {
registerModified(targetEntity);
targetEntity.setFireTicks(parameters.getInt("fire"));
}
CompatibilityUtils.applyPotionEffects(targetEntity, effects);
if (parameters.contains("remove_effects")) {
List<String> removeKeys = parameters.getStringList("remove_effects");
for (String removeKey : removeKeys) {
PotionEffectType removeType = PotionEffectType.getByName(removeKey);
targetEntity.removePotionEffect(removeType);
}
}
}
registerForUndo();
return SpellResult.CAST;
}
Aggregations