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


Java Player.hasPotionEffect方法代码示例

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


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

示例1: onEntityDamage

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
    if(event.getEntity() instanceof Player) {
        Player victim = (Player) event.getEntity();
        Location location = victim.getBoundingBox().center().toLocation(match.getWorld());
        if(event.getDamage() > 0 && location.getY() >= 0 && !victim.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
            EntityUtils.entities(match.getWorld(), Player.class)
                 .filter(player -> settings.getManager(player).getValue(Settings.BLOOD, Boolean.class, false))
                 .forEach(player -> {
                     if(event instanceof EntityDamageByEntityEvent) {
                         player.playEffect(location, Effect.STEP_SOUND, Material.REDSTONE_WIRE);
                     } else {
                         player.playEffect(location, Effect.STEP_SOUND, Material.LAVA);
                     }
                 });
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:BloodMatchModule.java

示例2: onMove

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent evt) {
    Player p = evt.getPlayer();
    Block b = p.getLocation().getBlock();
    if (isImmune(p) // Verify we should get an alert from this player.
            || Utils.isSameBlock(evt.getFrom(), evt.getTo()) // Check they've moved at least to the next block.
            || !checkNearby(b)) // Check if a block is nearby them.
        return;

    double yDif = evt.getTo().getY() - evt.getFrom().getY();
    double ascentMax = 0.8D;
    if (p.hasPotionEffect(PotionEffectType.JUMP))
        ascentMax += (double) p.getPotionEffect(PotionEffectType.JUMP).getAmplifier() / 10;

    detections.detect(new Detection(p),
            yDif == 0 && !checkNearby(evt.getFrom(), Material.WATER_LILY, Material.CARPET), // Hover.
            yDif > ascentMax, // If they sharply ascend.
            yDif == -.125D); // Glide (Unsure if this works.)
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:20,代码来源:Flight.java

示例3: checkAscension

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void checkAscension(Player player, double y1, double y2) {
    int max = MagicNumbers.ASCENSION_COUNT_MAX;
    if(player.hasPotionEffect(PotionEffectType.JUMP)) {
        max += 12;
    }
    Block block = player.getLocation().getBlock();
    if(!isMovingExempt(player) && !Utilities.isInWater(player) && !player.isFlying() && !Utilities
            .isClimbableBlock(player.getLocation().getBlock()) && !player.isInsideVehicle() && !MOVE_UP_BLOCKS
            .contains(player.getLocation().add(0,-1,0).getBlock().getType()) && !MOVE_UP_BLOCKS.contains(player
            .getLocation().add(0,-1.5,0).getBlock().getType())) {
        if(y1 < y2) {
            if(!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid()) {
                incrementOld(player,ascensionCount,max);
                if(ascensionCount.get(player) > max) {
                    for(Player pla : DynamicAC.instance.onlinestaff) {
                        pla.sendMessage(DynamicAC.prefix + player.getName() + " ascended Y Axis too fast!");
                    }
                    DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName
                            ()),"Climbed too fast");
                }
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:25,代码来源:BackendChecks.java

示例4: conformMinerInvisibility

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Applies the {@link MinerClass} invisibility {@link PotionEffect} depending on the {@link Player}s {@link Location}.
 *
 * @param player
 *            the {@link Player} to apply for
 * @param from
 *            the from {@link Location}
 * @param to
 *            the to {@link Location}
 */
private void conformMinerInvisibility(Player player, Location from, Location to) {
    int fromY = from.getBlockY();
    int toY = to.getBlockY();
    if (fromY != toY && plugin.getPvpClassManager().hasClassEquipped(player, this)) {
        boolean isInvisible = player.hasPotionEffect(PotionEffectType.INVISIBILITY);
        if (toY > INVISIBILITY_HEIGHT_LEVEL) {
            if (fromY <= INVISIBILITY_HEIGHT_LEVEL && isInvisible) {
                removeInvisibilitySafely(player);
            }
        } else {
            if (!isInvisible) {
                player.addPotionEffect(HEIGHT_INVISIBILITY, true);
                player.sendMessage(ChatColor.AQUA + getName() + ChatColor.GRAY + " invisibility added.");
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:28,代码来源:MinerClass.java

示例5: isCritical

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * @return Whether the hit is a critical hit or not.
 */
private boolean isCritical() {
	final Player player = profile.getPlayer();
	final Behaviour behaviour = profile.getBehaviour();
	return player.getFallDistance() > 0.0 && !behaviour.isOnLadder() && !behaviour.isOnVine()
			&& !behaviour.isInWater() && !player.hasPotionEffect(PotionEffectType.BLINDNESS)
			&& !player.isInsideVehicle() && !player.isSprinting() && !((Entity) player).isOnGround();
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:11,代码来源:CriticalsA.java

示例6: watch

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void watch(Player player){
    if (player.hasPotionEffect(PotionEffectType.SLOW)) {
        player.removePotionEffect(PotionEffectType.SLOW);
        return;
    }
    player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 99999, 3));
}
 
开发者ID:cadox8,项目名称:WC,代码行数:8,代码来源:Weapon.java

示例7: getMaxJump

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Return max distance we can ascend.
 *
 * @param player the player
 * @return the max jump height.
 */
private double getMaxJump(Player player) {

    double max = maxHeight;

    if (player.hasPotionEffect(PotionEffectType.JUMP)) {
        max += 0.4;
    }
    return max;

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:17,代码来源:Flight17.java

示例8: isCritical

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Check if an attack was a critical.
 *
 * @param player the player
 * @return true, if the attack was registered as a critical.
 */
public static boolean isCritical(Player player) {

    boolean onGround = ((Entity) player).isOnGround();
    return !onGround && player.getFallDistance() > 0.0F && !LocationHelper.isInLiquid(player.getLocation())
            && (player.getLocation().getBlock().getType() != Material.LADDER
            || player.getLocation().getBlock().getType() != Material.VINE)
            && player.getVehicle() == null && !player.hasPotionEffect(PotionEffectType.BLINDNESS);
}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:15,代码来源:FightHelper.java

示例9: isImmune

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Is the player in a state or situation that we should deem them not flying?
 * @param player
 * @return immune
 */
private static boolean isImmune(Player player) {
    return player.getGameMode() != GameMode.SURVIVAL
            || Utils.getRank(player).isAtLeast(EnumRank.MEDIA) // Don't bypass this check.
            || player.isGliding() // Not using Elytra
            || player.hasPotionEffect(PotionEffectType.LEVITATION) // Doesn't have a levitation potion
            || player.getVehicle() != null // Not in a vehicle
            || player.getVelocity().getY() > 0 // Not being launched up
            || player.getNearbyEntities(1, 2, 1).stream().anyMatch(e -> e.getType() == EntityType.BOAT) // Not standing on a boat.
            || player.getLocation().getBlock().isLiquid(); // Not in water.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:16,代码来源:Flight.java

示例10: checkYSpeed

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void checkYSpeed(Player player, double y) {
    if(!isMovingExempt(player) && !player.isInsideVehicle() && (y > MagicNumbers.Y_SPEED_MAX) && !isDoing(player,
            velocitized,MagicNumbers.VELOCITY_TIME) && !player.hasPotionEffect(PotionEffectType.JUMP) && !player
            .isFlying()) {
        for(Player pla : DynamicAC.instance.onlinestaff) {
            pla.sendMessage(DynamicAC.prefix + player.getName() + " went too fast on the Y Axis!");
        }
        DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),"Y axis");
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:11,代码来源:BackendChecks.java

示例11: isCritical

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static boolean isCritical(Player player) {
    Location location = player.getLocation();
    location.setY(player.getLocation().getY() -2);
    return player.getFallDistance() > 0.0f && player.getLocation().getY() % 1 != 0 && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS) && !Utilities.isHoveringOverWater(location) &&
            player
            .getEyeLocation()
            .getBlock()
            .getType
            () !=
            Material
            .LADDER;
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:13,代码来源:DynamicAC.java

示例12: onWorldChanged

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onWorldChanged(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    World from = event.getFrom();
    World to = player.getWorld();
    if (from.getEnvironment() != World.Environment.THE_END && to.getEnvironment() == World.Environment.THE_END && player.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
        player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:PortalListener.java

示例13: handleTimedEffects

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Adding potion effects to ability items
 * @param player The player
 * @param item The item with ability
 */
private void handleTimedEffects(Player player, ItemStack item) {
	if(item == null)
		return;
	
	if(!plugin.getAbilityManager().hasAbility(item))
		return;
	
	Ability ability = plugin.getAbilityManager().getAbility(item);
	
	PotionEffectType type;
	switch(ability.getName()) {
		case "Haste":
			type = PotionEffectType.FAST_DIGGING;
			break;
		case "High Jump":
			type = PotionEffectType.JUMP;
			break;
		case "Speed":
			type = PotionEffectType.SPEED;
			break;
		default:
			return;
	}
	if(player.hasPotionEffect(type)) {
		player.removePotionEffect(type);
	}
	player.addPotionEffect(new PotionEffect(type, 60, 1));
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:34,代码来源:AbilityManager.java

示例14: handlePoison

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void handlePoison(Player damager, Player target) {
	if(target.hasPotionEffect(PotionEffectType.POISON))
		return;
	
	target.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 0));
	target.sendMessage(Lang.HEADERS_TOKENS.toString()
			+ Lang.TOKENS_POISONED.toString()
				.replaceAll("%s", damager.getName()));
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:10,代码来源:AbilityListener.java

示例15: onEat

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onEat(PlayerItemConsumeEvent e) {
	if (e.getItem() != null) {
		final Player p = e.getPlayer();
		ItemStack item = e.getItem();
		if (Slimefun.hasUnlocked(p, item, true)) {
			if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MONSTER_JERKY, true)) {
				e.setCancelled(true);
				if (SlimefunManager.isItemSimiliar(p.getInventory().getItemInOffHand(), SlimefunItems.MONSTER_JERKY, true)) {
					p.getInventory().setItemInOffHand(InvUtils.decreaseItem(p.getInventory().getItemInOffHand(), 1));
				}
				else{
					p.getInventory().setItemInMainHand(InvUtils.decreaseItem(p.getInventory().getItemInMainHand(), 1));
				}
				PlayerInventory.update(p);
				p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 5, 0));
			}
			else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.FORTUNE_COOKIE, true)) p.sendMessage(ChatColor.translateAlternateColorCodes('&', Messages.local.getTranslation("messages.fortune-cookie").get(CSCoreLib.randomizer().nextInt(Messages.local.getTranslation("messages.fortune-cookie").size()))));
			else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BEEF_JERKY, true)) p.setSaturation((Integer) Slimefun.getItemValue("BEEF_JERKY", "Saturation"));
			else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MEDICINE, true)) {
				if (p.hasPotionEffect(PotionEffectType.POISON)) p.removePotionEffect(PotionEffectType.POISON);
				if (p.hasPotionEffect(PotionEffectType.WITHER)) p.removePotionEffect(PotionEffectType.WITHER);
				if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
				if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
				if (p.hasPotionEffect(PotionEffectType.WEAKNESS)) p.removePotionEffect(PotionEffectType.WEAKNESS);
				if (p.hasPotionEffect(PotionEffectType.CONFUSION)) p.removePotionEffect(PotionEffectType.CONFUSION);
				if (p.hasPotionEffect(PotionEffectType.BLINDNESS)) p.removePotionEffect(PotionEffectType.BLINDNESS);
				p.setFireTicks(0);
			}
			else if (item.getType() == Material.POTION) {
				SlimefunItem sfItem = SlimefunItem.getByItem(item);
				if (sfItem != null && sfItem instanceof Juice) {
					int mode = 0;
					
					if (SlimefunManager.isItemSimiliar(item, p.getInventory().getItemInMainHand(), true)) {
						if (p.getInventory().getItemInMainHand().getAmount() == 1) {
							mode = 0;
						}
						else {
							mode = 2;
						}
					}
					else if (SlimefunManager.isItemSimiliar(item, p.getInventory().getItemInOffHand(), true)) {
						if (p.getInventory().getItemInOffHand().getAmount() == 1) {
							mode = 1;
						}
						else {
							mode = 2;
						}
					}
					
					final int m = mode;
					
					Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
						
						
		                @Override
		                public void run() {
		                    if (m == 0) {
		                    	p.getInventory().setItemInMainHand(null);
		                    }
		                    else if (m == 1) {
		                    	p.getInventory().setItemInOffHand(null);
		                    }
		                    else if (m == 2) {
		                    	p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1));
		                    }
		                }
		                
		            }, 1L);
				}
			}
		}
		else e.setCancelled(true);
	}
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:77,代码来源:ItemListener.java


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