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


Java Player.getFoodLevel方法代码示例

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


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

示例1: call

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof EntityDamageEvent) {
		final EntityDamageEvent ede = (EntityDamageEvent) event;
		final DamageCause cause = ede.getCause();

		if (cause == DamageCause.FIRE || cause == DamageCause.CONTACT) {
			final Player player = profile.getPlayer();

			if (cause == DamageCause.FIRE && player.getFoodLevel() < 20) {
				// The AntiFire cheat only works when the hunger bar is
				// full.
				return;
			}

			final double previousHealth = player.getHealth();

			// Check a little later.
			Bukkit.getScheduler().runTaskLater(Crescent.getInstance(), () -> {
				if (player.getHealth() > previousHealth - ede.getDamage()) {
					callback(true);
				}
			}, 2L);
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:27,代码来源:AntiDamageA.java

示例2: onConsumeCake

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsumeCake(PlayerInteractEvent event)
{
	if(event.isCancelled()) return;
	Player player = event.getPlayer();
	if(event.hasBlock() && event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
	{
		Block cake = event.getClickedBlock();
		if(cake.getType().equals(Material.CAKE_BLOCK))
		{
			if(player.getFoodLevel() < 20 && (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE))
			{
				addStats(player, carbon, 171);
				addStats(player, protein, 114);
				addStats(player, salts, 3);
			}
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:20,代码来源:FoodDiversityConsume.java

示例3: ShowHunger

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static List<String> ShowHunger(Player player)
{
	int hunger = player.getFoodLevel();
	int saturation = (int)Math.round(player.getSaturation());
	String hungerBar = "";
	String saturationBar = ChatColor.YELLOW + "";
	for(int i = 0; i < hunger; i++)
	{
		hungerBar += "|";
	}
	for(int i = hunger; i < 20; i++)
	{
		hungerBar += ".";
	}
	for(int i = 0; i < saturation; i++)
	{
		saturationBar += "|";
	}
	
	if(hunger >= 20)
		hungerBar = ChatColor.GREEN + hungerBar;
	else if(hunger <= 6)
		hungerBar = ChatColor.RED + hungerBar;
	else
		hungerBar = ChatColor.GOLD + hungerBar;
	
	return Arrays.asList(ChatColor.GOLD + Words.get("Hunger"), hungerBar + ChatColor.RESET, saturationBar);
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:29,代码来源:Survival.java

示例4: storeTemporaryInventory

import org.bukkit.entity.Player; //导入方法依赖的package包/类
void storeTemporaryInventory(Player player) {
    final TemporaryPlayerStorage storage = new TemporaryPlayerStorage();
    storage.armorContent = player.getInventory().getArmorContents().clone();
    storage.isFlying = player.getAllowFlight();
    storage.inventory = player.getInventory().getContents().clone();
    storage.gameMode = player.getGameMode();
    storage.level = player.getLevel();
    storage.exp = player.getExp();
    storage.health = player.getHealth();
    storage.foodLevel = player.getFoodLevel();
    storage.scoreboard = player.getScoreboard();
    this.temporaryStorage.put(player, storage);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:14,代码来源:HelperGameEntity.java

示例5: checkSprintHungry

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void checkSprintHungry(PlayerToggleSprintEvent e) {
    Player player = e.getPlayer();
    if(e.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= 6) {
        for(Player pla : DynamicAC.instance.onlinestaff) {
            pla.sendMessage(DynamicAC.prefix + player.getName() + " sprinted while under 3 food thingies!");
        }
        DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()), "Sprinted while hungry");
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:10,代码来源:BackendChecks.java

示例6: onEntityEat

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
@SuppressWarnings("unused")
public void onEntityEat(FoodLevelChangeEvent e) {
    if (e.getEntity() instanceof Player) {
        Player player = (Player) e.getEntity();
        if (player.getFoodLevel() < e.getFoodLevel()) {
            DACManager.getBackend().checkFastEat(player);
        }
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:11,代码来源:PlayerListener.java

示例7: onItemClick

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onItemClick(PlayerInteractEvent event)
{
	Player player = event.getPlayer();
	ItemStack mainItem = player.getInventory().getItemInMainHand();
	
	Score score_dualWieldMsg = tech_dualWieldMsg.getScore(player);
	
	if(mainItem.getType() == Material.GOLD_AXE)
	{
		if(dualWield.getScore(player).getScore() == 0)
		{
			if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR)
			{
				if(spin.getScore(player).getScore() == 0)
				{
					if(player.getFoodLevel() > 6)
					{
						Random rand = new Random();
						
						Spin(player);
						
						if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
							player.setFoodLevel(player.getFoodLevel() - 1);
						
						int chance_reduceDur = rand.nextInt(10) + 1;
						switch(chance_reduceDur)
						{
							case 1:
								mainItem.setDurability((short)(mainItem.getDurability() + 1));
								break;
							default:
						}
						
						if(mainItem.getDurability() >= 32)
						{
							player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
							player.getInventory().setItemInMainHand(null);
						}
						player.updateInventory();
					}
					else
					{
						player.sendMessage(ChatColor.RED + Survival.Words.get("Lack of energy, unable to spin"));
					}
				}
			}
		}
		else 
		{
			if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
				score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 1);
			else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
				score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 2);
			if(score_dualWieldMsg.getScore() == 2)
			{
				player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to dual-wield with Valkyrie's Axe"));
			}
		}
	}
	score_dualWieldMsg.setScore(0);
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:64,代码来源:Valkyrie.java

示例8: onAttack

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getDamager() instanceof Player)
	{
		Player player = (Player)event.getDamager();
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		
		if(dualWield.getScore(player).getScore() == 0)
		{
			if(mainItem.getType() == Material.GOLD_AXE)
			{
				if(spin.getScore(player).getScore() == 0)
				{
					if(player.getFoodLevel() > 6)
					{
						Random rand = new Random();
						
						Spin(player);
						
						if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
							player.setFoodLevel(player.getFoodLevel() - 1);
						
						int chance_reduceDur = rand.nextInt(10) + 1;
						switch(chance_reduceDur)
						{
							case 1:
								mainItem.setDurability((short)(mainItem.getDurability() + 1));
								break;
							default:
						}
						
						if(mainItem.getDurability() >= 32)
						{
							player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
							player.getInventory().setItemInMainHand(null);
						}
						player.updateInventory();
					}
					else
					{
						player.sendMessage(ChatColor.RED + Survival.Words.get("Lack of energy, unable to spin"));
					}
				}
			}
		}
		else
		{
			event.setCancelled(true);
			return;
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:56,代码来源:Valkyrie.java

示例9: getCachedInventory

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static CachedInventory getCachedInventory(Player player, boolean dead) {
    List<String> effects = new ArrayList<>();
    player.getActivePotionEffects().forEach(effect -> effects.add(effect.getType().getName() + " " + effect.getAmplifier() + " (" + TimeUtil.formatSeconds(effect.getDuration() / 20) + ")"));
    return new CachedInventory(player.getName(), (dead ? 0.0 : Math.round(player.getHealth())), player.getFoodLevel(), effects, InventoryUtils.playerInventoryFromPlayer(player));
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:6,代码来源:Cache.java


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