diff options
author | Linnea Gräf <nea@nea.moe> | 2025-01-30 19:41:44 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-01-30 19:41:44 +0100 |
commit | e51a59636129c35b58dbdda83b141b539a87e6fe (patch) | |
tree | 8f5161f2bc9db5f70e03a41cb38bd01ace6db525 /mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt | |
parent | 1e3071f441685ae0142ba989b181d26a7b3b60ab (diff) | |
download | LocalTransactionLedger-e51a59636129c35b58dbdda83b141b539a87e6fe.tar.gz LocalTransactionLedger-e51a59636129c35b58dbdda83b141b539a87e6fe.tar.bz2 LocalTransactionLedger-e51a59636129c35b58dbdda83b141b539a87e6fe.zip |
fix: Failed requests in auxilary data provider crashing the game
Fixes: https://github.com/nea89o/LocalTransactionLedger/issues/21
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.kt | 5 |
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 } |