當前位置: 首頁>>代碼示例>>Java>>正文


Java FoodLevelChangeEvent.setCancelled方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.FoodLevelChangeEvent.setCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java FoodLevelChangeEvent.setCancelled方法的具體用法?Java FoodLevelChangeEvent.setCancelled怎麽用?Java FoodLevelChangeEvent.setCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.FoodLevelChangeEvent的用法示例。


在下文中一共展示了FoodLevelChangeEvent.setCancelled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: onHungerChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
/**
 * 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);
        }
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:21,代碼來源:PlayerEvents.java

示例5: onFoodChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@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;
		}
	}
}
 
開發者ID:tatanpoker09,項目名稱:TCMinigames,代碼行數:22,代碼來源:PlayerListener.java

示例6: 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

示例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: onHunger

import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onHunger(FoodLevelChangeEvent event) {
    if (isSpectating((Player) event.getEntity())) {
        event.setCancelled(true);
        event.setFoodLevel(20);
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:8,代碼來源:SpectatorModule.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: 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

示例12: onFoodLevelChange

import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
	if (Scheduler.getState() != State.PVP) {
		event.setFoodLevel(20);
		event.setCancelled(true);
		return;
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:9,代碼來源:Events.java

示例13: onHunger

import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onHunger(FoodLevelChangeEvent event) {
	Game game = Chambers.getInstance().getGameManager().getGame();
	if (game.getInvincibilityTime() > 0) {
		event.setCancelled(true);
	}
}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:8,代碼來源:GameDamageListener.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: FoodLevel

import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@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);
	}

}
 
開發者ID:SpikyBite,項目名稱:BiteSkywars,代碼行數:15,代碼來源:PlayerListener.java


注:本文中的org.bukkit.event.entity.FoodLevelChangeEvent.setCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。