Alex1304 / jdash

Geometry Dash API for Java developers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JDash

GitHub release (latest SemVer) Maven Central License javadoc

A reactive Geometry Dash API wrapper for Java.

Overview

JDash is a multi-module library requiring JDK 11 or above since version 4.0. There are currently 4 modules.

JDash Common module

Contains utility classes and data types to encode the different entities of Geometry Dash (levels, users...) required by all other modules.

Maven dependency (if you are already using one of the other modules, you don't need to add this dependency as other modules transitively depend on it):

<dependency>
    <groupId>com.alex1304.jdash</groupId>
    <artifactId>jdash-common</artifactId>
    <version>${version}</version> <!-- replace with latest version -->
</dependency>

JDash Client module

Provides a high-level client to request data from Geometry Dash servers. It is powered by Project Reactor which allows to make requests in an efficient and non-blocking manner with backpressure handling (requests are queued internally and processed when resources are available, allowing requests to fail-fast in case the queue is full).

GDClient client = GDClient.create();

// Block until request completes
GDLevel level = client.findLevelById(10565740).block();
System.out.println(level);

// But we can also choose to make it asychronous and non-blocking
client.getUserProfile(98006).subscribe(System.out::println); // will not block

Maven dependency:

<dependency>
    <groupId>com.alex1304.jdash</groupId>
    <artifactId>jdash-client</artifactId>
    <version>${version}</version> <!-- replace with latest version -->
</dependency>

JDash Events module

Provides an event loop that can be subscribed to in order to detect when new levels get rated and when the Daily level or Weekly demon changes.

GDClient client = GDClient.create();
GDEventLoop eventLoop = GDEventLoop.startWithDefaults(client);

eventLoop.on(AwardedAdd.class)
        .subscribe(event -> System.out.println("New level rated: "
                + event.addedLevel().name()));

eventLoop.on(DailyLevelChange.class)
        .subscribe(event -> System.out.println("New Daily level: "
                + event.after().name()));

Maven dependency:

<dependency>
    <groupId>com.alex1304.jdash</groupId>
    <artifactId>jdash-events</artifactId>
    <version>${version}</version> <!-- replace with latest version -->
</dependency>

JDash Graphics module

Allows to generate icon images from game assets.

// Get the user profile from the client or construct it manually
GDUserProfile user = ...;
// Will load game assets to memory. You should only need 1 instance in your application.
SpriteFactory spriteFactory = SpriteFactory.create();
// Create an icon set for the given user
GDUserIconSet iconSet = GDUserIconSet.create(user, spriteFactory);
// Generates the icon for the desired type, in this example the ball icon
BufferedImage icon = iconSet.generateIcon(IconType.BALL);
// Do anything with it, for example save it in tmp directory
String fileName = System.getProperty("java.io.tmpdir") + File.separator + "icon.png";
ImageIO.write(icon, "png", new File(fileName));

Result:

icon

Maven dependency:

<dependency>
    <groupId>com.alex1304.jdash</groupId>
    <artifactId>jdash-graphics</artifactId>
    <version>${version}</version> <!-- replace with latest version -->
</dependency>

Documentation

The full documentation is available at: https://jdash.alex1304.com

Javadoc:

License

This project is licensed under the MIT licence.

Contribute

Have a feature to suggest or a bug to report ? Issues and pull requests are more than welcome! Make sure to follow the template and share your ideas.

Contact

E-mail: mirandaa1304@gmail.com

Discord: Alex1304#9704

Twitter: @gd_alex1304

About

Geometry Dash API for Java developers

License:MIT License


Languages

Language:Java 98.9%Language:JavaScript 0.8%Language:CSS 0.3%