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.
-
-
Field Summary
Fields Modifier and Type Field Description static java.time.Duration
DEFAULT_CACHE_TTL
static int
DEFAULT_MAX_CONNECTIONS
static java.time.Duration
DEFAULT_REQUEST_TIMEOUT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AnonymousGDClient
buildAnonymous()
Builds an anonymous Geometry Dash client.AuthenticatedGDClient
buildAuthenticated(String username, String password)
Builds a GD client authenticated with a username and a password.static GDClientBuilder
create()
GDClientBuilder
withCacheTtl(java.time.Duration time)
Specifies how long a request should stay in cache.GDClientBuilder
withHost(String host)
Specifies a custom host for the client to send the requests to.GDClientBuilder
withMaxConnections(int maxConnections)
Specifies how many connections to the GD servers can be simultaneously open.GDClientBuilder
withRequestTimeout(java.time.Duration time)
Specifies a timeout for requests to complete.
-
-
-
Method Detail
-
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 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
public GDClientBuilder withCacheTtl(java.time.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
public GDClientBuilder withMaxConnections(int maxConnections)
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(java.time.Duration time)
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
-
buildAnonymous
public AnonymousGDClient buildAnonymous()
Builds an anonymous Geometry Dash client.- Returns:
AnonymousGDClient
-
buildAuthenticated
public AuthenticatedGDClient buildAuthenticated(String username, String password) throws GDLoginFailedException
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
-
-