Class GDClientBuilder

java.lang.Object
com.github.alex1304.jdash.client.GDClientBuilder

public final class GDClientBuilder
extends Object
Builds a Geometry Dash client step by step.
  • Field Details

    • DEFAULT_CACHE_TTL

      public static final Duration DEFAULT_CACHE_TTL
    • DEFAULT_MAX_CONNECTIONS

      @Deprecated public static final int DEFAULT_MAX_CONNECTIONS
      Deprecated.
    • DEFAULT_REQUEST_TIMEOUT

      public static final Duration DEFAULT_REQUEST_TIMEOUT
  • Method Details

    • create

      public static GDClientBuilder create()
    • withHost

      public GDClientBuilder withHost​(String host)
      Specifies a custom host for the client to send the requests to. This allows the use of AnonymousGDClient for Geometry Dash private servers (GDPS).
      Parameters:
      host - the host address (WITHOUT protocol and WITHOUT trailing slash!)
      Returns:
      this (for method chaining purposes)
      Throws:
      IllegalArgumentException - if host starts with 'http://', ends with '/'
      NullPointerException - if host is null
    • withCacheTtl

      public GDClientBuilder withCacheTtl​(Duration time)
      Specifies how long a request should stay in cache. Setting 0 as value disables the cache.
      Parameters:
      time - the time to set for the cache ttl
      Returns:
      this (for method chaining purposes)
      Throws:
      IllegalArgumentException - if time is negative
    • withMaxConnections

      @Deprecated public GDClientBuilder withMaxConnections​(int maxConnections)
      Deprecated.
      Limiting max connections is no longer supported. It caused too many issues as it involved having a fixed pool of connections. Reactor netty has a bug that causes the pool to break and make requests become indefinitely stuck at trying to acquire a connection.
      Specifies how many connections to the GD servers can be simultaneously open.
      Parameters:
      maxConnections - the number of max connections
      Returns:
      this (for method chaining purposes)
      Throws:
      IllegalArgumentException - if maxConnections is < 1
    • withRequestTimeout

      public GDClientBuilder withRequestTimeout​(Duration time)
      Specifies a timeout for requests to complete. If a request does not complete in time, a TimeoutException will be propagated for the said request.
      Parameters:
      time - the time to set for the cache ttl
      Returns:
      this (for method chaining purposes)
      Throws:
      IllegalArgumentException - if time is negative
    • withCooldown

      public GDClientBuilder withCooldown​(Cooldown cooldown)
      Specifies a cooldown for requests. This is useful to mitigate the risk of getting IP banned from official Geometry Dash servers in case too many requests are sent.
      Parameters:
      cooldown - the cooldown to apply globally
      Returns:
      this (for method chaining purposes)
    • buildAnonymous

      public AnonymousGDClient buildAnonymous()
      Builds an anonymous Geometry Dash client.
      Returns:
      AnonymousGDClient
    • buildAuthenticated

      @Deprecated public AuthenticatedGDClient buildAuthenticated​(String username, String password) throws GDLoginFailedException
      Deprecated.
      This method is synchronous and blocking. Use buildAuthenticated(Credentials) instead which builds the authenticated client asynchronously.
      Builds a GD client authenticated with a username and a password.
      Parameters:
      username - the username
      password - the password
      Returns:
      the authenticated GD client
      Throws:
      GDLoginFailedException - if the authentication fails
    • buildAuthenticated

      public reactor.core.publisher.Mono<AuthenticatedGDClient> buildAuthenticated​(GDClientBuilder.Credentials credentials)
      Builds a GD client authenticated with a username and a password. It internally builds an anonymous GD client in order to perform a login request, then constructs an authenticated client based on the login response.
      Parameters:
      credentials - the credentials used to authenticate the client
      Returns:
      a Mono that emites the authenticated client upon successful login. If the login fails, it will emit an error of type GDLoginFailedException