diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt new file mode 100644 index 0000000..f3d53e8 --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt @@ -0,0 +1,31 @@ +package moe.nea.notenoughupdates.repo + +import io.github.moulberry.repo.NEURepository +import kotlinx.coroutines.launch +import moe.nea.notenoughupdates.NotEnoughUpdates +import moe.nea.notenoughupdates.NotEnoughUpdates.logger +import net.minecraft.client.Minecraft +import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket + +object RepoManager { + + + val neuRepo: NEURepository = NEURepository.of(RepoDownloadManager.repoSavedLocation).apply { + registerReloadListener(ItemCache) + registerReloadListener { + if (Minecraft.getInstance().connection?.handleUpdateRecipes(ClientboundUpdateRecipesPacket(mutableListOf())) == null) { + logger.warn("Failed to issue a ClientboundUpdateRecipesPacket (to reload REI). This may lead to an outdated item list.") + } + } + } + + + fun launchAsyncUpdate() { + NotEnoughUpdates.coroutineScope.launch { + if (RepoDownloadManager.downloadUpdate()) { + neuRepo.reload() + } + } + } + +} |