Entity entity = game.getEntity(entityId); if (entity != null && entity.getOwner() == getPlayer(connIndex)) {
final Entity entity = game.getEntity(entityId);   if ( entity != null && entity.getOwner() == getPlayer(connIndex) ) {   if ( entity instanceof Protomech ) {   int numPlayerProtos = game.getSelectedEntityCount ( new EntitySelector() { private final int ownerId = entity.getOwnerId(); public boolean accept( Entity entity ) { if ( entity instanceof Protomech && ownerId == entity.getOwnerId() ) return true; return false; } } );     final char oldMax = (char)(Math.ceil( ((double)numPlayerProtos) / 5.0 )-1); char newMax = (char)(Math.ceil( ((double) (numPlayerProtos-1))/ 5.0 )-1); char deletedUnitNum = entity.getUnitNumber();   if ( oldMax != deletedUnitNum && oldMax != newMax ) {    Enumeration lastUnit = game.getSelectedEntities ( new EntitySelector() { private final int ownerId = entity.getOwnerId(); private final char lastUnitNum = oldMax; public boolean accept( Entity entity ) { if ( entity instanceof Protomech && ownerId == entity.getOwnerId() && lastUnitNum == entity.getUnitNumber() ) return true; return false; } } ); Entity lastUnitMember = (Entity) lastUnit.nextElement(); lastUnitMember.setUnitNumber( deletedUnitNum ); this.entityUpdate( lastUnitMember.getId() );  }  }
    private void receiveEntityDelete(Packet c, int connIndex) {        int entityId = c.getIntValue(0);        Entity entity = game.getEntity(entityId);        if (entity != null && entity.getOwner() == getPlayer(connIndex)) {            game.removeEntity(entityId, Entity.REMOVE_NEVER_JOINED);            send(createRemoveEntityPacket(entityId, Entity.REMOVE_NEVER_JOINED));        } else {            // hey! that's not your entity        }    }