} else if (entity instanceof GunEmplacement) { unitClass = Messages.getString("ChatLounge.2");
    public void refreshEntities() {        lisEntities.removeAll();        int listIndex = 0;        String strTreeSet = ""; //$NON-NLS-1$        String strTreeView = ""; //$NON-NLS-1$        boolean localUnits = false;        entityCorrespondance = new int[client.game.getNoOfEntities()];        /* We will attempt to sort by the following criteria: My units        first, then my teamates units, then other teams units.  We        will also sort by player name within the forementioned        categories.  Finally, a players units will be sorted by the        order they were "added" to the list.        */        LinkedList sortedEntities = new LinkedList();        for (Enumeration i = client.getEntities(); i.hasMoreElements();) {            Entity entity = (Entity) i.nextElement();            sortedEntities.add(entity);        }        Collections.sort( sortedEntities, new Comparator() {                public int compare( Object aa, Object bb ) {                    Entity a = (Entity)aa;                    Entity b = (Entity)bb;                    Player p_a = a.getOwner();                    Player p_b = b.getOwner();                    int t_a = p_a.getTeam();                    int t_b = p_b.getTeam();                    if (p_a.equals(client.getLocalPlayer()) &&                        !p_b.equals(client.getLocalPlayer())) {                        return -1;                    } else if (p_b.equals(client.getLocalPlayer()) &&                               !p_a.equals(client.getLocalPlayer())) {                        return 1;                    } else if (t_a == client.getLocalPlayer().getTeam()                               && t_b != client.getLocalPlayer().getTeam()) {                        return -1;                    } else if (t_b == client.getLocalPlayer().getTeam()                               && t_a != client.getLocalPlayer().getTeam()) {                        return 1;                    } else if (t_a != t_b) {                        return t_a - t_b;                    } else if (!p_a.equals(p_b)) {                        return p_a.getName().compareTo(p_b.getName());                    } else {                        return a.getId() - b.getId();                    }                }            } );        for (Iterator i = sortedEntities.iterator(); i.hasNext();) {            Entity entity = (Entity) i.next();            // Remember if the local player has units.            if (!localUnits && entity.getOwner().equals(client.getLocalPlayer())) {                localUnits = true;            }            // Reset the tree strings.            strTreeSet = ""; //$NON-NLS-1$            strTreeView = ""; //$NON-NLS-1$            // Set the tree strings based on C3 settings for the unit.            if (entity.hasC3i()) {                if (entity.calculateFreeC3Nodes() == 5)                    strTreeSet = "**"; //$NON-NLS-1$                strTreeView = " (" + entity.getC3NetId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$            } else if (entity.hasC3()) {                if (entity.getC3Master() == null) {                    if (entity.hasC3S())                        strTreeSet = "***"; //$NON-NLS-1$                    else                        strTreeSet = "*"; //$NON-NLS-1$                } else if (!entity.C3MasterIs(entity)) {                    strTreeSet = ">"; //$NON-NLS-1$                    if (entity.getC3Master().getC3Master() != null                        && !entity.getC3Master().C3MasterIs(entity.getC3Master()))                        strTreeSet = ">>"; //$NON-NLS-1$                    strTreeView = " -> " + entity.getC3Master().getDisplayName(); //$NON-NLS-1$                }            }            if (!client.game.getOptions().booleanOption("pilot_advantages")) { //$NON-NLS-1$                entity.getCrew().clearAdvantages();            }            int crewAdvCount = entity.getCrew().countAdvantages();            // Handle the "Blind Drop" option.            if (!entity.getOwner().equals(client.getLocalPlayer())                && client.game.getOptions().booleanOption("blind_drop") //$NON-NLS-1$                && !client.game.getOptions().booleanOption("real_blind_drop")) { //$NON-NLS-1$                String unitClass = ""; //$NON-NLS-1$                if (entity instanceof Infantry) {                    unitClass = Messages.getString("ChatLounge.0"); //$NON-NLS-1$                } else if (entity instanceof Protomech) {                    unitClass = Messages.getString("ChatLounge.1"); //$NON-NLS-1$                } else {                    unitClass = entity.getWeightClassName();                    if (entity instanceof Tank) {                        unitClass += Messages.getString("ChatLounge.6"); //$NON-NLS-1$                    }                }                lisEntities.add(                        Messages.getString("ChatLounge.EntityListEntry1", new Object[]{ //$NON-NLS-1$                                entity.getOwner().getName(),                                new Integer(entity.getCrew().getGunnery()),                                new Integer(entity.getCrew().getPiloting()),                                (crewAdvCount > 0 ? " <" + crewAdvCount + Messages.getString("ChatLounge.advs") : ""), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$                                unitClass,                                ((entity.isOffBoard()) ? Messages.getString("ChatLounge.deploysOffBoard") : ""), //$NON-NLS-1$ //$NON-NLS-2$                                ((entity.getDeployRound() > 0) ? Messages.getString("ChatLounge.deploysAfterRound") + entity.getDeployRound() : "")})); //$NON-NLS-1$ //$NON-NLS-2$                entityCorrespondance[listIndex++] = entity.getId();            } else if (entity.getOwner().equals(client.getLocalPlayer())                       || (!client.game.getOptions().booleanOption("blind_drop") //$NON-NLS-1$                       && !client.game.getOptions().booleanOption("real_blind_drop"))) { //$NON-NLS-1$                lisEntities.add(                    strTreeSet                    + Messages.getString("ChatLounge.EntityListEntry2", new Object[]{ //$NON-NLS-1$                            entity.getDisplayName(),                            new Integer(entity.getCrew().getGunnery()),                            new Integer(entity.getCrew().getPiloting()),                            (crewAdvCount > 0 ? " <" + crewAdvCount + Messages.getString("ChatLounge.advs") : ""), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$                            new Integer(entity.calculateBattleValue()),                            strTreeView,                            ((entity.isOffBoard()) ? Messages.getString("ChatLounge.deploysOffBoard") : ""), //$NON-NLS-1$ //$NON-NLS-2$                            ((entity.getDeployRound() > 0) ? Messages.getString("ChatLounge.deploysAfterRound") + entity.getDeployRound() : ""), //$NON-NLS-1$ //$NON-NLS-2$                            (entity.isDesignValid() ? "" : Messages.getString("ChatLounge.invalidDesign"))})); //$NON-NLS-1$ //$NON-NLS-2$                entityCorrespondance[listIndex++] = entity.getId();            }        }        // Enable the "Save Unit List..." and "Delete All"        // buttons if the local player has units.        butSaveList.setEnabled(localUnits);        butDeleteAll.setEnabled(localUnits);        // Disable the "must select" buttons.        butCustom.setEnabled(false);        butMechReadout.setEnabled(false);        butDelete.setEnabled(false);    }