本文整理汇总了Java中cn.nukkit.event.player.PlayerEatFoodEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerEatFoodEvent类的具体用法?Java PlayerEatFoodEvent怎么用?Java PlayerEatFoodEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayerEatFoodEvent类属于cn.nukkit.event.player包,在下文中一共展示了PlayerEatFoodEvent类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerEatFood
import cn.nukkit.event.player.PlayerEatFoodEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerEatFood(PlayerEatFoodEvent event) {
Player player = event.getPlayer();
Double become = Double.valueOf(
((Double) this.hunger.get(player)).doubleValue() + (double) (event.getFood().getRestoreFood() * 100));
if (become.doubleValue() > 2000.0D) {
become = Double.valueOf(2000.0D);
}
this.hunger.put(player, become);
}
示例2: eatenBy
import cn.nukkit.event.player.PlayerEatFoodEvent; //导入依赖的package包/类
public final boolean eatenBy(Player player) {
PlayerEatFoodEvent event = new PlayerEatFoodEvent(player, this);
player.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) return false;
return event.getFood().onEatenBy(player);
}