当前位置: 首页>>代码示例>>Java>>正文


Java PotionSplashEvent.getAffectedEntities方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.PotionSplashEvent.getAffectedEntities方法的典型用法代码示例。如果您正苦于以下问题:Java PotionSplashEvent.getAffectedEntities方法的具体用法?Java PotionSplashEvent.getAffectedEntities怎么用?Java PotionSplashEvent.getAffectedEntities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.PotionSplashEvent的用法示例。


在下文中一共展示了PotionSplashEvent.getAffectedEntities方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:28,代码来源:NaturalListener.java

示例2: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:Minehut,项目名称:GamePlate,代码行数:22,代码来源:FriendlyFireModule.java

示例3: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:22,代码来源:FriendlyFire.java

示例4: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:19,代码来源:PlayerEvents.java

示例5: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:22,代码来源:FriendlyFire.java

示例6: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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.");
    }
}
 
开发者ID:CoderMonkeys,项目名称:TerraCraftTools,代码行数:27,代码来源:PVPDisable.java

示例7: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
                    }
                }
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:18,代码来源:PvpFlagListener.java

示例8: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
                    }
                }
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:19,代码来源:MobFlagListener.java

示例9: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:TfT-02,项目名称:Ghosts,代码行数:26,代码来源:EntityListener.java

示例10: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:EventFilterMatchModule.java

示例11: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:DamageMatchModule.java

示例12: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
                }
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:InvincibilityTimer.java

示例13: splashPlayer

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
		}
	}
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:33,代码来源:VersusManager.java

示例14: blockFriendlyFirePotions

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
/**
 * 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);
                }
            }
        }
    }

}
 
开发者ID:redwallhp,项目名称:AthenaGM,代码行数:31,代码来源:FriendlyFireModule.java

示例15: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:9,代码来源:ObserverListeners.java


注:本文中的org.bukkit.event.entity.PotionSplashEvent.getAffectedEntities方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。