Java 类org.bukkit.event.entity.PotionSplashEvent 实例源码

项目:SurvivalAPI    文件:NaturalListener.java   
/**
 * 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);
    }
}
项目:DoubleRunner    文件:DoubleRunnerGameLoop.java   
@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)));
    }
}
项目:GamePlate    文件:FriendlyFireModule.java   
@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);
            }
        }
    }
}
项目:Breakpoint    文件:CTFListener.java   
@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);
}
项目:Cardinal-Plus    文件:FriendlyFire.java   
@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);
            }
        }
    }
}
项目:RedProtect    文件:RPPlayerListener.java   
@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);
    }
}
项目:Breakpoint    文件:CTFListener.java   
@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);
}
项目:Factoid    文件:PlayerListener.java   
/**
 * 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);
        }
    }
}
项目:DDCustomPlugin    文件:LegitWarzone.java   
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);
            }
        }
    }
}
项目:PlotSquared    文件:PlayerEvents.java   
@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);
    }
}
项目:modules-extra    文件:ListenerItem.java   
@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
    }
}
项目:CardinalPGM    文件:FriendlyFire.java   
@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);
            }
        }
    }
}
项目:TerraCraftTools    文件:PVPDisable.java   
@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.");
    }
}
项目:NPlugins    文件:PvpFlagListener.java   
@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);
                    }
                }
            }
        }
    }
}
项目:NPlugins    文件:MobFlagListener.java   
@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);
                    }
                }
            }
        }
    }
}
项目:Ghosts    文件:EntityListener.java   
/**
 * 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);
        }
    }
}
项目:ProjectAres    文件:EventFilterMatchModule.java   
@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);
        }
    }
}
项目:ProjectAres    文件:DamageMatchModule.java   
@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);
        }
    }
}
项目:QuarSK    文件:ExprPotionSplashAffectedEntities.java   
@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;
}
项目:QuarSK    文件:EvtPotionSplash.java   
@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;
}
项目:HCFCore    文件:InvincibilityTimer.java   
@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);
                }
            }
        }
    }
}
项目:HCFCore    文件:PotListener.java   
@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);
        }
    }
}
项目:HCFCore    文件:InvincibilityTimer.java   
@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);
                }
            }
        }
    }
}
项目:VanillaPlus    文件:VersusManager.java   
@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);
        }
    }
}
项目:AthenaGM    文件:FriendlyFireModule.java   
/**
 * 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);
                }
            }
        }
    }

}
项目:AthenaGM    文件:PlayerFreezeModule.java   
/**
 * 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);
        }
    }
}
项目:Arcade2    文件:ObserverListeners.java   
@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);
        }
    }
}
项目:Breakpoint    文件:DMListener.java   
@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);
}
项目:Breakpoint    文件:PVPListener.java   
@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);
}
项目:ExilePearl    文件:ExileListener.java   
/**
 * 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());
    }
}
项目:FancyFreeze    文件:PotionListener.java   
@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);
        }
    }
}
项目:RedProtect    文件:RPEntityListener.java   
@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;
            }
        }            
    }
}
项目:Breakpoint    文件:DMListener.java   
@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);
}
项目:Breakpoint    文件:PVPListener.java   
@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);
}
项目:civcraft    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.LOW) 
public void onPotionSplash(PotionSplashEvent event) {
    for (PotionEffect effect : event.getPotion().getEffects()) {
        if (isPotionDisabled(effect)) {
            event.setCancelled(true);
            return;
        }
    }
}
项目:HoloAPI    文件:IndicatorListener.java   
@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());
            }
        }
    }
}
项目:McMMOPlus    文件:EntityListener.java   
/**
 * 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()));
        }
    }
}
项目:cloudgame    文件:Spectators.java   
@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);
    }
}
项目:TerraCraftTools    文件:NoInvisibilityPotions.java   
@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.");
            }
        }
    }
}
项目:NPlugins    文件:ExtendedPotionSplashEvent.java   
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));
}