diff options
author | nea <romangraef@gmail.com> | 2022-08-04 04:26:51 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-08-04 04:26:51 +0200 |
commit | 05a4a5b3817ea3e70662d3834fd56a1b249fa70e (patch) | |
tree | a02169948679be5a748a3255e99738133bf8f83c /src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt | |
parent | c83890afc8304fc0a1b1d0ea8da791c6d9b90439 (diff) | |
download | Firmament-05a4a5b3817ea3e70662d3834fd56a1b249fa70e.tar.gz Firmament-05a4a5b3817ea3e70662d3834fd56a1b249fa70e.tar.bz2 Firmament-05a4a5b3817ea3e70662d3834fd56a1b249fa70e.zip |
screen padding
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt index 70ee18e..375b2bb 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt @@ -1,6 +1,7 @@ package moe.nea.notenoughupdates.repo import io.github.moulberry.repo.NEURepository +import io.github.moulberry.repo.NEURepositoryException import kotlinx.coroutines.launch import kotlinx.serialization.Serializable import kotlinx.serialization.serializer @@ -9,15 +10,16 @@ import moe.nea.notenoughupdates.NotEnoughUpdates.logger import moe.nea.notenoughupdates.util.ConfigHolder import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents import net.minecraft.client.Minecraft +import net.minecraft.network.chat.Component import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Config) { @Serializable data class Config( - var user: String = "NotEnoughUpdates", - var repo: String = "NotEnoughUpdates-REPO", - var autoUpdate: Boolean = true, - var branch: String = "dangerous", + var user: String = "NotEnoughUpdates", + var repo: String = "NotEnoughUpdates-REPO", + var autoUpdate: Boolean = true, + var branch: String = "dangerous", ) var recentlyFailedToUpdateItemList = false @@ -33,7 +35,9 @@ object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Co } private fun trySendClientboundUpdateRecipesPacket(): Boolean { - return Minecraft.getInstance().level != null && Minecraft.getInstance().connection?.handleUpdateRecipes(ClientboundUpdateRecipesPacket(mutableListOf())) != null + return Minecraft.getInstance().level != null && Minecraft.getInstance().connection?.handleUpdateRecipes( + ClientboundUpdateRecipesPacket(mutableListOf()) + ) != null } init { @@ -46,7 +50,18 @@ object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Co fun launchAsyncUpdate() { NotEnoughUpdates.coroutineScope.launch { RepoDownloadManager.downloadUpdate() + reload() + } + } + + fun reload() { + try { neuRepo.reload() + } catch (exc: NEURepositoryException) { + Minecraft.getInstance().player?.sendSystemMessage( + Component.literal("Failed to reload repository. This will result in some mod features not working.") + ) + exc.printStackTrace() } } @@ -54,7 +69,7 @@ object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Co if (config.autoUpdate) { launchAsyncUpdate() } else { - neuRepo.reload() + reload() } } |