本文整理汇总了Java中cn.nukkit.event.player.PlayerFoodLevelChangeEvent.getFoodSaturationLevel方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerFoodLevelChangeEvent.getFoodSaturationLevel方法的具体用法?Java PlayerFoodLevelChangeEvent.getFoodSaturationLevel怎么用?Java PlayerFoodLevelChangeEvent.getFoodSaturationLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.event.player.PlayerFoodLevelChangeEvent
的用法示例。
在下文中一共展示了PlayerFoodLevelChangeEvent.getFoodSaturationLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLevel
import cn.nukkit.event.player.PlayerFoodLevelChangeEvent; //导入方法依赖的package包/类
public void setLevel(int foodLevel, float saturationLevel) {
if (foodLevel > 20) {
foodLevel = 20;
}
if (foodLevel < 0) {
foodLevel = 0;
}
if (foodLevel <= 6 && !(this.getLevel() <= 6)) {
if (this.getPlayer().isSprinting()) {
this.getPlayer().setSprinting(false);
}
}
PlayerFoodLevelChangeEvent ev = new PlayerFoodLevelChangeEvent(this.getPlayer(), foodLevel, saturationLevel);
this.getPlayer().getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
this.sendFoodLevel(this.getLevel());
return;
}
int foodLevel0 = ev.getFoodLevel();
float fsl = ev.getFoodSaturationLevel();
this.foodLevel = foodLevel;
if (fsl != -1) {
if (fsl > foodLevel) fsl = foodLevel;
this.foodSaturationLevel = fsl;
}
this.foodLevel = foodLevel0;
this.sendFoodLevel();
}
示例2: setFoodSaturationLevel
import cn.nukkit.event.player.PlayerFoodLevelChangeEvent; //导入方法依赖的package包/类
public void setFoodSaturationLevel(float fsl) {
if (fsl > this.getLevel()) fsl = this.getLevel();
if (fsl < 0) fsl = 0;
PlayerFoodLevelChangeEvent ev = new PlayerFoodLevelChangeEvent(this.getPlayer(), this.getLevel(), fsl);
this.getPlayer().getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
return;
}
fsl = ev.getFoodSaturationLevel();
this.foodSaturationLevel = fsl;
}