aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt
diff options
context:
space:
mode:
Diffstat (limited to 'mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt')
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt5
1 files changed, 4 insertions, 1 deletions
diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt
index 93bb453..42a1f42 100644
--- a/mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt
+++ b/mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt
@@ -14,6 +14,7 @@ import java.util.concurrent.CompletableFuture
class ExternalDataProvider @Inject constructor(
val requestUtil: RequestUtil
) {
+ // TODO: Save all the data locally, so in case of a failed request older versions can be used
fun createAuxillaryDataRequest(path: String): Request {
return requestUtil.createRequest("https://github.com/nea89o/ledger-auxiliary-data/raw/refs/heads/master/$path")
@@ -22,7 +23,9 @@ class ExternalDataProvider @Inject constructor(
private val itemNameFuture: CompletableFuture<Map<String, String>> = CompletableFuture.supplyAsync {
val request = createAuxillaryDataRequest("data/item_names.json")
val response = request.execute(requestUtil)
- val nameMap = response.json(GsonUtil.typeToken<Map<String, String>>())
+ val nameMap =
+ response?.json(GsonUtil.typeToken<Map<String, String>>())
+ ?: mapOf()
return@supplyAsync nameMap
}