當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。