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


Java Player.setSaturation方法代码示例

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


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

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

示例2: reset

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void reset() {
    final Player bukkit = getBukkit();
    bukkit.closeInventory();
    clearInventory();
    bukkit.setExhaustion(0);
    bukkit.setFallDistance(0);
    bukkit.setFireTicks(0);
    bukkit.setFoodLevel(20); // full
    bukkit.setMaxHealth(20);
    bukkit.setHealth(bukkit.getMaxHealth());
    bukkit.setAbsorption(0);
    bukkit.setLevel(0);
    bukkit.setExp(0); // clear xp
    bukkit.setSaturation(5); // default
    bukkit.setFastNaturalRegeneration(false);
    bukkit.setSlowNaturalRegeneration(true);
    bukkit.setAllowFlight(false);
    bukkit.setFlying(false);
    bukkit.setSneaking(false);
    bukkit.setSprinting(false);
    bukkit.setFlySpeed(0.1f);
    bukkit.setKnockbackReduction(0);
    bukkit.setWalkSpeed(WalkSpeedKit.BUKKIT_DEFAULT);
    AttributeUtils.removeAllModifiers(bukkit);
    resetPotions();

    // we only reset bed spawn here so people don't have to see annoying messages when they respawn
    bukkit.setBedSpawnLocation(null);

    match.callEvent(new PlayerResetEvent(this));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:32,代码来源:MatchPlayer.java

示例3: handleLogin

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void handleLogin(Player p)
{
    super.handleLogin(p);
    p.setGameMode(GameMode.ADVENTURE);
    p.setLevel(0);
    p.setExp(0);
    p.setFoodLevel(20);
    p.setSaturation(20);

    Location spec = new Location(AgarMC.get().getWorld(), origin.getX() + dimensions / 2, origin.getY() + 20, origin.getZ() + dimensions / 2);
    spec.setPitch(90);
    p.teleport(spec);
    p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
    if (gamePlayers.size() >= SamaGamesAPI.get().getGameManager().getGameProperties().getMaxSlots())
        this.status = Status.IN_GAME;
    Titles.sendTabTitle(p, ChatColor.GREEN + "Bienvenue sur " + ChatColor.AQUA + "SamaGames" + ChatColor.GREEN + " !\n",
            ChatColor.AQUA + "\nTeamSpeak : " + ChatColor.GREEN + "ts.samagames.net");
}
 
开发者ID:SamaGames,项目名称:AgarMC,代码行数:20,代码来源:AgarGame.java

示例4: reset

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void reset(Player player, boolean heal) {
    if (heal) player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
    player.setFoodLevel(20);
    player.setSaturation(20);
    player.getInventory().clear();
    player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)});
    player.setItemOnCursor(new ItemStack(Material.AIR));

    player.getActivePotionEffects().forEach(potionEffect -> {
        try {
            player.removePotionEffect(potionEffect.getType());
        } catch (NullPointerException ignored) {}
    });

    player.setFireTicks(0);
    player.setFallDistance(0);
    player.setTotalExperience(0);
    player.setExp(0);
    player.setLevel(0);
    player.setWalkSpeed(0.2F);
    player.setFlySpeed(0.1F);

    player.setSneaking(false);
    player.setInvulnerable(false);
    player.setCanPickupItems(true);
    player.setCollidable(true);
    player.setFlying(false);
    player.setAllowFlight(false);

    player.resetTitle();

    for (Attribute attribute : Attribute.values()) {
        if (player.getAttribute(attribute) == null) continue;
        for (AttributeModifier modifier : player.getAttribute(attribute).getModifiers()) {
            player.getAttribute(attribute).removeModifier(modifier);
        }
    }
    player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).addModifier(new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 24.000D, AttributeModifier.Operation.ADD_SCALAR));

    player.updateInventory();
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:42,代码来源:Players.java

示例5: onPlayerJoin

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Should be executed when the player joins the server.
 */
protected void onPlayerJoin() {
	// Resets
	Player player = getPlayer();
	player.setLevel(0);
	player.setExp(0);
	player.setFoodLevel(20);
	player.setSaturation(20);
	player.setHealth(20);
	
	// TODO coherence
	getPlayer().sendMessage(ChatColor.GOLD + "Bienvenue en Apsorbtion !");
}
 
开发者ID:SamaGames,项目名称:Absorption,代码行数:16,代码来源:GamePlayer.java

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

示例7: onHungerChange

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onHungerChange(FoodLevelChangeEvent e){
    if(e.getEntity() instanceof Player){
        Player p = (Player) e.getEntity();
            p.setSaturation(1000);
            p.setFoodLevel(20);

    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:HungerFixListener.java

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