本文整理汇总了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();
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:32,代码来源:PlayerFood.java
示例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;
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:12,代码来源:PlayerFood.java
示例3: onFoodLevelChange
import cn.nukkit.event.player.PlayerFoodLevelChangeEvent; //导入依赖的package包/类
@EventHandler
public void onFoodLevelChange(PlayerFoodLevelChangeEvent event){
event.setFoodLevel(20);
event.setFoodSaturationLevel(20F);
}
开发者ID:onebone,项目名称:MineCombat-Nukkit,代码行数:6,代码来源:MineCombat.java
示例4: onFoodLevelChange
import cn.nukkit.event.player.PlayerFoodLevelChangeEvent; //导入依赖的package包/类
@EventHandler
public void onFoodLevelChange(PlayerFoodLevelChangeEvent event){
if(!this.manager.isAuthenticated(event.getPlayer())){
event.setCancelled();
}
}
开发者ID:onebone,项目名称:GateKeeper,代码行数:7,代码来源:GateKeeper.java
注:本文中的cn.nukkit.event.player.PlayerFoodLevelChangeEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论