System.out.println("s: player " + connId + " (" + getPlayer(connId).getName() + ") connected from " + getClient(connId).getSocket().getInetAddress());  sendServerChat(getPlayer(connId).getName() + " connected from " + getClient(connId).getSocket().getInetAddress());   if (game.getNoOfPlayers() > 1 && game.getOptions().booleanOption("friendly_fire")) { game.getOptions().getOption("friendly_fire").setValue(false); send(createGameSettingsPacket()); }
player = getPlayer( connId ); if ( null != player ) { StringBuffer buff = new StringBuffer(); buff.append( player.getName() ) .append( " connected from " ) .append( getClient(connId).getSocket().getInetAddress() ); String who = buff.toString(); System.out.print( "s: player #" ); System.out.print( connId ); System.out.print( ", " ); System.out.println( who );  sendServerChat( who );   if ( game.getNoOfPlayers() > 1 && game.getOptions().booleanOption("friendly_fire") ) { game.getOptions().getOption("friendly_fire").setValue(false); send(createGameSettingsPacket()); } }
    private void receivePlayerName(Packet packet, int connId) {        final Connection conn = getPendingConnection(connId);        String name = (String)packet.getObject(0);        boolean returning = false;                // this had better be from a pending connection        if (conn == null) {            System.out.println("server: got a client name from a non-pending connection");            return;        }                // check if they're connecting with the same name as a ghost player        for (Enumeration i = game.getPlayers(); i.hasMoreElements();) {            Player player = (Player)i.nextElement();            if (player.isGhost() && player.getName().equals(name)) {                returning = true;                player.setGhost(false);                // switch id                connId = player.getId();                conn.setId(connId);            }        }                // right, switch the connection into the "active" bin        connectionsPending.removeElement(conn);        connections.addElement(conn);        connectionIds.put(new Integer(conn.getId()), conn);                // add and validate the player info        if (!returning) {            game.addPlayer(connId, new Player(connId, name));            validatePlayerInfo(connId);        }                // if it is not the lounge phase, this player becomes an observer        if (game.getPhase() != Game.PHASE_LOUNGE        && game.getEntitiesOwnedBy(getPlayer(connId)) < 1) {            getPlayer(connId).setObserver(true);        }                // send the player the motd        sendServerChat(connId, motd);                // send info that the player has connected        send(createPlayerConnectPacket(connId));                // tell them their local playerId        send(connId, new Packet(Packet.COMMAND_LOCAL_PN, new Integer(connId)));                // send current game info        sendCurrentInfo(connId);        try {            InetAddress[] addresses = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());            for (int i = 0; i < addresses.length; i++) {                sendServerChat(connId, "Machine IP is " + addresses[i].getHostAddress());            }        } catch (UnknownHostException  e) {            // oh well.        }                System.out.println("s: player " + connId        + " (" + getPlayer(connId).getName() + ") connected from "        + getClient(connId).getSocket().getInetAddress());                sendServerChat(getPlayer(connId).getName() + " connected from "        + getClient(connId).getSocket().getInetAddress());                // there is more than one player, uncheck the friendly fire option        if (game.getNoOfPlayers() > 1 && game.getOptions().booleanOption("friendly_fire")) {            game.getOptions().getOption("friendly_fire").setValue(false);            send(createGameSettingsPacket());        }    }