当前位置: 首页>>代码示例>>Java>>正文


Java FoodLevelChangeEvent.getEntityType方法代码示例

本文整理汇总了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);
			}
		}
	}
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:27,代码来源:MagicFoodLevelEvent.java

示例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);
			}
		}
	}
}
 
开发者ID:myiume,项目名称:MyiuLib,代码行数:11,代码来源:MGListener.java

示例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));
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:8,代码来源:GodModeListener.java

示例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);
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:7,代码来源:LoggedOutUserHandler.java


注:本文中的org.bukkit.event.entity.FoodLevelChangeEvent.getEntityType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。