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


Java Player.addPotionEffect方法代码示例

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


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

示例1: onGameStart

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Give effects to all players
 *
 * @param game Game instance
 */
@Override
public void onGameStart(SurvivalGame game)
{
    for (SurvivalPlayer player : (Collection<SurvivalPlayer>)game.getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p == null)
            continue;

        p.addPotionEffect(PotionEffectType.SPEED.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.DAMAGE_RESISTANCE.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.JUMP.createEffect(Integer.MAX_VALUE, 4));
        p.setMaxHealth(32D);
        p.setHealth(32D);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:24,代码来源:SuperheroesModule.java

示例2: giveSlow

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void giveSlow(int durationSeconds, int tier) {
    int highestTier = tier;
    int remaining = 0;
    Player p = getPlayer();
    if (p == null)
        return;
    for (PotionEffect pe : p.getActivePotionEffects()) {
        if (pe.getType().equals(PotionEffectType.SLOW)) {
            remaining = pe.getDuration();
            int temp = pe.getAmplifier();
            if (temp > highestTier)
                highestTier = temp;
        }
    }

    p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, RTicks.seconds(durationSeconds) + (remaining / 2), highestTier), true);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:18,代码来源:PlayerDataRPG.java

示例3: handleFreeze

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void handleFreeze(Player player, Rune rune) {
	Player target = Utility.getTargetPlayer(player, 10);
	if(target == null || !Utility.canAttack(player, target)) {
		return;
	}
	
	LineEffect eff = new LineEffect(plugin.getEffectManager());
	eff.setEntity(player);
	eff.setTargetEntity(target);
	eff.particle = ParticleEffect.SNOW_SHOVEL;
	eff.start();
	target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 6));
	target.playSound(target.getLocation(), Sound.ENTITY_SNOWMAN_DEATH, 1F, 1F);
	
	player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
	player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_APPLY.toString()
		.replaceAll("%s", rune.getName()));
	target.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_FROZEN.toString()
			.replaceAll("%s", player.getName()));
	finish(player, false);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:22,代码来源:RuneManager.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: onConsume

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(event.isCancelled()) return;
	Player player = event.getPlayer();
	if(event.getItem().getType() == Material.POISONOUS_POTATO)
	{
		for (PotionEffect effect : player.getActivePotionEffects())
	        player.removePotionEffect(effect.getType());

		Random rand = new Random();
		if(rand.nextInt(10) + 1 <= 6)
		{
			player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 0), true);
			player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 0), true);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:19,代码来源:PoisonousPotato.java

示例6: giveStealth

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void giveStealth(Player p, int seconds) {
    invis.add(p);
    for(Player p2 : plugin.getServer().getOnlinePlayers())
        p2.hidePlayer(p);
    p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, RTicks.seconds(seconds), 1, true, false));
    RParticles.showWithOffset(ParticleEffect.SMOKE_LARGE, p.getLocation().add(0, p.getEyeHeight() * 0.7, 0), 1.0, 15);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:8,代码来源:StealthManager.java

示例7: initPlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void initPlayer(final Player player, boolean skipJoinMessage) {
    boolean rpEnabled = Config.getConfig().getBoolean("resource-pack.enabled", true);
    if (rpEnabled) {
        player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60, 1));
    }

    if (InventoryManager.isNewPlayer(player) && rpEnabled) {
        if (Config.getConfig().getBoolean("join-messages.rp-info.enabled", true)) {
            Runnable callback = () -> InventoryManager.sendResourcePack(player);

            EffectUtils.sendTitle(player,
                    Config.getConfig().getInt("join-messages.delay"),
                    Config.getConfig().getString("join-messages.rp-info.title"),
                    Config.getConfig().getStringList("join-messages.rp-info.text"), callback);
        } else {
            InventoryManager.sendResourcePack(player);
        }
    } else {
        if (Config.getConfig().getBoolean("join-messages.default.enabled", true)) {
            if (!skipJoinMessage) {
                EffectUtils.sendTitle(player,
                        Config.getConfig().getInt("join-messages.delay"),
                        Config.getConfig().getString("join-messages.default.title"),
                        Config.getConfig().getStringList("join-messages.default.text"), null);
            }
        }

        if (rpEnabled) {
            InventoryManager.sendResourcePack(player);
        } else {
            InventoryManager.loadPlayerInventory(player);
        }
    }

    if (RPGInventory.getPermissions().has(player, "rpginventory.admin")) {
        RPGInventory.getInstance().checkUpdates(player);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:39,代码来源:InventoryManager.java

示例8: cast

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean cast(final Player p, PlayerDataRPG pd, int level) {
    if (!pd.isStealthed()) {
        p.sendMessage(ChatColor.RED + "Shadow Acrobat can only be used while in stealth.");
        return false;
    }
    int durationSeconds = 0;
    switch (level) {
        case 1:
            durationSeconds = 5;
            break;
        case 2:
            durationSeconds = 7;
            break;
        case 3:
            durationSeconds = 9;
            break;
        case 4:
            durationSeconds = 11;
            break;
        case 5:
            durationSeconds = 13;
            break;
    }
    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, RTicks.seconds(durationSeconds), 4, true, false));
    p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, RTicks.seconds(durationSeconds), 2, true, false));
    Spell.notify(p, "You feel extremely nimble.");
    return true;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:30,代码来源:ShadowAcrobat.java

