JDash
A Java library for Geometry Dash.
Features
- Provides a high-level HTTP client to fetch data from Geometry Dash servers
- Supports authentication with Geometry Dash account username / password
- Allows for both blocking and reactive/non-blocking programming styles
- Supports request caching for better performances
- Provides a convenient way to generate player icons.
Get started
In a Maven project, add the following dependency to your pom.xml
:
<dependencies>
<!-- ... your other dependencies -->
<dependency>
<groupId>com.github.alex1304</groupId>
<artifactId>jdash</artifactId>
<version><!-- Latest version number --></version>
</dependency>
</dependencies>
Or download the latest version at the releases page, and add all required JAR files into the build path of your Java project.
How to use it ?
There are many ways to use the library. Here are a few examples:
Anonymous client, blocking style
import com.github.alex1304.jdash.client.AnonymousGDClient;
import com.github.alex1304.jdash.client.GDClientBuilder;
import com.github.alex1304.jdash.entity.GDLevel;
import com.github.alex1304.jdash.entity.GDUser;
public class TestMain {
public static void main(String[] args) {
// Build an anonymous client
AnonymousGDClient client = GDClientBuilder.create().buildAnonymous();
// Fetch level of ID 10565740
GDLevel level = client.getLevelById(10565740).block();
// Fetch user of name "RobTop"
GDUser user = client.searchUser("RobTop").block();
// Do stuff with them, for example print them
System.out.println(level);
System.out.println(user);
}
}
Anonymous client, non-blocking style
import com.github.alex1304.jdash.client.AnonymousGDClient;
import com.github.alex1304.jdash.client.GDClientBuilder;
public class TestMain {
public static void main(String[] args) throws Exception {
// Build an anonymous client
AnonymousGDClient client = GDClientBuilder.create().buildAnonymous();
// Fetch level of ID 10565740 then print it
client.getLevelById(10565740).doOnSuccess(level -> System.out.println(level)).subscribe();
// Fetch user of name "RobTop" then print it
client.searchUser("RobTop").doOnSuccess(user -> System.out.println(user)).subscribe();
// The above calls are non-blocking, meaning that you can do something else in parallel while the client is doing its job!
// Let's put that in evidence:
System.out.println("Start another long-running task here...");
Thread.sleep(5000);
System.out.println("Bye!");
}
}
Authenticated client
import com.github.alex1304.jdash.client.AuthenticatedGDClient;
import com.github.alex1304.jdash.client.GDClientBuilder;
import com.github.alex1304.jdash.entity.GDMessage;
import com.github.alex1304.jdash.exception.GDLoginFailedException;
import com.github.alex1304.jdash.util.GDPaginator;
public class TestMain {
public static void main(String[] args) throws Exception {
// Build an anonymous client
try {
AuthenticatedGDClient client = GDClientBuilder.create().buildAuthenticated(new Credentials("MyUsername", "MyP@ssw0rd")).block();
// With an authenticated client, you can do cool stuff like this:
client.getPrivateMessages(0).doOnSuccess(messages -> {
for (GDMessage message : messages) {
System.out.println(message);
}
}).subscribe();
// Pretty self-explanatory, right? It's fetching your in-game private messages!
// Here's a blocking version:
GDPaginator<GDMessage> messages = client.getPrivateMessages(0).block();
for (GDMessage message : messages) {
System.out.println(message);
}
// GDPaginator is basically a List but with extra metadata info related to pagination
// (number of pages, number of items per page, etc). RTFM for more details.
} catch (GDLoginFailedException e) {
System.err.println("Oops! Login failed.");
}
}
}
The full documentation is available here.
License
MIT
Contribute
Issues and Pull requests are more than welcome ! There is no guide that tells how to structure them, but if you explain clearly what you did in your pull request, we will be able to dicuss about it and getting it eventually merged. This is the same for issues, feel free to submit them as long as they are clear.
Contact
E-mail: [email protected]
Discord: Alex1304#9704
Twitter: @gd_alex1304