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


Java PotionSplashEvent.setCancelled方法代码示例

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


在下文中一共展示了PotionSplashEvent.setCancelled方法的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: 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

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

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

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

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

示例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();
    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

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

示例10: onPotionsSplash

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

示例11: onPotionSplash

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

示例12: onPotionSplash

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

示例13: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW) 
public void onPotionSplash(PotionSplashEvent event) {
	for (PotionEffect effect : event.getPotion().getEffects()) {
		if (isPotionDisabled(effect)) {
			event.setCancelled(true);
			return;
		}
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:10,代码来源:PlayerListener.java

示例14: onPotionSplash

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

示例15: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
/**
 * Acts upon a potion splash event. If the potion is not thrown by a player,
 * it's allowed to pass. If it was thrown by a player, however, it checks to
 * see if the potion's effect was allowed.
 *
 * @param event The PotionSplashEvent event
 */
@EventHandler(priority = EventPriority.HIGHEST)
public void onPotionSplash(PotionSplashEvent event) {
    if (event.getPotion().getShooter() instanceof Player) { // If a player threw the potion...
        List<PotionEffectType> deniedEffects = Util.getDeniedEffectsAtPlayerLoc((Player) event.getPotion().getShooter());
        Collection<PotionEffect> potionEffects = event.getPotion().getEffects();
        if (deniedEffects == null || potionEffects == null || deniedEffects.isEmpty() || potionEffects.isEmpty()) {
            return;
        }

        for (PotionEffect pe : potionEffects) {
            if (deniedEffects.contains(pe.getType())) {
                event.setCancelled(true); // We can try more complex checks later.
                Util.removeDisallowedEffects((Player) event.getPotion().getShooter());
                Collection<LivingEntity> affected = event.getAffectedEntities();
                if (affected != null && !affected.isEmpty()) { // If there is an affected entity
                    for (LivingEntity p : affected) {
                        if (p instanceof Player) {
                            Util.removeDisallowedEffects((Player) p);
                        }
                    }
                }
                return; // No more needs to be done.
            }
        }
    }
}
 
开发者ID:Tribalforge,项目名称:AntiPotionField,代码行数:34,代码来源:PlayerEventRegionsHandler.java


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