本文整理汇总了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);
}
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
示例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");
}
}
示例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);
}
}
}
示例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);
}
示例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;
}
}
}
示例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));
}