gt: 		if (getSettings().TIME_SETUP.getValue() > 0)
context: package com.deaboy.manhunt.game;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Random;
  
  import org.bukkit.ChatColor;
  import org.bukkit.GameMode;
  import org.bukkit.World.Environment;
  import org.bukkit.entity.Player;
  
  import com.deaboy.manhunt.Manhunt;
  import com.deaboy.manhunt.ManhuntUtil;
  import com.deaboy.manhunt.chat.ChatManager;
  import com.deaboy.manhunt.lobby.GameLobby;
  import com.deaboy.manhunt.lobby.Team;
  import com.deaboy.manhunt.map.SpawnType;
  import com.deaboy.manhunt.settings.ManhuntGameSettings;
  import com.deaboy.manhunt.timeline.*;
  
  public class ManhuntGame extends Game
  {
  	//////////////// PROPERTIES ////////////////
  	private Timeline timeline;
  	private ManhuntGameSettings settings;
  	private GameEventListener listener;
  	private long end_time;
  	
  	private static final long pregame_ticks = 320L; 
  	
  	//////////////// CONSTRUCTORS ////////////////
  	public ManhuntGame(GameLobby lobby)
  	{
  		super(lobby);
  		this.settings = new ManhuntGameSettings();
  		this.listener = new ManhuntGameListener(this);
  	}
  	
  	
  	//////////////// PUBLIC METHODS ////////////////
  	//---------------- Game Methods ----------------//
  	@Override
  	public void startGame()
  	{
  		this.setMap(getLobby().getCurrentMap());
  		setStage(GameStage.PREGAME);
  		// Initiate timeline
  		
  		timeline = generateTimeline();
  		end_time = 0L;
  		
  		if (getWorld().getEnvironment() == Environment.NORMAL)
  		{
  			end_time = 12000 - getSettings().TIME_SETUP.getValue() * 1200 - 320;
  			ManhuntUtil.transitionWorldTime(getWorld(), end_time, new Runnable()
  			{
  				public void run()
  				{
  					timeline.run();
  				}
  			});
  		}
  		else
  		{
  			timeline.run();
  		}
  		
  		end_time += pregame_ticks;
  		end_time += getSettings().TIME_SETUP.getValue() * 60 * 20;
  		end_time += getSettings().TIME_LIMIT.getValue() * 60 * 20;
  		
  		listener.startListening();
  	}
  	@Override
  	public void endGame()
  	{
  		if (!isRunning())
  			return;
  		
  		int hunters = getLobby().getPlayerNames(Team.HUNTERS).size();
  		int prey = getLobby().getPlayerNames(Team.PREY).size();
  		
  		getLobby().broadcast(ChatManager.bracket1_ + "The Game is OVER!" + ChatManager.bracket2_);
  		// Neither team won.
  		if (hunters == 0 && prey == 0)
  		{
  			getLobby().broadcast(ChatManager.leftborder + "Both teams died!");
  			getLobby().broadcast(ChatManager.leftborder + ChatColor.RED + "You all FAIL! Booooo!");
  		}
  		// The hunters won
  		else if (prey == 0)
  		{
  			getLobby().broadcast(ChatManager.leftborder + "The " + Team.PREY.getColor() + Team.PREY.getName(true) + ChatManager.color + " have all died!");
  			getLobby().broadcast(ChatManager.leftborder + Team.HUNTERS.getColor() + "The " + Team.HUNTERS.getName(true) + " have won the game!");
  		}
  		// The prey won
  		else if (hunters == 0)
  		{
  			getLobby().broadcast(ChatManager.leftborder + "The " + Team.HUNTERS.getColor() + Team.HUNTERS.getName(true) + ChatManager.color + " are all dead!");
  			getLobby().broadcast(ChatManager.leftborder + Team.PREY.getColor() + "The " + Team.PREY.getName(true) + " have won the game!");
  		}
  		// The prey won from time limit
  		else
  		{
  			getLobby().broadcast(ChatManager.leftborder + "The time limit has been reached!");
  			getLobby().broadcast(ChatManager.leftborder + Team.PREY.getColor() + "The " + Team.PREY.getName(true) + " have won the game!");
  		}
  		
  		stopGame();
  	}
  	@Override
  	public void cancelGame()
  	{
  		if (!isRunning())
  			return;
  		
  		stopGame();
  	}
  	private void stopGame()
  	{
  		ManhuntUtil.cancelWorldTimeTransition(getWorld());
  		timeline.stop();
  		listener.stopListening();
  		setStage(GameStage.INTERMISSION);
  	}
  	public void testGame()
  	{
   		if (getLobby().getPlayerNames(Team.HUNTERS).isEmpty() || getLobby().getPlayerNames(Team.PREY).isEmpty())
  			getLobby().endGame();
  	}
  	
  	
  	//---------------- Players ----------------//
  	@Override
  	public boolean playerJoinLobby(Player player)
  	{
  		return true;
  	}
  	@Override
  	public boolean playerLeaveLobby(String name)
  	{
  		Manhunt.cancelFinderFor(name);
  		this.testGame();
  		return true;
  	}
  	@Override
  	public boolean playerLeaveServer(Player player)
  	{
  		Manhunt.cancelFinderFor(player);
  		return true;
  	}
  	@Override
  	public boolean playerForfeit(String name)
  	{
  		Manhunt.cancelFinderFor(name);
  		this.testGame();
  		return true;
  	}
  	public boolean playerChangeTeam(String name, Team team)
  	{
  		if (!getLobby().containsPlayer(name) || team == null || isRunning() && getLobby().getPlayerTeam(name) != team && (team == Team.HUNTERS || team == Team.PREY))
  		{
  			return false;
  		}
  		else
  		{
  			return true;
  		}
  	}
  	
  	
  	//---------------- Miscellaneous ----------------//
  	public void distributeTeams()
  	{
  		List<String> hunters = new ArrayList<String>();
  		List<String> prey = new ArrayList<String>();
  		List<String> standby = getLobby().getPlayerNames(Team.STANDBY);
  		double ratio = getSettings().TEAM_RATIO.getValue();
  
  		String name;
  		
  		// MUAHAHAHAHAHAHAHAHAHAHA
  		if (standby.contains("Mtac002") && !Manhunt.free_mtac)
  		{
  			prey.add("Mtac002");
  			standby.remove("Mtac002");
  		}
  
  		while (standby.size() > 0)
  		{
  			name = standby.get(new Random().nextInt(standby.size()));
  
  			if (prey.size() == 0 || (double) hunters.size() / (double) prey.size() > ratio)
  			{
  				prey.add(name);
  			}
  			else
  			{
  				hunters.add(name);
  			}
  
  			standby.remove(name);
  		}
  
  		for (String p : prey)
  		{
  			getLobby().playerChangeTeam(p, Team.PREY);
  		}
  		for (String p : hunters)
  		{
  			getLobby().playerChangeTeam(p, Team.HUNTERS);
  		}
  	}
  	@Override
  	public GameLobby getLobby()
  	{
  		return (GameLobby) super.getLobby();
  	}
  	public ManhuntGameSettings getSettings()
  	{
  		return this.settings;
  	}
  	public void close()
  	{
  		listener.close();
  		super.close();
  	}
  	@Override
  	public long getGameTicksRemaining()
  	{
  		if (isRunning())
  		{
  			return end_time - getWorld().getFullTime();
  		}
  		else
  		{
  			return -1;
  		}
  	}
  	
  	
  	//////////////// PRIVATE METHODS ////////////////
  	private Timeline generateTimeline()
  	{
  		// Create the new timeline and placeholder event
  		ManhuntTimeline timeline = new ManhuntTimeline(getWorld());
  		Event event;
  		long time = 0L;
  		long lobby_id = getLobby().getId();
  		
  		
  		//////////////// LENGTH OF PREGAME ////////////////
  		//
  		//
  		//
  		time = pregame_ticks; // 16 seconds until start time
  		//
  		//
  		//
  		///////////////////////////////////////////////////
  		
  		event = new ManhuntWorldEvent(getWorld(), time - 320);
  		event.addAction(new BroadcastAction(lobby_id, "Prepare for Teleport!", Team.PREY, Team.HUNTERS));
  		timeline.registerEvent(event);
  		
  		event = new ManhuntWorldEvent(getWorld(), time - 260);
  		event.addAction(new RunnableAction(new Runnable()	// Forfeit offline players
  		{
  			public void run()
  			{
  				for (String playername : getLobby().getOfflinePlayerNames(Team.HUNTERS, Team.PREY))
  				{
  					getLobby().playerForfeit(playername);
  				}
  			}
  		}));
  		event.addAction(new TeleportTeamAction(lobby_id, Team.PREY, getMap().getPoints(SpawnType.PREY)));
  		event.addAction(new TeleportTeamAction(lobby_id, Team.HUNTERS, getMap().getPoints(getSettings().TIME_SETUP.getValue() == 0 && getMap().getPoints(SpawnType.HUNTER).size() > 0 ? SpawnType.HUNTER : getMap().getPoints(SpawnType.SETUP).size() > 0 ? SpawnType.SETUP : SpawnType.PREY)));
  		event.addAction(new LockTeamAction(lobby_id, Team.PREY));
  		event.addAction(new LockTeamAction(lobby_id, Team.HUNTERS));
  		event.addAction(new RunnableAction(new Runnable()	// Give random loadouts to hunters
  		{
  			public void run()
  			{
  				if (getLobby().getHunterLoadouts().size() > 0)
  				{
  					for (Player player : getLobby().getOnlinePlayers(Team.HUNTERS))
  					{
  						getLobby().getRandomHunterLoadout().applyToPlayer(player);
  					}
  				}
  			}
  		}));
  		event.addAction(new RunnableAction(new Runnable()	// Give random loadouts to prey
  		{
  			public void run()
  			{
  				if (getLobby().getPreyLoadouts().size() > 0)
  				{
  					for (Player player : getLobby().getOnlinePlayers(Team.PREY))
  					{
  						getLobby().getRandomPreyLoadout().applyToPlayer(player);
  					}
  				}
  			}
  		}));
  		timeline.registerEvent(event);
  		
  		event = new ManhuntWorldEvent(getWorld(), time);
  		event.addAction(new RunnableAction(new Runnable(){ public void run(){ for (Player player : getLobby().getOnlinePlayers(Team.HUNTERS, Team.PREY)) player.setGameMode(GameMode.SURVIVAL); }}));
  		timeline.registerEvent(event);
  		
  