Java Code Examples for org.bukkit.entity.LivingEntity#hasPotionEffect()
The following examples show how to use
org.bukkit.entity.LivingEntity#hasPotionEffect() .
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: SentinelUtilities.java From Sentinel with MIT License | 7 votes |
/** * Returns whether an entity is invisible (when invisible targets are ignorable). */ public static boolean isInvisible(LivingEntity entity) { if (!SentinelPlugin.instance.ignoreInvisible || !entity.hasPotionEffect(PotionEffectType.INVISIBILITY)) { return false; } EntityEquipment eq = entity.getEquipment(); if (eq == null) { return true; } if (SentinelVersionCompat.v1_9) { if (!isAir(eq.getItemInMainHand()) || !isAir(eq.getItemInOffHand())) { return false; } } else { if (!isAir(eq.getItemInHand())) { return false; } } return isAir(eq.getBoots()) && isAir(eq.getLeggings()) && isAir(eq.getChestplate()) && isAir(eq.getHelmet()); }
Example 2
Source File: CivPotionEffect.java From Civs with GNU General Public License v3.0 | 6 votes |
@Override public HashMap<String, Double> getVariables() { HashMap<String, Double> returnMap = new HashMap<String, Double>(); Object target = getTarget(); if (!(target instanceof LivingEntity)) { return returnMap; } LivingEntity livingEntity = (LivingEntity) target; if (!livingEntity.hasPotionEffect(this.type)) { return returnMap; } for (PotionEffect potionEffect : livingEntity.getActivePotionEffects()) { if (potionEffect.getType().equals(this.type)) { returnMap.put("ticks", (double) potionEffect.getDuration()); returnMap.put("level", (double) potionEffect.getAmplifier()); break; } } return returnMap; }
Example 3
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 4
Source File: CivPotionEffect.java From Civs with GNU General Public License v3.0 | 5 votes |
@Override public boolean meetsRequirement() { Object target = getTarget(); if (!(target instanceof LivingEntity)) { return false; } LivingEntity livingEntity = (LivingEntity) target; return livingEntity.hasPotionEffect(this.type); }
Example 5
Source File: SentinelPotion.java From Sentinel with MIT License | 5 votes |
@Override public boolean isTarget(LivingEntity ent, String prefix, String value) { if (prefix.equals("potion")) { if (ent.hasPotionEffect(PotionEffectType.getByName(value))) { return true; } } return false; }
Example 6
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 7
Source File: CondIsPoisoned.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final LivingEntity e) { return e.hasPotionEffect(PotionEffectType.POISON); }