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


Java PotionSplashEvent.getEntity方法代码示例

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


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

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

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

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

示例4: onPlayerThrowPotion

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

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

示例6: onSplashPotion

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

示例7: onPotionSplash

import org.bukkit.event.entity.PotionSplashEvent; //导入方法依赖的package包/类
@EventHandler
public void onPotionSplash(PotionSplashEvent event) {
	if (Variables.friendlyfire_enable
			&& event.getEntity() instanceof Player
			&& event.getPotion().getShooter() instanceof Player) {
		Player attacker = (Player) event.getPotion().getShooter();
		ThePlayer tpAttacker = plugin.getPlayerHandler().getPlayer(attacker.getUniqueId());
		
		if (!tpAttacker.getPartyName().isEmpty()
				&& (Variables.friendlyfire_listworlds.contains("*")
						|| Variables.friendlyfire_listworlds.contains(attacker.getWorld().getName()))) {
			boolean cancel = false;
			for (PotionEffect pe : event.getEntity().getEffects()) {
				switch (pe.getType().getName().toLowerCase()) {
				case "harm":
				case "blindness":
				case "confusion":
				case "poison":
				case "slow":
				case "slow_digging":
				case "weakness":
				case "unluck":
					cancel = true;
				}
				if (cancel)
					break;
			}
			if (cancel) {
				// Friendly fire not allowed here
				Party party = plugin.getPartyHandler().getParty(tpAttacker.getPartyName());
				for (LivingEntity e : event.getAffectedEntities()) {
					if (e instanceof Player) {
						Player victim = (Player) e;
						if (!attacker.equals(victim)) {
							ThePlayer tpVictim = plugin.getPlayerHandler().getPlayer(victim.getUniqueId());
							if (tpVictim.getPartyName().equalsIgnoreCase(tpAttacker.getPartyName())) {
								// Calling API event
								PartiesPotionsFriendlyFireBlockedEvent partiesFriendlyFireEvent = new PartiesPotionsFriendlyFireBlockedEvent(victim, attacker, event);
								Bukkit.getServer().getPluginManager().callEvent(partiesFriendlyFireEvent);
								if (!partiesFriendlyFireEvent.isCancelled()) {
									// Friendly fire confirmed
									tpAttacker.sendMessage(Messages.canthitmates);
									party.sendFriendlyFireWarn(tpVictim, tpAttacker);
									
									event.setIntensity(e, 0);
									LogHandler.log(LogLevel.DEBUG, "Denied PvP friendly fire [Potion splash] between A:'" + attacker.getName() + "' and V:'" + victim.getName() + "'", true);
								} else
									LogHandler.log(LogLevel.DEBUG, "PartiesPotionsFriendlyFireBlockedEvent is cancelled, ignoring [Potion splash] between A:'" + attacker.getName() + "' and V:'" + victim.getName() + "'", true);
							}
						}
					}
				}
			}
		}
	}
}
 
开发者ID:AlessioDP,项目名称:Parties,代码行数:57,代码来源:FightListener.java


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