public List<Server> getServerTypeServers(ServerType serverType) {
    List<Server> servers = new ArrayList<>();

    DBCursor serversCursor =
        getDatabase()
            .findMany(
                "servers", new BasicDBObject("server_type_id", serverType.getId().toString()));
    while (serversCursor.hasNext()) {
      servers.add(getModel((ObjectId) serversCursor.next().get("_id"), serverType));
    }

    return servers;
  }
  public Server getNetworkServerTypeServerNumber(
      Network network, ServerType serverType, int number) {
    List<Server> servers = new ArrayList<>();

    BasicDBObject query = new BasicDBObject("network_id", network.getId().toString());
    query.put("server_type_id", serverType.getId().toString());
    query.put("number", number);

    DBObject dbServer = getDatabase().findOne("servers", query);
    if (dbServer == null) {
      return null;
    }
    return getModel((ObjectId) dbServer.get("_id"), network, serverType);
  }
  public List<Server> getNetworkServerTypeServers(
      Network network, ServerType serverType, boolean onlyActive) {
    List<Server> servers = new ArrayList<>();

    BasicDBObject query = new BasicDBObject("network_id", network.getId().toString());
    query.put("server_type_id", serverType.getId().toString());
    if (onlyActive == true) {
      query.put("number", new BasicDBObject("$gt", 0));
      query.put("port", new BasicDBObject("$gt", 0));
    }

    DBCursor serversCursor = getDatabase().findMany("servers", query);
    serversCursor.sort(new BasicDBObject("number", 1));

    while (serversCursor.hasNext()) {
      servers.add(getModel((ObjectId) serversCursor.next().get("_id"), network, serverType));
    }
    return servers;
  }
  public int getNextNumber(Network network, ServerType serverType) {
    int number = 1;

    List<Integer> numbers = new ArrayList<>();

    BasicDBObject query = new BasicDBObject("network_id", network.getId().toString());
    query.put("server_type_id", serverType.getId().toString());

    DBCursor serversCursor = getDatabase().findMany("servers", query);
    while (serversCursor.hasNext()) {
      int serverNumber = (int) serversCursor.next().get("number");
      numbers.add(serverNumber);
    }

    while (numbers.contains(number)) {
      number += 1;
    }

    return number;
  }