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


Java FoodLevelChangeEvent.getEntity方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.FoodLevelChangeEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java FoodLevelChangeEvent.getEntity方法的具体用法?Java FoodLevelChangeEvent.getEntity怎么用?Java FoodLevelChangeEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.FoodLevelChangeEvent的用法示例。


在下文中一共展示了FoodLevelChangeEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onFoodLevelChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
    if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();

        Game game = Skywars.getInstance().getGame(player);
        if (game != null && game.getGamePlayer(player) != null) {
            GamePlayer gamePlayer = game.getGamePlayer(player);

            if (!(game.isState(Game.GameState.ACTIVE) || game.isState(Game.GameState.DEATHMATCH))) {
                if (gamePlayer.isTeamClass()) {
                    if (gamePlayer.getTeam().isPlayer(player)) {
                        event.setFoodLevel(25);
                        event.setCancelled(true);
                    }
                } else {
                    if (gamePlayer.getPlayer() == player) {
                        event.setFoodLevel(25);
                        event.setCancelled(true);
                    }
                }
            }
        }
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:26,代码来源:FoodLevel.java

示例3: onPlace

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlace(FoodLevelChangeEvent event)
{
	Entity entity = event.getEntity();
	
	if(!(entity instanceof Player))
	{
		return;
	}
	
	if(options.modeHungerLoss || !modeCoordinator.isInMode(((Player) entity).getUniqueId()))
	{
		return;
	}
	
	event.setCancelled(true);
}
 
开发者ID:Shortninja66,项目名称:StaffPlus,代码行数:18,代码来源:FoodLevelChange.java

示例4: onHunger

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onHunger(FoodLevelChangeEvent flce) {
  if (!(flce.getEntity() instanceof Player)) {
    return;
  }

  Player player = (Player) flce.getEntity();
  Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);

  if (game == null) {
    return;
  }

  if (game.getState() == GameState.RUNNING) {
    if (game.isSpectator(player) || game.getCycle().isEndGameRunning()) {
      flce.setCancelled(true);
      return;
    }

    flce.setCancelled(false);
    return;
  }

  flce.setCancelled(true);
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:26,代码来源:PlayerListener.java

示例5: onPlayerHunger

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
private void onPlayerHunger(FoodLevelChangeEvent event) {

    if (!(event.getEntity() instanceof Player))
        return;

    Player p = (Player)event.getEntity();
    IArenaPlayer player = ArenaPlayer.get(p);
    if (player == null)
        return;

    IArena arena = player.getArena();
    if (arena == null)
        return;

    // get settings
    IContextSettings settings = player.getContextSettings();
    if (settings == null)
        return;

    // prevent hunger
    if (!settings.isHungerEnabled()) {
        event.setFoodLevel(20);
        event.setCancelled(true);
    }
}
 
开发者ID:JCThePants,项目名称:PV-Star,代码行数:27,代码来源:PlayerEventListener.java

示例6: onFoodRegen

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGH)
public void onFoodRegen(FoodLevelChangeEvent e){
	if(e.getEntity() instanceof Player){
		Player p = (Player) e.getEntity();
		
		Game g = GameManager.getInstance().getGame(p);
		
		if(g != null){
			if(g.gs == GameStage.Lobby || g.gs == GameStage.Build){
				if(e.getFoodLevel() != 20){
					e.setFoodLevel(20);
				}
			}
		}
	}
}
 
开发者ID:WeaselBuilds,项目名称:WeaselsWalls,代码行数:17,代码来源:FoodRegen.java

示例7: onFoodLevelChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
	Entity e = event.getEntity();
	ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
	
	// Is the entity a player
	if(e instanceof Player) {
		Player p = (Player) e;
		
		// Is the current in any arean
		if(am.isInArena(p)) {
			ArenaPlayer ap = am.getPlayer(p);
			
			// The food level of the player may not be changed when he's in the lobby or when he's a spectator
			if(ap.isInLobby() || ap.isSpectator())
				event.setCancelled(true);
		}
	}
}
 
开发者ID:timvisee,项目名称:simple-survival-games,代码行数:20,代码来源:SSGEntityListener.java

示例8: handleHungerChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void handleHungerChange(final FoodLevelChangeEvent event) {
    if(event.getEntity() instanceof Player) {
        int oldFoodLevel = ((Player) event.getEntity()).getFoodLevel();
        event.setFoodLevel(oldFoodLevel);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:HungerMatchModule.java

示例9: onFoodLevelChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
protected void onFoodLevelChange(FoodLevelChangeEvent e) {
	if (e.getEntity() instanceof Player && !e.getEntity().hasMetadata("NPC") && SkyWarsReloaded.getPC().getPlayer(((Player) e.getEntity()).getUniqueId()).isSpectating()) {
		e.setCancelled(true);
		((Player) e.getEntity()).setFoodLevel(20);
		((Player) e.getEntity()).setSaturation(20);
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:9,代码来源:SpectatorListener.java

示例10: onFoodChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
public void onFoodChange(FoodLevelChangeEvent e) {
	 Entity ent = e.getEntity();
	if(ent instanceof Player) {
		 GamePlayer hungry = SkyWarsReloaded.getPC().getPlayer(((Player) ent).getUniqueId());
		 if (hungry.inGame()) {
			 Game game = hungry.getGame();
			 if (game != null) {
				 if (game.getState() == GameState.PREGAME) {
					 e.setCancelled(true);
				 }
			 }
		 }
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:16,代码来源:PlayerListener.java

示例11: onFoodChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
public void onFoodChange(FoodLevelChangeEvent e) {
	Entity ent = e.getEntity();
	if(ent instanceof Player) {
		if (inLobbyWorld((Player) ent) && SkyWarsReloaded.getCfg().hungerDisabled()) {
			e.setCancelled(true);
		}
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:10,代码来源:LobbyListener.java

示例12: onEntityEat

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
@SuppressWarnings("unused")
public void onEntityEat(FoodLevelChangeEvent e) {
    if (e.getEntity() instanceof Player) {
        Player player = (Player) e.getEntity();
        if (player.getFoodLevel() < e.getFoodLevel()) {
            DACManager.getBackend().checkFastEat(player);
        }
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:11,代码来源:PlayerListener.java

示例13: onHungerChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
public void onHungerChange(FoodLevelChangeEvent e){
    if(e.getEntity() instanceof Player){
        Player p = (Player) e.getEntity();
            p.setSaturation(1000);
            p.setFoodLevel(20);

    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:HungerFixListener.java

示例14: onFoodChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
public void onFoodChange(FoodLevelChangeEvent e) {
    if (!(e.getEntity() instanceof Player)) {
        return;
    }
    Player p = (Player) e.getEntity();
    if (!Utils.isInArena(p)) {
        return;
    }
    e.setCancelled(true);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:12,代码来源:PlayerListener.java

示例15: onHunger

import org.bukkit.event.entity.FoodLevelChangeEvent; //导入方法依赖的package包/类
@EventHandler
public void onHunger(FoodLevelChangeEvent event) {
    if (!(event.getEntity() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getEntity();
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() == PlayerStatus.PLAYING) {
        return;
    }

    event.setCancelled(true);
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:16,代码来源:PlayerListener.java


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