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


Java PotionSplashEvent类代码示例

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


PotionSplashEvent类属于org.bukkit.event.entity包,在下文中一共展示了PotionSplashEvent类的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)
{
    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)));
    }
}
 
开发者ID:SamaGames,项目名称:DoubleRunner,代码行数:21,代码来源:DoubleRunnerGameLoop.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 && 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

示例4: onPlayerSplashedByPotion

import org.bukkit.event.entity.PotionSplashEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:20,代码来源:CTFListener.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 && 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

示例6: PlayerTrownPotion

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

示例7: onPotionSplash

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

示例8: onSplashPotionThrown

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

示例9: 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

示例10: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入依赖的package包/类
@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
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:17,代码来源:ListenerItem.java

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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