/** * PlayerList - Half Life PlayerList class - Source: <a href='http://www.warpedcoders.org/source/WarpedCStrike/PlayerList.java'>View Source</a> * * @(#)PlayerList.java * * @author Justin Novak - SkareCrow * @version 1.00 2006/11/12 */import java.util.*;public class PlayerList { private static final String EOL = System.getProperty("line.separator"); private Map<Object, Player> players = new LinkedHashMap<Object, Player>(); /** * No Arguements Constructor * For Objects that extend PlayerList */ public PlayerList() { } /** * Method adds a new Player to the PlayerList with a key of Player index * * @param p The Player to add to PlayerList */ public void addPlayer(Player p) { players.put(p.getIndex(), p); } /** * Method to remove a Player from PlayerList * * @param key The key from PlayerList - Player index */ public void removePlayer(Object key) { players.remove(key); } /** * Method to return an Player from PlayerList * * @param key The key from PlayerList - Player index * @returns An Player from PlayerList */ public Player getPlayer(Object key) { return players.get(key); } /** * Method to return a {@line Collection} from the PlayerList * * @returns A new Collection of PlayerList */ public Collection getPlayers() { return players.values(); } /** * Method to return an Array of PlayerList - Player's * * @returns An new Object[] of Player's */ public Object[] toArray() { return getPlayers().toArray(); } /** * Method for Debugging - Outputs all Player's to the console */ public void toConsole() { Iterator it = getPlayers().iterator(); while (it.hashNext()) { Player p = it.next(); System.out.println("--- Player Index: " + p.getIndex() + " ---------"); System.out.println("Player Name: " + p.getName()); System.out.println("Player Kills: " + p.getKills()); System.out.println("Time Conected: " + p.getTime()); } }}