本文整理匯總了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);
}
}