/** * Change the duration using values defined in config * for splash potions */ @EventHandler(priority = EventPriority.HIGHEST) public void onPotionSplash(PotionSplashEvent event){ ThrownPotion thrownPotion = event.getPotion(); ItemStack potion = thrownPotion.getItem(); PotionMeta potionMeta = (PotionMeta) potion.getItemMeta(); PotionEffect potionEffect = (PotionEffect) thrownPotion.getEffects().toArray()[0]; PotionData potionData = potionMeta.getBasePotionData(); if(isExcludedPotion(potionData.getType())) return; event.setCancelled(true); int duration = getPotionDuration(potionData, true); PotionEffectType pet = potionEffect.getType(); PotionEffect pe = new PotionEffect(pet, duration, potionEffect.getAmplifier()); event.getAffectedEntities().forEach(livingEntity -> setNewPotionEffect(livingEntity, pet, pe)); }
for (PotionEffect effect : e.getPotion().getEffects()) { entity.removePotionEffect(effect.getType()); for (PotionEffect effect : e.getPotion().getEffects()) { entity.removePotionEffect(effect.getType()); for (PotionEffect effect : e.getPotion().getEffects()) { entity.removePotionEffect(effect.getType());
for (PotionEffect effect : potion.getEffects()) { PotionEffectType type = effect.getType(); if (type.equals(PotionEffectType.HARM) || type.equals(PotionEffectType.POISON)) { for (PotionEffect effect : potion.getEffects()) { PotionEffectType type = effect.getType(); if (type.equals(PotionEffectType.HARM) || type.equals(PotionEffectType.POISON)) {
@EventHandler(ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { Entity entity = event.getEntity(); ThrownPotion potion = event.getPotion(); World world = entity.getWorld(); Cause cause = create(potion); // Fire item interaction event Events.fireToCancel(event, new UseItemEvent(event, cause, world, potion.getItem())); // Fire entity interaction event if (!event.isCancelled()) { int blocked = 0; int affectedSize = event.getAffectedEntities().size(); boolean hasDamageEffect = Materials.hasDamageEffect(potion.getEffects()); for (LivingEntity affected : event.getAffectedEntities()) { DelegateEvent delegate = hasDamageEffect ? new DamageEntityEvent(event, cause, affected) : new UseEntityEvent(event, cause, affected); // Consider the potion splash flag delegate.getRelevantFlags().add(Flags.POTION_SPLASH); if (Events.fireAndTestCancel(delegate)) { event.setIntensity(affected, 0); blocked++; } } if (blocked == affectedSize) { // server does weird things with this if the event is modified, so use cached number event.setCancelled(true); } } }
for (PotionEffect effect : event.getPotion().getEffects()) { if (badPotionEffects.contains(effect.getType())) { badjuju = true;
Player thrower = (Player)projectileSource; Collection<PotionEffect> effects = potion.getEffects(); for(PotionEffect effect : effects)
Collection<PotionEffect> effects = potion.getEffects();