/**
   * Handle a "buildColony"-message.
   *
   * @param server The <code>FreeColServer</code> handling the request.
   * @param player The <code>Player</code> building the colony.
   * @param connection The <code>Connection</code> the message is from.
   * @return An update <code>Element</code> defining the new colony and updating its surrounding
   *     tiles, or an error <code>Element</code> on failure.
   */
  public Element handle(FreeColServer server, Player player, Connection connection) {
    Game game = server.getGame();
    ServerPlayer serverPlayer = server.getPlayer(connection);

    Unit unit;
    try {
      unit = player.getFreeColGameObject(builderId, Unit.class);
    } catch (Exception e) {
      return DOMMessage.clientError(e.getMessage());
    }
    if (!unit.canBuildColony()) {
      return DOMMessage.clientError("Unit " + builderId + " can not build colony.");
    }

    if (colonyName == null) {
      return DOMMessage.clientError("Null colony name");
    } else if (Player.ASSIGN_SETTLEMENT_NAME.equals(colonyName)) {; // ok
    } else if (game.getSettlement(colonyName) != null) {
      return DOMMessage.clientError("Non-unique colony name " + colonyName);
    }

    Tile tile = unit.getTile();
    if (!player.canClaimToFoundSettlement(tile)) {
      return DOMMessage.clientError("Can not build colony on tile: " + tile);
    }

    // Build can proceed.
    return server.getInGameController().buildSettlement(serverPlayer, unit, colonyName);
  }