Class AuthenticatedGDClient


  • public final class AuthenticatedGDClient
    extends Object
    An HTTP client specifically designed to make authenticated requests to Geometry Dash servers. It provides the same methods as AnonymousGDClient, but allows to do more stuff that requires authentication, such as reading private messages, etc. To create an instance of this class, use GDClientBuilder.buildAuthenticated(String, String).

    Unless mentionned otherwise on the said methods, all methods which return type is a Mono may emit one of the following errors if the underlying request fails:

    • BadResponseException - happens when the Geometry Dash server returns an HTTP error (like a 404 Not Found or a 500 Internal Server Error for instance)
    • MissingAccessException - certainly the most common error. Happens when nothing is found (e.g a level search gave no results), or when access to the resource is denied (e.g trying to fetch a user profile with an authenticated client, and the user has blocked the account that the client is logged on). Unfortunately there is no way to distinguish those two situations due to how the Geometry Dash API is designed. For those who are familiar with the raw Geometry Dash API, this is when the server returns -1.
    • CorruptedResponseContentException - happens when the Geometry Dash server returns a response that cannot be parsed to the desired object. This should rarely happen in normal conditions, but it may be more frequent when you use JDash on a Geometry Dash private server.
    • Method Detail

      • getPrivateMessages

        public reactor.core.publisher.Mono<GDPaginator<GDMessage>> getPrivateMessages​(int page)
        Gets the private messages of the account that this client is logged on.
        Parameters:
        page - the page number
        Returns:
        a Mono emitting a paginator containing all messages found. Note that if no messages are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when nothing is found and when an actual error occurs while processing the request (blame RobTop for that!).
        Throws:
        UnsupportedOperationException - if this client is not logged it to any account
      • sendPrivateMessage

        public reactor.core.publisher.Mono<Void> sendPrivateMessage​(GDUser user,
                                                                    String subject,
                                                                    String body)
        Sends a private message to a user.
        Parameters:
        user - the recipient of the message
        subject - the message subject
        body - the message body
        Returns:
        a Mono completing empty if succeeded, an error otherwise.
        Throws:
        UnsupportedOperationException - if this client is not logged it to any account
        IllegalArgumentException - if user isn't a registered user (user.getAccountId() == 0)
      • sendPrivateMessage

        public reactor.core.publisher.Mono<Void> sendPrivateMessage​(long recipientAccountId,
                                                                    String subject,
                                                                    String body)
        Sends a private message to a user by their ID.
        Parameters:
        recipientAccountId - the ID of the recipient of the message
        subject - the message subject
        body - the message body
        Returns:
        a Mono completing empty if succeeded, an error otherwise.
        Throws:
        UnsupportedOperationException - if this client is not logged it to any account
        IllegalArgumentException - if user isn't a registered user (user.getAccountId() == 0)
      • getAccountID

        public long getAccountID()
        Gets the account ID of this client
        Returns:
        the account ID
        Throws:
        IllegalStateException - if this client is unauthenticated
      • getPlayerID

        public long getPlayerID()
        Gets the player ID of this client
        Returns:
        the player ID
        Throws:
        IllegalStateException - if this client is unauthenticated
      • getUsername

        public String getUsername()
        Gets the username of the GD account this client is logged in
        Returns:
        the username
        Throws:
        IllegalStateException - if this client is unauthenticated
      • getPassword

        public String getPassword()
        Gets the GD account password of this client
        Returns:
        the password
        Throws:
        IllegalStateException - if this client was built with no password specified
      • getUserByAccountId

        public reactor.core.publisher.Mono<GDUser> getUserByAccountId​(long accountId)
        Gets a Geometry Dash user from their accountID
        Parameters:
        accountId - the ID of the user's Geometry Dash account
        Returns:
        a Mono emitting the requested user, or an error if something goes wrong (user not found, user has blocked the account that this client is logged on, etc). If the user profile is found but was unable to retrieve search result data for that user, a UserSearchDataNotFoundException will be emitted.
      • searchUser

        public reactor.core.publisher.Mono<GDUser> searchUser​(String searchQuery)
        Submits a search query and returns the corresponding user.
        Parameters:
        searchQuery - the user to search for
        Returns:
        a Mono emitting the user found, or an error if not found.
      • getLevelById

        public reactor.core.publisher.Mono<GDLevel> getLevelById​(long levelId)
        Gets a Geometry Dash level from its ID.
        Parameters:
        levelId - the ID of the level to get
        Returns:
        a Mono emitting the level with the corresponding ID, or an error if not found or something went wrong.
      • getSongById

        public reactor.core.publisher.Mono<GDSong> getSongById​(long songId)
        Gets information on a custom song from its ID.
        Parameters:
        songId - the ID of the song
        Returns:
        a Mono emitting the song info, or an error if not found or something went wrong. If the song is not allowed for use in Geometry Dash, the error SongNotAllowedForUseException will be emitted.
      • getDailyLevel

        public reactor.core.publisher.Mono<GDTimelyLevel> getDailyLevel()
        Gets the current Daily Level on Geometry Dash.
        Returns:
        a Mono emitting the Daily level, or an error if not found or something went wrong. If no Daily level is available, the error NoTimelyAvailableException is emitted.
      • getWeeklyDemon

        public reactor.core.publisher.Mono<GDTimelyLevel> getWeeklyDemon()
        Gets the current Weekly Demon on Geometry Dash.
        Returns:
        a Mono emitting the Weekly demon, or an error if not found or something went wrong. If no Weekly demon is available, the error NoTimelyAvailableException is emitted.
      • searchLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> searchLevels​(String query,
                                                                              LevelSearchFilters filters,
                                                                              int page)
        Search for levels in Geometry Dash.
        Parameters:
        query - the search query
        filters - the search filters
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • getLevelsByUser

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> getLevelsByUser​(GDUser user,
                                                                                 int page)
        Gets levels uploaded by a specific user in Geometry Dash.
        Parameters:
        user - the user
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseAwardedLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseAwardedLevels​(LevelSearchFilters filters,
                                                                                     int page)
        Browse levels in the Awarded section of Geometry Dash.
        Parameters:
        filters - the search filters
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseRecentLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseRecentLevels​(LevelSearchFilters filters,
                                                                                    int page)
        Browse levels in the Recent section of Geometry Dash.
        Parameters:
        filters - the search filters
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseFeaturedLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseFeaturedLevels​(int page)
        Browse levels in the Featured section of Geometry Dash.
        Parameters:
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseHallOfFameLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseHallOfFameLevels​(int page)
        Browse levels in the Hall of Fame section of Geometry Dash.
        Parameters:
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseMostDownloadedLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseMostDownloadedLevels​(LevelSearchFilters filters,
                                                                                            int page)
        Browse levels in the Most Downloaded section of Geometry Dash.
        Parameters:
        filters - the search filters
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseMostLikedLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseMostLikedLevels​(LevelSearchFilters filters,
                                                                                       int page)
        Browse levels in the Most Liked section of Geometry Dash.
        Parameters:
        filters - the search filters
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseTrendingLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseTrendingLevels​(LevelSearchFilters filters,
                                                                                      int page)
        Browse levels in the Trending section of Geometry Dash.
        Parameters:
        filters - the search filters
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseMagicLevels

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseMagicLevels​(LevelSearchFilters filters,
                                                                                   int page)
        Browse levels in the Magic section of Geometry Dash.
        Parameters:
        filters - the search filters
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseFollowedLevels

        @Deprecated
        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseFollowedLevels​(LevelSearchFilters filters,
                                                                                      Collection<? extends GDUser> followed,
                                                                                      int page)
        Deprecated.
        This requires that all GDUser instances must have been fetched beforehand, while account IDs are technically sufficient to perform this request. Please use browseFollowedIds(...) instead.
        Browse levels in the Followed section of Geometry Dash.
        Parameters:
        filters - the search filters
        followed - the collection containing the instances of followed users
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • browseFollowedIds

        public reactor.core.publisher.Mono<GDPaginator<GDLevel>> browseFollowedIds​(LevelSearchFilters filters,
                                                                                   Collection<? extends Long> followedAccountIDs,
                                                                                   int page)
        Browse levels in the Followed section of Geometry Dash.
        Parameters:
        filters - the search filters
        followedAccountIDs - the collection containing the account IDs of followed users
        page - the page number
        Returns:
        a Mono emitting a paginator containing all levels found. Note that if no levels are found, it will emit an error instead of just an empty paginator. This is because the Geometry Dash API returns the same response when the search produces no results and when an actual error occurs while processing the request (blame RobTop for that!).
      • getUserDataFromProfile

        public reactor.core.publisher.Mono<GDUserProfileData> getUserDataFromProfile​(long accountId)
        Gets data from a user provided by their profile. Unlike getUserByAccountId(long), this doesn't include some data that is only obtainable by using getUserDataFromSearch(String)
        Parameters:
        accountId - the account ID of the user to fetch
        Returns:
        a Mono emitting the data found
      • getUserDataFromSearch

        public reactor.core.publisher.Mono<GDUserSearchData> getUserDataFromSearch​(String searchQuery)
        Gets data from a user provided by the Search user feature. The data gotten from there might be inaccurate and severely outdated, that's why it is preferred to use getUserDataFromProfile(long) in order to fetch stats.
        Parameters:
        searchQuery - the search query
        Returns:
        a Mono emitting the data found
      • getHost

        public String getHost()
        Gets the host.
        Returns:
        String
      • getCacheTtl

        public java.time.Duration getCacheTtl()
        Gets the time to live of a cache entry in milliseconds.
        Returns:
        long
      • getMaxConnections

        public int getMaxConnections()
        Gets the maximum number of simultaneous connections.
        Returns:
        int
      • getRequestTimeout

        public java.time.Duration getRequestTimeout()
        Gets the maximum time in milliseconds to wait if a request takes too long to complete.
        Returns:
        long
      • clearCache

        public void clearCache()
        Clears the cache of previous requests.