Package com.github.alex1304.jdash.client
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.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GDClientBuilder.Credentials
Encapsulates a username and a password field. -
Field Summary
Fields Modifier and Type Field Description static Duration
DEFAULT_CACHE_TTL
static int
DEFAULT_MAX_CONNECTIONS
Deprecated.static Duration
DEFAULT_REQUEST_TIMEOUT
-
Method Summary
Modifier and Type Method Description AnonymousGDClient
buildAnonymous()
Builds an anonymous Geometry Dash client.reactor.core.publisher.Mono<AuthenticatedGDClient>
buildAuthenticated(GDClientBuilder.Credentials credentials)
Builds a GD client authenticated with a username and a password.AuthenticatedGDClient
buildAuthenticated(String username, String password)
Deprecated.This method is synchronous and blocking.static GDClientBuilder
create()
GDClientBuilder
withCacheTtl(Duration time)
Specifies how long a request should stay in cache.GDClientBuilder
withCooldown(Cooldown cooldown)
Specifies a cooldown for requests.GDClientBuilder
withHost(String host)
Specifies a custom host for the client to send the requests to.GDClientBuilder
withMaxConnections(int maxConnections)
Deprecated.Limiting max connections is no longer supported.GDClientBuilder
withRequestTimeout(Duration time)
Specifies a timeout for requests to complete.
-
Field Details
-
DEFAULT_CACHE_TTL
-
DEFAULT_MAX_CONNECTIONS
Deprecated. -
DEFAULT_REQUEST_TIMEOUT
-
-
Method Details
-
create
-
withHost
Specifies a custom host for the client to send the requests to. This allows the use ofAnonymousGDClient
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 isnull
-
withCacheTtl
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.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
Specifies a timeout for requests to complete. If a request does not complete in time, aTimeoutException
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
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
Builds an anonymous Geometry Dash client.- Returns:
AnonymousGDClient
-
buildAuthenticated
@Deprecated public AuthenticatedGDClient buildAuthenticated(String username, String password) throws GDLoginFailedExceptionDeprecated.This method is synchronous and blocking. UsebuildAuthenticated(Credentials)
instead which builds the authenticated client asynchronously.Builds a GD client authenticated with a username and a password.- Parameters:
username
- the usernamepassword
- 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
-