示例9: cast

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean cast(final Player p, PlayerDataRPG pd, int level) {
    double multiplier = 2.0;
    switch (level) {
        case 1:
            multiplier = 2.0;
            break;
        case 2:
            multiplier = 2.3;
            break;
        case 3:
            multiplier = 2.6;
            break;
        case 4:
            multiplier = 2.9;
            break;
        case 5:
            multiplier = 3.2;
            break;
    }
    ArrayList<Location> locs = new ArrayList<Location>();
    final Location startLoc = p.getLocation().clone();
    locs.add(startLoc.clone().add(1, 0, 1));
    locs.add(startLoc.clone().add(1, 0, -1));
    locs.add(startLoc.clone().add(-1, 0, 1));
    locs.add(startLoc.clone().add(-1, 0, -1));
    for (Location loc : locs) {
        RParticles.sendLightning(p, loc);
    }
    p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, RTicks.seconds(10), 5, true, false));
    pd.giveBuff(WalkingSanctuary.BUFF_ID, multiplier, 10000);
    Spell.notify(p, "You call upon divine powers.");
    Spell.notifyDelayed(p, "You feel Walking Sanctuary wear off.", 10);
    return true;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:36,代码来源:WalkingSanctuary.java

示例10: onGameStart

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Give a night vision effect to every players
 *
 * @param game Game
 */
@Override
public void onGameStart(SurvivalGame game)
{
    for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
    {
        Player player1 = player.getPlayerIfOnline();
        if (player1 != null)
            player1.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 255));
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:16,代码来源:CatsEyesModule.java

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

示例12: setNinjaNaut

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void setNinjaNaut(SurvivalGame game, SurvivalPlayer player, boolean first)
{
    if (!player.isOnline() || player.isSpectator())
        return;

    this.ninjanaut = player.getUUID();

    game.getCoherenceMachine().getMessageManager().writeCustomMessage(player.getPlayerData().getDisplayName() + (first ? " a été choisi comme Ninjanaut" : " a tué le Ninjanaut, et prends donc sa place") + ". Il sera plus résistant, tuez le pour prendre sa place.", true);

    Player p = player.getPlayerIfOnline();
    p.addPotionEffect(PotionEffectType.SPEED.createEffect(Integer.MAX_VALUE, 2));
    p.addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(Integer.MAX_VALUE, 2));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:14,代码来源:NinjanautModule.java

示例13: onConsume

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(event.isCancelled()) return;
	Player player = event.getPlayer();
	if(event.getItem().getType() == Material.COOKIE)
	{
		int amp = -1;
		int dur = 600;
		for (PotionEffect effect : player.getActivePotionEffects())
		{
			if(effect.getType().equals(PotionEffectType.HEALTH_BOOST))
			{
				dur += effect.getDuration();
				if(effect.getDuration() >= 300)
					amp++;
				if(effect.getDuration() >= 1200)
					amp++;
				if(effect.getDuration() >= 3600)
					amp++;
		        player.removePotionEffect(effect.getType());
			}
		}
		player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, dur, amp));
		player.setSaturation(player.getSaturation() + 4.6f);
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:28,代码来源:CookieHealthBoost.java

示例14: onPotionEffectExpire

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPotionEffectExpire(PotionEffectExpireEvent event) {
    LivingEntity livingEntity = event.getEntity();
    if (livingEntity instanceof Player) {
        Player player = (Player) livingEntity;
        PotionEffect previous = restores.remove(player.getUniqueId(), event.getEffect().getType());
        if (previous != null) {
            event.setCancelled(true);
            player.addPotionEffect(previous, true);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:13,代码来源:EffectRestorer.java

示例15: WaterPower

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void WaterPower(PlayerMoveEvent event) {
	Player p = event.getPlayer();
	if (Kit.getKit(p).getName().equalsIgnoreCase("poseidon")) {
		Material m = p.getLocation().getBlock().getType();
		if (m == Material.STATIONARY_WATER || m == Material.WATER) {
			p.addPotionEffect(new PotionEffect(
					PotionEffectType.INCREASE_DAMAGE, 200, 1));
			p.setRemainingAir(300);
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:13,代码来源:KitEvents.java


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