aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt')
-rw-r--r--src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt43
1 files changed, 0 insertions, 43 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt b/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt
deleted file mode 100644
index 93bb453..0000000
--- a/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-package moe.nea.ledger.modules
-
-import moe.nea.ledger.events.InitializationComplete
-import moe.nea.ledger.events.SupplyDebugInfo
-import moe.nea.ledger.utils.GsonUtil
-import moe.nea.ledger.utils.di.Inject
-import moe.nea.ledger.utils.network.Request
-import moe.nea.ledger.utils.network.RequestUtil
-import net.minecraftforge.common.MinecraftForge
-import net.minecraftforge.fml.common.eventhandler.Event
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import java.util.concurrent.CompletableFuture
-
-class ExternalDataProvider @Inject constructor(
- val requestUtil: RequestUtil
-) {
-
- fun createAuxillaryDataRequest(path: String): Request {
- return requestUtil.createRequest("https://github.com/nea89o/ledger-auxiliary-data/raw/refs/heads/master/$path")
- }
-
- 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>>())
- return@supplyAsync nameMap
- }
-
- lateinit var itemNames: Map<String, String>
-
- class DataLoaded(val provider: ExternalDataProvider) : Event()
-
- @SubscribeEvent
- fun onDebugData(debugInfo: SupplyDebugInfo) {
- debugInfo.record("externalItemsLoaded", itemNameFuture.isDone && !itemNameFuture.isCompletedExceptionally)
- }
-
- @SubscribeEvent
- fun onInitComplete(event: InitializationComplete) {
- itemNames = itemNameFuture.join()
- MinecraftForge.EVENT_BUS.post(DataLoaded(this))
- }
-} \ No newline at end of file