本文整理汇总了Java中org.bukkit.event.entity.FoodLevelChangeEvent.getEntityType方法的典型用法代码示例。如果您正苦于以下问题:Java FoodLevelChangeEvent.getEntityType方法的具体用法?Java FoodLevelChangeEvent.getEntityType怎么用?Java FoodLevelChangeEvent.getEntityType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.FoodLevelChangeEvent
的用法示例。
在下文中一共展示了FoodLevelChangeEvent.getEntityType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEat
import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
public void onEat(FoodLevelChangeEvent event)
{
if (event.getEntityType() == EntityType.PLAYER)
{
Player player = (Player)event.getEntity();
int foodLevelAdded = player.getFoodLevel() - event.getFoodLevel();
// Monitor added food level (food consumed) only
if (foodLevelAdded < 0)
{
MagicDataService magicDataService = MagicDataService.getInstance();
PlayerMagicData data = magicDataService.getMagicData(player.getName());
if (player.getFoodLevel() < MagicDataService.MAX_FOOD_LEVEL)
{
data.addFoodLevelsToRegen(foodLevelAdded);
}
else // Reached maximum, make sure it doesn't regenerate for any reason
{
data.setFoodLevelsToRegen(0);
data.setLastTimeRegenerated(0);
}
}
}
}
示例2: onPlayerHungerEvent
import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerHungerEvent(FoodLevelChangeEvent e) {
if (e.getEntityType() == EntityType.PLAYER) {
for (Minigame mg : Minigame.getMinigameInstances()) {
if (!mg.getConfigManager().isHungerEnabled() && mg.isPlayer((e.getEntity()).getName())) {
e.setCancelled(true);
}
}
}
}
示例3: onPlayerStarve
import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerStarve(final FoodLevelChangeEvent event) {
if (event.getEntityType() == EntityType.PLAYER) {
final Player p = (Player)event.getEntity();
event.setCancelled(p.getFoodLevel() > event.getFoodLevel() && this.feature.hasGodMode(p));
}
}
示例4: onFoodLevelChange
import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onFoodLevelChange(final FoodLevelChangeEvent event) {
if (event.getEntityType() == EntityType.PLAYER && this.loggedOutPlayers.containsKey(event.getEntity().getUniqueId())) {
event.setCancelled(true);
}
}