diff --git a/build.gradle.kts b/build.gradle.kts index 9ddd497..f23e7fc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.springframework.boot") version "3.3.0" + id("org.springframework.boot") version "3.3.1" id("io.spring.dependency-management") version "1.1.5" id("com.github.ben-manes.versions") version "0.51.0" id("java") @@ -29,17 +29,17 @@ dependencies { implementation("org.springframework.cloud:spring-cloud-starter-openfeign") implementation("com.github.ben-manes.caffeine:caffeine:3.1.8") implementation("org.mariadb.jdbc:mariadb-java-client:3.4.0") - implementation("org.flywaydb:flyway-mysql:10.14.0") - implementation("org.flywaydb:flyway-core:10.14.0") - implementation("io.jsonwebtoken:jjwt-api:0.12.5") + implementation("org.flywaydb:flyway-mysql:10.15.0") + implementation("org.flywaydb:flyway-core:10.15.0") + implementation("io.jsonwebtoken:jjwt-api:0.12.6") implementation("com.github.xMrAfonso:Hangar4J:1.2.3") { exclude(group = "com.google.code.gson", module = "gson") } implementation("com.google.code.gson:gson:2.11.0") implementation("com.github.usefulness:webp-imageio:0.8.0") - runtimeOnly("io.jsonwebtoken:jjwt-impl:0.12.5") - runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.12.5") + runtimeOnly("io.jsonwebtoken:jjwt-impl:0.12.6") + runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.12.6") developmentOnly("org.springframework.boot:spring-boot-devtools") } diff --git a/src/main/java/com/mcbanners/bannerapi/net/upstream/SpigotClient.java b/src/main/java/com/mcbanners/bannerapi/net/upstream/SpigotClient.java index 2ca10fd..de298ee 100644 --- a/src/main/java/com/mcbanners/bannerapi/net/upstream/SpigotClient.java +++ b/src/main/java/com/mcbanners/bannerapi/net/upstream/SpigotClient.java @@ -8,6 +8,10 @@ import org.springframework.stereotype.Component; import org.springframework.web.client.RestClientResponseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + @Component public final class SpigotClient extends BasicHttpClient { public SpigotClient() { @@ -35,12 +39,32 @@ public ResponseEntity getResource(int id) { } public ResponseEntity getAllByAuthor(int id) { - try { - return get(String.format("getResourcesByAuthor&id=%d", id), SpigotResource[].class); - } catch (RestClientResponseException ex) { - Log.error("Failed to load all Spigot Resources by author id %d: %s", id, ex.getMessage()); - ex.printStackTrace(); - return null; + final List resources = new ArrayList<>(); + int page = 1; + + while (true) { + try { + final String url = String.format("getResourcesByAuthor&id=%d&page=%d", id, page); + final ResponseEntity response = get(url, SpigotResource[].class); + + if (response.getBody() == null || response.getBody().length == 0) { + break; + } + + resources.addAll(Arrays.asList(response.getBody())); + + page++; + } catch (RestClientResponseException ex) { + Log.error("Failed to load Spigot Resources by author id %d on page %d: %s", id, page, ex.getMessage()); + ex.printStackTrace(); + return null; + + } } + + final SpigotResource[] resourcesArray = new SpigotResource[resources.size()]; + resources.toArray(resourcesArray); + + return ResponseEntity.ok(resourcesArray); } }