本文整理汇总了Java中cn.nukkit.event.player.PlayerFoodLevelChangeEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerFoodLevelChangeEvent类的具体用法?Java PlayerFoodLevelChangeEvent怎么用?Java PlayerFoodLevelChangeEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayerFoodLevelChangeEvent类属于cn.nukkit.event.player包,在下文中一共展示了PlayerFoodLevelChangeEvent类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例3: onFoodLevelChange
import cn.nukkit.event.player.PlayerFoodLevelChangeEvent; //导入依赖的package包/类
@EventHandler
public void onFoodLevelChange(PlayerFoodLevelChangeEvent event){
event.setFoodLevel(20);
event.setFoodSaturationLevel(20F);
}
示例4: onFoodLevelChange
import cn.nukkit.event.player.PlayerFoodLevelChangeEvent; //导入依赖的package包/类
@EventHandler
public void onFoodLevelChange(PlayerFoodLevelChangeEvent event){
if(!this.manager.isAuthenticated(event.getPlayer())){
event.setCancelled();
}
}