/** * Patching witch's potions * * @param event Event */ @EventHandler public void onPotionSplash(PotionSplashEvent event) { ThrownPotion potion = event.getPotion(); if (potion.getShooter() instanceof Witch) { event.setCancelled(true); List<PotionEffectType> potionEffects = new ArrayList<>(); potionEffects.add(PotionEffectType.SLOW_DIGGING); potionEffects.add(PotionEffectType.CONFUSION); potionEffects.add(PotionEffectType.NIGHT_VISION); potionEffects.add(PotionEffectType.HUNGER); potionEffects.add(PotionEffectType.BLINDNESS); PotionEffect selected = new PotionEffect(potionEffects.get(new Random().nextInt(potionEffects.size())), 20 * 15, 1); for (LivingEntity ent : event.getAffectedEntities()) ent.addPotionEffect(selected); } }
@EventHandler public void onPotionSplash(PotionSplashEvent event) { PotionEffect actual = null; for (PotionEffect potionEffect : event.getPotion().getEffects()) { if (potionEffect.getType().getName().equals("POISON")) { actual = potionEffect; break; } } if (actual != null) { event.setCancelled(true); event.getAffectedEntities().forEach(entity -> entity.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8 * 20, 0))); } }
@EventHandler public void onPotionSplash(PotionSplashEvent event) { boolean proceed = false; for (PotionEffect effect : event.getPotion().getEffects()) { if (effect.getType().equals(PotionEffectType.POISON) || effect.getType().equals(PotionEffectType.BLINDNESS) || effect.getType().equals(PotionEffectType.CONFUSION) || effect.getType().equals(PotionEffectType.HARM) || effect.getType().equals(PotionEffectType.HUNGER) || effect.getType().equals(PotionEffectType.SLOW) || effect.getType().equals(PotionEffectType.SLOW_DIGGING) || effect.getType().equals(PotionEffectType.WITHER) || effect.getType().equals(PotionEffectType.WEAKNESS)) { proceed = true; } } if (proceed && event.getPotion().getShooter() instanceof Player && TeamManager.getTeamByPlayer((Player) event.getPotion().getShooter()) != null) { TeamModule team = TeamManager.getTeamByPlayer((Player) event.getPotion().getShooter()); for (LivingEntity affected : event.getAffectedEntities()) { if (affected instanceof Player && TeamManager.getTeamByPlayer((Player) affected) != null && TeamManager.getTeamByPlayer((Player) affected).equals(team) && !affected.equals(event.getPotion().getShooter())) { event.setIntensity(affected, 0); } } } }
@Override public void onPlayerSplashedByPotion(PotionSplashEvent event, BPPlayer bpShooter, BPPlayer bpTarget) { CTFProperties targetProps = (CTFProperties) bpTarget.getGameProperties(); Player target = bpTarget.getPlayer(); CTFGame game = getGame(); if(targetProps.isEnemy(bpShooter) && !game.hasRoundEnded()) { if(targetProps.hasSpawnProtection()) { Player shooter = bpShooter.getPlayer(); shooter.sendMessage(MessageType.PVP_SPAWNKILLING.getTranslation().getValue()); event.setIntensity(target, 0); } } else event.setIntensity(target, 0); }
@EventHandler public void onPotionSplash(PotionSplashEvent event) { boolean proceed = false; for (PotionEffect effect : event.getPotion().getEffects()) { if (effect.getType().equals(PotionEffectType.POISON) || effect.getType().equals(PotionEffectType.BLINDNESS) || effect.getType().equals(PotionEffectType.CONFUSION) || effect.getType().equals(PotionEffectType.HARM) || effect.getType().equals(PotionEffectType.HUNGER) || effect.getType().equals(PotionEffectType.SLOW) || effect.getType().equals(PotionEffectType.SLOW_DIGGING) || effect.getType().equals(PotionEffectType.WITHER) || effect.getType().equals(PotionEffectType.WEAKNESS)) { proceed = true; } } if (proceed && event.getPotion().getShooter() instanceof Player && TeamUtils.getTeamByPlayer((Player) event.getPotion().getShooter()) != null) { TeamModule team = TeamUtils.getTeamByPlayer((Player) event.getPotion().getShooter()); for (LivingEntity affected : event.getAffectedEntities()) { if (affected instanceof Player && TeamUtils.getTeamByPlayer((Player) affected) != null && TeamUtils.getTeamByPlayer((Player) affected) == team && !affected.equals((Player) event.getPotion().getShooter())) { event.setIntensity(affected, 0); } } } }
@EventHandler public void PlayerTrownPotion(PotionSplashEvent e){ if (!(e.getPotion().getShooter() instanceof Player)){ return; } Player p = (Player)e.getPotion().getShooter(); Entity ent = e.getEntity(); RedProtect.get().logger.debug("Is PotionSplashEvent event."); Region r = RedProtect.get().rm.getTopRegion(ent.getLocation()); if (r != null && !r.usePotions(p)){ RPLang.sendMessage(p, "playerlistener.region.cantuse"); e.setCancelled(true); return; } //deny potion if (RPUtil.denyPotion(e.getPotion().getItem(), p)){ e.setCancelled(true); } }
/** * On potion splash. * * @param event * the event */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { if (event.getEntity() != null && event.getEntity().getShooter() instanceof Player) { IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea( event.getPotion().getLocation()); Player player = (Player) event.getEntity().getShooter(); if (!checkPermission(land, player, PermissionList.POTION_SPLASH.getPermissionType())) { if (player.isOnline()) { messagePermission(player); } event.setCancelled(true); } } }
public void onSplashPotionThrown(PotionSplashEvent event) { ThrownPotion potion = event.getPotion(); PotionEffect pShort = new PotionEffect(PotionEffectType.INVISIBILITY, 2701, 0, true); PotionEffect pLong = new PotionEffect(PotionEffectType.INVISIBILITY, 7201, 0, true); LivingEntity entity = potion.getShooter(); if ((entity instanceof Player)) { if (locationInWarzone(entity.getLocation())) { if (potion.getEffects().contains(pShort)) { event.setCancelled(true); giveBackPotion((Player) entity, (short) 32702); } else if (potion.getEffects().contains(pLong)) { event.setCancelled(true); giveBackPotion((Player) entity, (short) 32766); } } } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { ThrownPotion damager = event.getPotion(); Location l = BukkitUtil.getLocation(damager); if (!PS.get().hasPlotArea(l.getWorld())) { return; } int count = 0; for (LivingEntity victim : event.getAffectedEntities()) { if (!entityDamage(damager, victim)) { event.setIntensity(victim, 0); count++; } } if ((count > 0 && count == event.getAffectedEntities().size()) || !onProjectileHit(event)) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { UsePotionSplash action = this.newAction(UsePotionSplash.class, event.getPotion().getWorld()); if (action != null) { if (event.getPotion().getShooter() instanceof Player) { action.setPlayer((Player)event.getPotion().getShooter()); action.setLocation(event.getPotion().getLocation()); // TODO item etc. this.logAction(action); } // TODO other shooter } }
@EventHandler public void onPotionSplash(PotionSplashEvent event) { boolean proceed = false; for (PotionEffect effect : event.getPotion().getEffects()) { if (effect.getType().equals(PotionEffectType.POISON) || effect.getType().equals(PotionEffectType.BLINDNESS) || effect.getType().equals(PotionEffectType.CONFUSION) || effect.getType().equals(PotionEffectType.HARM) || effect.getType().equals(PotionEffectType.HUNGER) || effect.getType().equals(PotionEffectType.SLOW) || effect.getType().equals(PotionEffectType.SLOW_DIGGING) || effect.getType().equals(PotionEffectType.WITHER) || effect.getType().equals(PotionEffectType.WEAKNESS)) { proceed = true; } } if (proceed && event.getPotion().getShooter() instanceof Player && Teams.getTeamByPlayer((Player) event.getPotion().getShooter()) != null) { Optional<TeamModule> team = Teams.getTeamByPlayer((Player) event.getPotion().getShooter()); for (LivingEntity affected : event.getAffectedEntities()) { if (affected instanceof Player && Teams.getTeamByPlayer((Player) affected) != null && Teams.getTeamByPlayer((Player) affected).equals(team) && !affected.equals(event.getPotion().getShooter())) { event.setIntensity(affected, 0); } } } }
@EventHandler public void onPotionSplash(PotionSplashEvent event) { ThrownPotion potion = event.getEntity(); boolean harms = canHarm(potion); if (event.getEntity().getShooter() instanceof Player && disabledPlayers.contains((Player) event.getEntity().getShooter()) && harms) { event.setCancelled(true); ((Player) event.getEntity().getShooter()).sendMessage(ChatColor.DARK_RED + "You cannot harm other players with PvP off!"); return; } boolean cancellations = false; boolean everyone = true; for (LivingEntity e : event.getAffectedEntities()) { if (e instanceof Player && harms && disabledPlayers.contains((Player) e)) { event.setIntensity(e, 0.0); cancellations = true; } else { everyone = false; } } if (everyone) { event.setCancelled(true); ((Player) event.getEntity().getShooter()).sendMessage(ChatColor.LIGHT_PURPLE + "All targets of your splash potion has PvP disabled."); } else if (cancellations) { ((Player) event.getEntity().getShooter()).sendMessage(ChatColor.LIGHT_PURPLE + "Your splash potion's effects have been nullified on targets with PvP disabled."); } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPotionSplash(final ExtendedPotionSplashEvent ext) { final PotionSplashEvent event = (PotionSplashEvent)ext.getBaseEvent(); if (event.getPotion().getShooter() instanceof Player) { if (ext.hasNegativeEffect()) { GeneralRegion region; for (final LivingEntity e : event.getAffectedEntities()) { if (e.getType() == EntityType.PLAYER) { region = this.getPlugin().getDb().getPriorByLocation(e.getLocation()); if (region != null && region.getFlag(Flag.PVP)) { event.setCancelled(true); } } } } } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPotionSplash(final ExtendedPotionSplashEvent ext) { final PotionSplashEvent event = (PotionSplashEvent)ext.getBaseEvent(); final ProjectileSource shooter = event.getPotion().getShooter(); if (shooter instanceof LivingEntity && getMobs().contains(((Entity)shooter).getType())) { if (ext.hasNegativeEffect()) { GeneralRegion region; for (final LivingEntity e : event.getAffectedEntities()) { if (e.getType() == EntityType.PLAYER) { region = this.getPlugin().getDb().getPriorByLocation(e.getLocation()); if (region != null && region.getFlag(Flag.MOB)) { event.setCancelled(true); } } } } } }
/** * Handle PotionSplashEvent events that involve modifying the event. * * @param event The event to modify */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { ProjectileSource shooter = event.getPotion().getShooter(); if (!(shooter instanceof Player)) { return; } Player player = (Player) shooter; for (LivingEntity entity : event.getAffectedEntities()) { if (!(entity instanceof Player) || player == entity) { continue; } if (Ghosts.p.getGhostManager().isGhost(player)) { event.setIntensity(entity, 0); } } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPotionSplash(final PotionSplashEvent event) { for(LivingEntity entity : event.getAffectedEntities()) { if(!getMatch().canInteract(entity)) { event.setIntensity(entity, 0); } } }
@EventHandler(ignoreCancelled = true) public void onPotionSplash(final PotionSplashEvent event) { final ThrownPotion potion = event.getPotion(); if(PotionClassification.classify(potion) != PotionClassification.HARMFUL) return; for(LivingEntity victim : event.getAffectedEntities()) { final ParticipantState victimState = getMatch().getParticipantState(victim); final DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.MAGIC, victim, potion); if(victimState != null && queryDamage(event, victimState, damageInfo).isDenied()) { event.setIntensity(victim, 0); } } }
@Override public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(PotionSplashEvent.class)) { Skript.error( "The 'affected entities' expression can only be used in potion splash events", ErrorQuality.SEMANTIC_ERROR ); return false; } return true; }
@Override public boolean check(Event e) { if (e instanceof PotionSplashEvent) { if (effectTypesLiteral.getAll().length > 0) { if (effectTypesLiteral.getAll() != null) { return ((PotionSplashEvent) e).getEntity() .getEffects() .containsAll(Arrays.asList(effectTypesLiteral.getAll())); } } return true; } return false; }
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) public void onPotionSplash(PotionSplashEvent event) { ThrownPotion potion = event.getPotion(); if (potion.getShooter() instanceof Player && BukkitUtils.isDebuff(potion)) { for (LivingEntity livingEntity : event.getAffectedEntities()) { if (livingEntity instanceof Player) { if (getRemaining((Player) livingEntity) > 0L) { event.setIntensity(livingEntity, 0); } } } } }
@EventHandler public void onPotionSplash(final PotionSplashEvent event) { if (event.getEntity().getShooter() instanceof Player) { final Player shooter = (Player) event.getEntity().getShooter(); if (shooter.isSprinting() && event.getIntensity(shooter) > 0.5D) { event.setIntensity(shooter, 1.0D); } } }
@EventHandler(priority=EventPriority.LOWEST) public void splashPlayer(PotionSplashEvent event) { if(!(event.getPotion().getShooter()instanceof Player)) return; Player shooter = (Player) event.getPotion().getShooter(); boolean poison = false; boolean harm = false; boolean wither = false; for(PotionEffect effect : event.getPotion().getEffects()){ if(effect.getType().equals(PotionEffectType.POISON)){ poison = true; }else if(effect.getType().equals(PotionEffectType.HARM)){ harm = true; }else if(effect.getType().equals(PotionEffectType.WITHER)){ wither = true; } } if(poison || harm || wither){ VPPlayer sender = VanillaPlusCore.getPlayerManager().getPlayer(shooter); for(Entity e : event.getAffectedEntities()){ if(!(e instanceof Player)) continue; VPPlayer player = VanillaPlusCore.getPlayerManager().getPlayer((Player) e); VersusState versus = player.getVersus(); if(poison) versus.setPoison(sender); if(harm) versus.setHarm(sender); if(wither) versus.setWither(sender); } } }
/** * Stop negative effect splash potions from hurting a player's own team */ @EventHandler(priority = EventPriority.LOW) public void blockFriendlyFirePotions(PotionSplashEvent event) { Set<PotionEffectType> blacklist = new HashSet<>(); blacklist.add(PotionEffectType.HARM); blacklist.add(PotionEffectType.POISON); blacklist.add(PotionEffectType.WEAKNESS); blacklist.add(PotionEffectType.SLOW); blacklist.add(PotionEffectType.INVISIBILITY); if (!(event.getPotion().getShooter() instanceof Player)) return; Player damager = (Player) event.getPotion().getShooter(); Arena arena = plugin.getArenaHandler().getArenaForPlayer(damager); if (arena != null) { Team dTeam = PlayerUtil.getTeamForPlayer(arena.getMatch(), damager); for (LivingEntity ent : event.getAffectedEntities()) { if (!(ent instanceof Player)) continue; if (dTeam == PlayerUtil.getTeamForPlayer(arena.getMatch(), (Player) ent)) { for (PotionEffect effect : event.getPotion().getEffects()) { if (blacklist.contains(effect.getType())) event.setIntensity(ent, 0); } } } } }
/** * Stop splash potions from splashing */ @EventHandler public void onPotionsSplash(PotionSplashEvent event){ if (event.getEntity().getShooter() instanceof Player) { Player player = (Player) event.getEntity().getShooter(); if (shouldFreeze(player)) { event.setCancelled(true); } } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { for (LivingEntity entity : event.getAffectedEntities()) { if (this.isObserving(entity)) { event.setIntensity(entity, 0.0D); } } }
@Override public void onPlayerSplashedByPotion(PotionSplashEvent event, BPPlayer bpShooter, BPPlayer bpVictim) { DMGame game = getGame(); if(game.hasRoundEnded()) event.setIntensity(bpVictim.getPlayer(), 0); if(bpVictim.equals(bpShooter)) event.setIntensity(bpVictim.getPlayer(), 0); }
@EventHandler public void onPotionSplash(PotionSplashEvent event) { ThrownPotion ePotion = event.getPotion(); Entity eShooter = ePotion.getShooter(); if (eShooter instanceof Player) { Player shooter = (Player) eShooter; BPPlayer bpShooter = BPPlayer.get(shooter); if (bpShooter.isInGame()) { Game game = bpShooter.getGame(); for (LivingEntity eTarget : event.getAffectedEntities()) if (eTarget instanceof Player) { Player target = (Player) eTarget; BPPlayer bpTarget = BPPlayer.get(target); if (bpTarget.isInGameWith(bpShooter)) game.getListener().onPlayerSplashedByPotion(event, bpShooter, bpTarget); else event.setIntensity(eTarget, 0); } else event.setIntensity(eTarget, 0); } else event.setCancelled(true); } else event.setCancelled(true); }
/** * Prevent exiled players from using splash potions * @param e The event */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerThrowPotion(PotionSplashEvent e) { if(e.getEntity() != null && e.getEntity().getShooter() instanceof Player) { checkAndCancelRule(ExileRule.USE_POTIONS, e, (Player)e.getEntity().getShooter()); } }
@EventHandler(ignoreCancelled = true) public void on(PotionSplashEvent event) { for (LivingEntity entity : event.getAffectedEntities()) { if (!(entity instanceof Player)) continue; if (freezer.isCurrentlyFrozen(entity.getUniqueId())) { event.setIntensity(entity, 0); } } }
@EventHandler public void onPotionSplash(PotionSplashEvent event) { RedProtect.get().logger.debug("RPEntityListener - Is PotionSplashEvent"); if (event.isCancelled()) { return; } ProjectileSource thrower = event.getPotion().getShooter(); for (PotionEffect e : event.getPotion().getEffects()) { PotionEffectType t = e.getType(); if (!t.equals(PotionEffectType.BLINDNESS) && !t.equals(PotionEffectType.CONFUSION) && !t.equals(PotionEffectType.HARM) && !t.equals(PotionEffectType.HUNGER) && !t.equals(PotionEffectType.POISON) && !t.equals(PotionEffectType.SLOW) && !t.equals(PotionEffectType.SLOW_DIGGING) && !t.equals(PotionEffectType.WEAKNESS) && !t.equals(PotionEffectType.WITHER)) { return; } } Player shooter; if (thrower instanceof Player) { shooter = (Player)thrower; } else { return; } for (Entity e2 : event.getAffectedEntities()) { Region r = RedProtect.get().rm.getTopRegion(e2.getLocation()); if (event.getEntity() instanceof Player){ if (r != null && r.flagExists("pvp") && !r.canPVP((Player)event.getEntity(), shooter)) { event.setCancelled(true); return; } } else { if (r != null && !r.canInteractPassives(shooter)) { event.setCancelled(true); return; } } } }
@EventHandler(priority = EventPriority.LOW) public void onPotionSplash(PotionSplashEvent event) { for (PotionEffect effect : event.getPotion().getEffects()) { if (isPotionDisabled(effect)) { event.setCancelled(true); return; } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSplashPotion(PotionSplashEvent event) { if (Settings.INDICATOR_ENABLE.getValue("potion")) { for (Entity e : event.getAffectedEntities()) { if ((event.getEntity() instanceof Player && Settings.INDICATOR_SHOW_FOR_PLAYERS.getValue("potion")) || Settings.INDICATOR_SHOW_FOR_MOBS.getValue("potion")) { this.showPotionHologram(e, event.getPotion().getEffects()); } } } }
/** * Handle PotionSplash events in order to fix broken Splash Potion of Saturation. * * @param event The event to process */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) { if (!effect.getType().equals(PotionEffectType.SATURATION)) { return; } for (LivingEntity entity : event.getAffectedEntities()) { int duration = (int) (effect.getDuration() * event.getIntensity(entity)); entity.addPotionEffect(new PotionEffect(effect.getType(), duration, effect.getAmplifier(), effect.isAmbient())); } } }
@EventHandler public void onSpectatorPotionSplash(PotionSplashEvent e) { for (LivingEntity ent : e.getAffectedEntities()) { if (!(ent instanceof Player)) { continue; } Game game = gameSpectated((Player) ent); if (game == null) { continue; } e.setIntensity(ent, 0); } }
@EventHandler public void onPotionSplash(PotionSplashEvent event) { for (PotionEffect pe : event.getEntity().getEffects()) { if (pe.getType().equals(PotionEffectType.INVISIBILITY)) { event.setCancelled(true); if (event.getEntity().getShooter() instanceof Player) { ((Player) event.getEntity().getShooter()).sendMessage(ChatColor.DARK_RED + "You cannot use invisibility potions."); } } } }
public ExtendedPotionSplashEvent(final RegionDb db, final PotionSplashEvent event) { super(db.getPlugin(), event); final ThrownPotion potion = event.getPotion(); for (final PotionEffect e : potion.getEffects()) { if (getNegativeEffects().contains(e.getType())) { this.hasNegativeEffect = true; break; } } this.getPlugin().info(String.valueOf(this.hasNegativeEffect)); }