當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。