@EventHandler public void potionSplash(PotionSplashEvent event) { if (!event.getPotion().getWorld().getName().equals(getName())) return; event.setCancelled(true); Iterator iterator = event.getAffectedEntities().iterator(); while (iterator.hasNext()) { LivingEntity target = (LivingEntity) iterator.next(); if (event.getEntity().getShooter().equals(target)) { Player p = (Player) target; p.sendMessage(ChatColor.RED + "You cannot heal yourself!"); } else { target.addPotionEffect(event.getPotion().getEffects().iterator().next()); } } }
@EventHandler(priority = EventPriority.NORMAL) public void onSplashPotion(PotionSplashEvent event) { if (event.isCancelled()) return; Entity ent = event.getEntity(); boolean srcpvp = Residence.getPermsByLoc(ent.getLocation()).has("pvp", true); Iterator<LivingEntity> it = event.getAffectedEntities().iterator(); while (it.hasNext()) { LivingEntity target = it.next(); if (target.getType() == EntityType.PLAYER) { Boolean tgtpvp = Residence.getPermsByLoc(target.getLocation()).has("pvp", true); if (!srcpvp || !tgtpvp) { event.setIntensity(target, 0); } } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPotionSplash(final PotionSplashEvent event) { ThrownPotion potion = event.getPotion(); Collection<PotionEffect> effects = ((PotionMeta) potion.getItem().getItemMeta()).getCustomEffects(); Bukkit.broadcastMessage( "A " + event.getEntity().getType().getName() + " splashed a potion with " + effects.size() + " effects attached:"); for (PotionEffect effect : effects) { Bukkit.broadcastMessage( "Type: " + effect.getType().getName() + ", Level: " + (effect.getAmplifier() + 1) + ", Duration: " + effect.getDuration()); } }