Java 类org.bukkit.event.entity.FoodLevelChangeEvent 实例源码

项目:world-of-icerealm    文件:MagicFoodLevelEvent.java   
@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);
            }
        }
    }
}
项目:SkywarsSeries    文件:FoodLevel.java   
@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);
                    }
                }
            }
        }
    }
}
项目:StaffPlus    文件:FoodLevelChange.java   
@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);
}
项目:BedwarsRel    文件:PlayerListener.java   
@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);
}
项目:acidisland    文件:PlayerEvents.java   
/**
 * Prevents changing of hunger while having a special permission and being on your island
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onHungerChange(final FoodLevelChangeEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName() + " food level = " + ((Player)e.getEntity()).getFoodLevel() + " new food level = " + e.getFoodLevel());

    }
    // Allow food increases
    if (e.getFoodLevel() - ((Player)e.getEntity()).getFoodLevel() > 0) {
        return;
    }
    if (e.getEntity().hasPermission(Settings.PERMPREFIX + "nohunger")) {
        if(plugin.getGrid().playerIsOnIsland((Player) e.getEntity())) {
            e.setCancelled(true);
        }
    }
}
项目:askyblock    文件:PlayerEvents.java   
/**
 * Prevents changing of hunger while having a special permission and being on your island
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onHungerChange(final FoodLevelChangeEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName() + " food level = " + ((Player)e.getEntity()).getFoodLevel() + " new food level = " + e.getFoodLevel());

    }
    // Allow food increases
    if (e.getFoodLevel() - ((Player)e.getEntity()).getFoodLevel() > 0) {
        return;
    }
    if (e.getEntity().hasPermission(Settings.PERMPREFIX + "nohunger")) {
        if(plugin.getGrid().playerIsOnIsland((Player) e.getEntity())) {
            e.setCancelled(true);
        }
    }
}
项目:TCMinigames    文件:PlayerListener.java   
@EventHandler
public void onFoodChange(FoodLevelChangeEvent event){
    if(Minigame.getCurrentMinigame()!=null){
        switch(Minigame.getCurrentMinigame().getMap().getType()){
        case CIRCLE_OF_BOOM:
            if(((CircleOfBoom)Minigame.getCurrentMinigame()).isCorrer()){
                ((Player) event.getEntity()).setFoodLevel(20);
            } else {
                ((Player) event.getEntity()).setFoodLevel(6);
            }
            event.setCancelled(true);
            break;
        case KEY_QUEST:
            break;
        case WATER_THE_MONUMENT:
            break;
        default:
            break;
        }
    }
}
项目:PV-Star    文件:PlayerEventListener.java   
@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);
    }
}
项目:WeaselsWalls    文件:FoodRegen.java   
@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);
                }
            }
        }
    }
}
项目:simple-survival-games    文件:SSGEntityListener.java   
@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);
        }
    }
}
项目:Warzone    文件:SpectatorModule.java   
@EventHandler
public void onHunger(FoodLevelChangeEvent event) {
    if (isSpectating((Player) event.getEntity())) {
        event.setCancelled(true);
        event.setFoodLevel(20);
    }
}
项目:ProjectAres    文件:HungerMatchModule.java   
@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);
    }
}
项目:KingdomFactions    文件:DropEventListener.java   
@EventHandler
   public void onFood(FoodLevelChangeEvent e) {
    KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer(e.getEntity());
    if(player != null) {
        if(player.getKingdom().getType() == KingdomType.GEEN) {
            e.setFoodLevel(20);
        }

    }
}
项目:SkyWarsReloaded    文件:SpectatorListener.java   
@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);
    }
}
项目:SkyWarsReloaded    文件:PlayerListener.java   
@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);
                 }
             }
         }
    }
}
项目:SkyWarsReloaded    文件:LobbyListener.java   
@EventHandler
public void onFoodChange(FoodLevelChangeEvent e) {
    Entity ent = e.getEntity();
    if(ent instanceof Player) {
        if (inLobbyWorld((Player) ent) && SkyWarsReloaded.getCfg().hungerDisabled()) {
            e.setCancelled(true);
        }
    }
}
项目:mczone    文件:GeneralEvents.java   
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
    event.setFoodLevel(20);
    Gamer g = Gamer.get(event.getEntity().getName());
    if (g.getVariable("arena") != null) {
        Arena a = (Arena) g.getVariable("arena");
        if (a.getState() == ArenaState.STARTED)
            return;
    }
    ((Player) event.getEntity()).setHealth(20);
}
项目:mczone    文件:Events.java   
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
    if (Scheduler.getState() != State.PVP) {
        event.setFoodLevel(20);
        event.setCancelled(true);
        return;
    }
}
项目:mczone    文件:GeneralEvents.java   
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
    event.setFoodLevel(20);
    Gamer g = Gamer.get(event.getEntity().getName());
    if (g.getVariable("arena") != null) {
        Arena a = (Arena) g.getVariable("arena");
        if (a.getState() == ArenaState.STARTED)
            return;
    }
    ((Player) event.getEntity()).setHealth(20);
}
项目:DynamicAC    文件:PlayerListener.java   
@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);
        }
    }
}
项目:HCFCore    文件:HungerFixListener.java   
@EventHandler
public void onHungerChange(FoodLevelChangeEvent e){
    if(e.getEntity() instanceof Player){
        Player p = (Player) e.getEntity();
            p.setSaturation(1000);
            p.setFoodLevel(20);

    }
}
项目:HCFCore    文件:HungerFixListener.java   
@EventHandler
public void onHungerChange(FoodLevelChangeEvent e){
    if(e.getEntity() instanceof Player){
        Player p = (Player) e.getEntity();
            p.setSaturation(1000);
            p.setFoodLevel(20);

    }
}
项目:ArchersBattle    文件:PlayerListener.java   
@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);
}
项目:Chambers    文件:GameDamageListener.java   
@EventHandler
public void onHunger(FoodLevelChangeEvent event) {
    Game game = Chambers.getInstance().getGameManager().getGame();
    if (game.getInvincibilityTime() > 0) {
        event.setCancelled(true);
    }
}
项目:Chambers    文件:GameProtectionListener.java   
@EventHandler
public void onHunger(FoodLevelChangeEvent event) {
    Game game = Chambers.getInstance().getGameManager().getGame();
    if (!game.hasStarted()) {
        event.setCancelled(true);
    }
}
项目:ZorahPractice    文件:PlayerListener.java   
@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);
}
项目:BiteSkywars    文件:PlayerListener.java   
@EventHandler
public void FoodLevel(FoodLevelChangeEvent event){
    Entity p = event.getEntity();
    if(!(p instanceof Player)){
        return;
    }
    Player p1 = (Player)p;
    Arena a = new ArenaManager().getArena(p1);

    if(a==null||!a.isGame()){
        event.setCancelled(true);
    }

}
项目:AthenaGM    文件:HubListener.java   
/**
 * Stop hunger depletion on the Hub
 */
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
    if (event.getEntity() instanceof Player && hub.hasPlayer((Player)event.getEntity())) {
        event.setCancelled(true);
    }
}
项目:Skript    文件:ExprFoodLevel.java   
@Override
protected Float[] get(final Event e, final Player[] source) {
    return get(source, new Getter<Float, Player>() {
        @Override
        public Float get(final Player p) {
            if (getTime() >= 0 && e instanceof FoodLevelChangeEvent && p.equals(((FoodLevelChangeEvent) e).getEntity()) && !Delay.isDelayed(e)) {
                return 0.5f * ((FoodLevelChangeEvent) e).getFoodLevel();
            } else {
                return 0.5f * p.getFoodLevel();
            }
        }
    });
}
项目:MinigameManager    文件:MinigameListener.java   
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
    HumanEntity entity = event.getEntity();
    if (entity instanceof Player) {
        Player player = (Player) entity;
        Rotation rotation = manager.getRotationManager().getRotation(player);
        if (rotation != null && rotation.getState() == RotationState.INGAME) {
            MinigameAttributes attr = rotation.getCurrentMinigame().getAttributes();
            if (attr.alwaysSaturated())
                event.setCancelled(true);
        } else if (!manager.getMinigameSettings().lobbyHunger() && rotation != null && rotation.getState() != RotationState.INGAME)
            event.setCancelled(true);
    }
}
项目:world-of-icerealm    文件:ExplorerPerk.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerFoodLevelChange(FoodLevelChangeEvent evt) {

    if (evt.getEntity() instanceof Player) {
        Player player = (Player)evt.getEntity();

        if (perkService.playerHasPerk(player, SurvivorTree.ExplorerId)) {

            if (player.getFoodLevel() > evt.getFoodLevel() && new Random(Calendar.getInstance().getTimeInMillis()).nextInt(2) == 1) {
                evt.setCancelled(true);
            }
        }
    }
}
项目:BeeLogin    文件:EventCanceler.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onFoodLevelChange(FoodLevelChangeEvent evt) {
    if (!usingBeeLoginMod)
        return;
    HumanEntity EPlayer = evt.getEntity();
    if (EPlayer instanceof Player) {
        Player player = (Player) EPlayer;
        if (!loginStatus.get(player.getName().toLowerCase())) {
            evt.setCancelled(true);
        }
    }
}
项目:AnnihilationPro    文件:Areas.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.LOW)
public void checkFood(FoodLevelChangeEvent event)
{
    Area a = getArea(new Loc(event.getEntity().getLocation(),false));
    if(a != null && !a.getAllowHunger())
    {
        event.setFoodLevel(20);
        //event.setCancelled(true);
    }
}
项目:BiteSkywars    文件:PlayerListener.java   
@EventHandler
public void FoodLevel(FoodLevelChangeEvent event){
    Entity p = event.getEntity();
    if(!(p instanceof Player)){
        return;
    }
    Player p1 = (Player)p;
    Arena a = new ArenaManager().getArena(p1);

    if(a==null||!a.isGame()){
        event.setCancelled(true);
    }

}
项目:RageMode    文件:EventListener.java   
@EventHandler
public void onHungerGain(FoodLevelChangeEvent event) {
    if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        if (PlayerList.isPlayerPlaying(player.getUniqueId().toString())) {
            event.setCancelled(true);
        }
    }
}
项目:SuperVanish    文件:GeneralEventHandler.java   
@EventHandler(priority = EventPriority.HIGH)
public void onFoodLevelChange(FoodLevelChangeEvent e) {
    try {
        if (e.getEntity() instanceof Player && config.getBoolean("InvisibilityFeatures.DisableHunger")) {
            Player p = (Player) e.getEntity();
            if (plugin.getVanishStateMgr().isVanished(p.getUniqueId())
                    && e.getFoodLevel() <= p.getFoodLevel())
                e.setCancelled(true);
        }
    } catch (Exception er) {
        plugin.logException(er);
    }
}
项目:buildinggame    文件:LoseFood.java   
/**
    * Handles players losing food in the lobby
    *
    * @param e an event representing a player losing food
    * @see FoodLevelChangeEvent
    * @since 2.1.0
    */
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent e) {
       HumanEntity entity = e.getEntity();

       if (!(entity instanceof Player) || ArenaManager.getInstance().getArena((Player) entity) == null)
        return;

    e.setCancelled(true);
}
项目:RedProtect    文件:RPPlayerListener.java   
@EventHandler
public void onHunger(FoodLevelChangeEvent e){
    if (!(e.getEntity() instanceof Player)){
        return;
    }

    Player p = (Player) e.getEntity();
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (r != null && !r.canHunger()){
        e.setCancelled(true);
    }
   }
项目:MyiuLib    文件:MGListener.java   
@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);
            }
        }
    }
}
项目:BlockParty-1.8    文件:FeedListener.java   
@EventHandler
public void onFeed(FoodLevelChangeEvent e) {
    if (BlockParty.onFloorPlayers.containsKey(e.getEntity().getName())) {
        e.setFoodLevel(20);
    }
    if (BlockParty.inLobbyPlayers.containsKey(e.getEntity().getName())) {
        e.setFoodLevel(20);
    }
}