Java Code Examples for org.bukkit.entity.LivingEntity#addPotionEffect()
The following examples show how to use
org.bukkit.entity.LivingEntity#addPotionEffect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Glowing.java From MineTinker with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void effect(MTEntityDamageByEntityEvent event) { if (!(event.getEntity() instanceof LivingEntity)) { return; } Player player = event.getPlayer(); ItemStack tool = event.getTool(); LivingEntity entity = (LivingEntity) event.getEntity(); if (!player.hasPermission("minetinker.modifiers.glowing.use")) { return; } if (!modManager.hasMod(tool, this)) { return; } if (modManager.hasMod(tool, Shrouded.instance())) { //Should not trigger twice return; } entity.addPotionEffect(getPotionEffect(event, entity, player, tool)); }
Example 2
Source File: EffPoison.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override protected void execute(final Event e) { for (final LivingEntity le : entites.getArray(e)) { if (!cure) { Timespan dur; int d = (int) (duration != null && (dur = duration.getSingle(e)) != null ? (dur.getTicks_i() >= Integer.MAX_VALUE ? Integer.MAX_VALUE : dur.getTicks_i()) : DEFAULT_DURATION); if (le.hasPotionEffect(PotionEffectType.POISON)) { for (final PotionEffect pe : le.getActivePotionEffects()) { if (pe.getType() != PotionEffectType.POISON) continue; d += pe.getDuration(); } } le.addPotionEffect(new PotionEffect(PotionEffectType.POISON, d, 0), true); } else { le.removePotionEffect(PotionEffectType.POISON); } } }
Example 3
Source File: Poisoned.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getDamager(); target.addPotionEffect( new PotionEffect( PotionEffectType.POISON, duration * level, //This value is counted in ticks, 1/20 of a second strength + level)); }
Example 4
Source File: Revulsion.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getDamager(); target.addPotionEffect( new PotionEffect( PotionEffectType.CONFUSION, duration * level, //This value is counted in ticks, 1/20 of a second 0)); }
Example 5
Source File: Drunk.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getDamager(); target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration * level, strength + level)); target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, duration * level, strength + level)); target.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, duration * level, 0)); }
Example 6
Source File: Frozen.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getDamager(); target.addPotionEffect( new PotionEffect( PotionEffectType.SLOW, duration * level, strength + level)); }
Example 7
Source File: Hardened.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getDamager(); target.addPotionEffect( new PotionEffect( PotionEffectType.WEAKNESS, duration * level, strength + level)); }
Example 8
Source File: Cripple.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getEntity(); if(!target.hasPotionEffect(PotionEffectType.CONFUSION)) { EffectManager.playSound(target.getLocation(), "ENTITY_PLAYER_HURT", 1f, 0.4f); EffectManager.playSound(target.getLocation(), "BLOCK_ANVIL_LAND", 0.1f, 2f); target.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, duration * level, 0)); target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration * level, strength + level)); } }
Example 9
Source File: Poison.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getEntity(); target.addPotionEffect(new PotionEffect(PotionEffectType.POISON, duration * level, strength + level)); }
Example 10
Source File: Wither.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getEntity(); target.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, duration * level, strength + level)); }
Example 11
Source File: Blind.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getEntity(); EffectManager.playSound(target.getLocation(), "ENTITY_PLAYER_HURT", 1f, 0.4f); target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration + 20 * level, 0)); }
Example 12
Source File: Paralyze.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { if(e instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getEntity(); target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration + (level-1)*20, strength + level-1), true); target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration + (level-1)*20, 1), true); target.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, duration + (level-1)*20, strength + level-1), true); } }
Example 13
Source File: FailedHandler.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
@Override public void overwriteLivingEntityAI(LivingEntity entity) { entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Short.MAX_VALUE - 1, 15, true)); }
Example 14
Source File: SpiritWalk.java From EliteMobs with GNU General Public License v3.0 | 3 votes |
private void spiritWalkAnimation(LivingEntity bossMob, Location entityLocation, Location finalLocation) { bossMob.setAI(false); bossMob.setInvulnerable(true); bossMob.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 20 * 10, 1)); Vector toDestination = finalLocation.clone().subtract(entityLocation.clone()).toVector().normalize().divide(new Vector(2, 2, 2)); new BukkitRunnable() { int counter = 0; @Override public void run() { if (bossMob.getLocation().clone().distance(finalLocation) < 2 || counter > 20 * 10) { bossMob.teleport(finalLocation); bossMob.setAI(true); bossMob.setInvulnerable(false); bossMob.removePotionEffect(PotionEffectType.GLOWING); cancel(); } bossMob.teleport(bossMob.getLocation().clone().add(toDestination.clone())); counter++; } }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1); }
Example 15
Source File: PotionEffect.java From Kettle with GNU General Public License v3.0 | 2 votes |
/** * Attempts to add the effect represented by this object to the given * {@link LivingEntity}. * * @param entity The entity to add this effect to * @return Whether the effect could be added * @see LivingEntity#addPotionEffect(PotionEffect) */ public boolean apply(LivingEntity entity) { return entity.addPotionEffect(this); }
Example 16
Source File: PotionEffectApplier.java From EliteMobs with GNU General Public License v3.0 | 2 votes |
private void eventPotionEffectApplier(HashMap<PotionEffect, List<String>> potionEffects, Player player, LivingEntity livingEntity) { for (PotionEffect potionEffect : potionEffects.keySet()) { if (potionEffects.get(potionEffect).size() > 0) { if (potionEffects.get(potionEffect).get(0).equalsIgnoreCase(SELF)) { player.removePotionEffect(potionEffect.getType()); player.addPotionEffect(potionEffect); if (potionEffects.get(potionEffect).size() > 1) { if (potionEffects.get(potionEffect).get(1).equalsIgnoreCase(CONTINUOUS)) { player.removePotionEffect(potionEffect.getType()); } } } else if (potionEffects.get(potionEffect).get(0).equalsIgnoreCase(TARGET)) { livingEntity.removePotionEffect(potionEffect.getType()); livingEntity.addPotionEffect(potionEffect); } } else { //legacy config settings where there are no tags if (offensivePotionEffects.contains(potionEffect.getType())) { livingEntity.removePotionEffect(potionEffect.getType()); livingEntity.addPotionEffect(potionEffect); } } } }