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


Java Player.getActivePotionEffects方法代码示例

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


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

示例1: resetPlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void resetPlayer(Player player) {
    player.setLevel(0);
    player.setExp(0);
    player.setFoodLevel(20);
    player.setHealth(20);
    player.setHealthScale(20);
    player.setExhaustion(0);
    player.getInventory().clear();
    ItemStack blankItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 15);
    ItemMeta blankMeta = blankItem.getItemMeta();
    blankMeta.setDisplayName("" + ChatColor.RED);
    blankItem.setItemMeta(blankMeta);
    for(int i=9; i<=35; i++) {
        player.getInventory().setItem(i, blankItem);
    }
    player.getInventory().setHelmet(new ItemStack(Material.AIR, 1));
    player.getInventory().setChestplate(new ItemStack(Material.AIR, 1));
    player.getInventory().setLeggings(new ItemStack(Material.AIR, 1));
    player.getInventory().setBoots(new ItemStack(Material.AIR, 1));
    for(PotionEffect potionEffect : player.getActivePotionEffects()) {
        player.removePotionEffect(potionEffect.getType());
    }
    player.setFireTicks(0);
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:25,代码来源:Utils.java

示例2: cleanPlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Clean player's inventory
 *
 * @param player Player
 */
public static void cleanPlayer(Player player)
{
    if(player != null && Bukkit.getPlayer(player.getUniqueId()) != null)
    {
        player.getInventory().clear();
        player.getInventory().setHelmet(null);
        player.getInventory().setChestplate(null);
        player.getInventory().setLeggings(null);
        player.getInventory().setBoots(null);

        player.setSaturation(20.0F);
        player.setHealth(player.getMaxHealth());
        player.setExp(0.0F);
        player.setLevel(0);

        for(PotionEffect potionEffect : player.getActivePotionEffects())
            player.removePotionEffect(potionEffect.getType());
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:25,代码来源:InventoryUtils.java

示例3: giveKit

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void giveKit(final Player p) {
	Kit k = getKit(p);
	
	p.getInventory().clear();
	p.getInventory().setArmorContents(null);
	
	for (ItemStack i : k.getItems()) {
		int id = i.getType().getId();
		if ((id < 298) || (317 < id))
               p.getInventory().addItem(i);
        else if ((id == 298) || (id == 302)     || (id == 306) || (id == 310)   || (id == 314))
                p.getInventory().setHelmet(new ItemStack(id, 1));
        else if ((id == 299) || (id == 303)     || (id == 307) || (id == 311) || (id == 315))
                p.getInventory().setChestplate(new ItemStack(id, 1));
        else if ((id == 300) || (id == 304) || (id == 308) || (id == 312) || (id == 316))
                p.getInventory().setLeggings(new ItemStack(id, 1));
        else if ((id == 301) || (id == 305) || (id == 309) || (id == 313) || (id == 317))
                p.getInventory().setBoots(new ItemStack(id, 1));
	}
	p.getInventory().addItem(new ItemStack(Material.COMPASS));
	for (PotionEffect potion : p.getActivePotionEffects())
		p.removePotionEffect(potion.getType());
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:24,代码来源:Kit.java

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

示例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.BEETROOT)
	{
		int amp = 0;
		int dur = 200;
		for (PotionEffect effect : player.getActivePotionEffects())
		{
			if(effect.getType().equals(PotionEffectType.INCREASE_DAMAGE))
			{
				dur += effect.getDuration();
				if(dur > 600) dur = 600;
				player.removePotionEffect(effect.getType());
			}
		}
		player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, dur, amp));
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:22,代码来源:BeetrootStrength.java

示例6: restoreInventory

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void restoreInventory(Player player) {
	if (player != null) {
    	if (playerExists(player.getUniqueId().toString())) {
        	player.getInventory().clear();
			player.getInventory().setHelmet(null);
		    player.getInventory().setChestplate(null);
		    player.getInventory().setLeggings(null);
		    player.getInventory().setBoots(null);
for (PotionEffect effect : player.getActivePotionEffects()) {
       player.removePotionEffect(effect.getType());
}
        	player.getInventory().setContents(inventories.get(player.getUniqueId().toString()).getContent());
        	player.getInventory().setArmorContents(inventories.get(player.getUniqueId().toString()).getArmor());
        	player.setLevel(inventories.get(player.getUniqueId().toString()).getLevel());
        	player.setExp(inventories.get(player.getUniqueId().toString()).getExp());
        	player.setGameMode(inventories.get(player.getUniqueId().toString()).getGameMode());
        	inventories.remove(player.getUniqueId().toString());
    	}
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:21,代码来源:InventoryController.java

示例7: onAttack

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onAttack(EntityDamageByEntityEvent e) {
	if(!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) {
		return;
	}
	Player p = (Player) e.getEntity();
	Player attacker = (Player) e.getDamager();
	
	for(PotionEffect effect : attacker.getActivePotionEffects()) {
		if(effect.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
			e.setDamage(e.getDamage() - (3 * (effect.getAmplifier() + 1)));
		}
	}
	
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:16,代码来源:StrengthPatch.java

示例8: postLoad

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Runs after data has been loaded from SQL database
*/
@Override
public void postLoad(final Player p) {
    if (p != null && isValid()) {
        if (!PunishmentManager.ips_byUUID.containsKey(p.getUniqueId().toString())) {
            String ip = PunishmentManager.parseIP(p.getAddress());
            PunishmentManager.registerIP(p.getUniqueId(), ip);
        } else {
            knownIPs.add(PunishmentManager.ips_byUUID.get(p.getUniqueId().toString()));
        }
        dead = false;
        baseMaxHP = getBaseMaxHP();
        updateEquipmentStats();
        for (PotionEffect pe : p.getActivePotionEffects())
            p.removePotionEffect(pe.getType());
        manaRegenTask();
        hpDisplayAndRegenTask();
        specialEffectsTask();
        everySecondTask();
        equipEffectsTask();
        saveTask();
        statusEffectTask();
        updateHealthManaDisplay();
        RegionManager.checkRegion(p, this);
        checkBuycraft(true);
        p.getInventory().clear();
        p.setGameMode(loadedGamemode);
        for (Entry<Integer, ItemStack> e : loadedInventory.entrySet()) {
            p.getInventory().setItem(e.getKey(), e.getValue());
        }
        updateEquipmentStats();
        hp = loadedHP;
        p.teleport(loadedLocation);
        RMessages.sendTitle(p, " ", " ", 1, 1, 1);
        checkBuycraft(false); // not in lobby
        RegionManager.checkRegion(p, this);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:41,代码来源:PlayerDataRPG.java

示例9: unload

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void unload() {
    if (isStealthed())
        removeStealth();
    if (bossBar != null)
        bossBar.removeAll();
    bossBar = null;
    if (uuid != null) {
        ParticleManager.dispose(uuid);
        DungeonManager.dispose(uuid);
        MenuManager.clear(uuid);
        SchematicUserConfig cfg = SchematicManager.configs.remove(uuid);
        if (cfg != null) {
            cfg.history.clear();
            cfg.loadedSchematics.clear();
        }
    }
    if (name != null) {
        //            TeleportAcceptCommand.cleanup(name);
        WarpManager.cleanup(name);
        SakiShieldCore.clear(name);
    }
    Player p = getPlayer();
    if (p != null && p.isValid()) {
        for (PotionEffect pe : p.getActivePotionEffects())
            p.removePotionEffect(pe.getType());
    }
    super.unload();
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:30,代码来源:PlayerDataRPG.java

示例10: removeStealth

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void removeStealth() {
    if (!isStealthed())
        return;
    stealthCounter++;
    stealthed = false;
    Player p = getPlayer();
    if (p != null && p.isValid()) {
        StealthManager.removeStealth(p);
        for (PotionEffect pe : p.getActivePotionEffects())
            p.removePotionEffect(pe.getType());
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:13,代码来源:PlayerDataRPG.java

示例11: removeInvisibilitySafely

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void removeInvisibilitySafely(Player player) {
    for (PotionEffect active : player.getActivePotionEffects()) {
        if (active.getType().equals(PotionEffectType.INVISIBILITY) && active.getDuration() > DEFAULT_MAX_DURATION) {
            player.sendMessage(ChatColor.RED + getName() + ChatColor.GRAY + " invisibility removed.");
            player.removePotionEffect(active.getType());
            break;
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:MinerClass.java

示例12: resetPotions

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void resetPotions() {
    final Player bukkit = getBukkit();
    for(PotionEffect effect : bukkit.getActivePotionEffects()) {
        if(effect.getType() != null) {
            bukkit.removePotionEffect(effect.getType());
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:MatchPlayer.java

示例13: setRestoreEffect

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void setRestoreEffect(Player player, PotionEffect effect) {
    boolean shouldCancel = true;
    Collection<PotionEffect> activeList = player.getActivePotionEffects();
    for (PotionEffect active : activeList) {
        if (!active.getType().equals(effect.getType()))
            continue;

        // If the current potion effect has a higher amplifier, ignore this one.
        if (effect.getAmplifier() < active.getAmplifier()) {
            return;
        } else if (effect.getAmplifier() == active.getAmplifier()) {
            // If the current potion effect has a longer duration, ignore this one.
            if (effect.getDuration() < active.getDuration()) {
                return;
            }
        }

        restores.put(player.getUniqueId(), active.getType(), active);
        shouldCancel = false;
        break;
    }

    // Cancel the previous restore.
    player.addPotionEffect(effect, true);
    if (shouldCancel && effect.getDuration() > BardClass.HELD_EFFECT_DURATION_TICKS && effect.getDuration() < BardClass.DEFAULT_MAX_DURATION) {
        restores.remove(player.getUniqueId(), effect.getType());
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:29,代码来源:EffectRestorer.java

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

示例15: setSpectator

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void setSpectator(Player player, String prefix, Location spawn) {
    if (!PREFIXES.containsKey(player.getName()))
        PREFIXES.put(player.getName(), prefix);

    player.setFoodLevel(20);
    player.setLevel(0);
    player.setGameMode(GameMode.ADVENTURE);
    player.setAllowFlight(true);
    player.setPlayerListName(prefix + player.getDisplayName());
    player.setDisplayName(prefix + player.getDisplayName());
    player.setExp(0);
    player.setHealthScale(20);
    player.setHealth(20);
    player.setTotalExperience(0);
    player.setCanPickupItems(false);
    player.setCustomName(prefix + player.getDisplayName());
    player.setCustomNameVisible(true);
    for (PotionEffect eff : player.getActivePotionEffects()) {
        player.removePotionEffect(eff.getType());
    }
    player.teleport(spawn);

    for (Player p : Bukkit.getOnlinePlayers()) {
        p.hidePlayer(player);
    }

    PlayerUtil.addDeadPlayer(player);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:29,代码来源:Spectator.java


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