From e51a59636129c35b58dbdda83b141b539a87e6fe Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 30 Jan 2025 19:41:44 +0100 Subject: fix: Failed requests in auxilary data provider crashing the game Fixes: https://github.com/nea89o/LocalTransactionLedger/issues/21 --- mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mod/src/main/kotlin/moe/nea/ledger/modules') 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> = CompletableFuture.supplyAsync { val request = createAuxillaryDataRequest("data/item_names.json") val response = request.execute(requestUtil) - val nameMap = response.json(GsonUtil.typeToken>()) + val nameMap = + response?.json(GsonUtil.typeToken>()) + ?: mapOf() return@supplyAsync nameMap } -- cgit