jdash.client.response.DailyInfoResponseDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdash-client Show documentation
Show all versions of jdash-client Show documentation
The HTTP client used to pull data from Geometry Dash servers
The newest version!
package jdash.client.response;
import jdash.client.exception.ActionFailedException;
import jdash.common.entity.GDDailyInfo;
import java.time.Duration;
import java.util.function.Function;
class DailyInfoResponseDeserializer implements Function {
@Override
public GDDailyInfo apply(String response) {
if (!response.matches("\\d+\\|\\d+(|.*)*")) {
throw new ActionFailedException(response, "Failed to load daily level info");
}
final var tokens = response.split("\\|");
final var number = Long.parseLong(tokens[0]) % 100_000;
return new GDDailyInfo(number, Duration.ofSeconds(Long.parseLong(tokens[1])));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy