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/NotEnoughUpdates.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/NotEnoughUpdates.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt b/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt index 1986339..a7a8a19 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt @@ -3,6 +3,7 @@ package moe.nea.notenoughupdates import com.mojang.brigadier.Command import com.mojang.brigadier.CommandDispatcher import io.github.cottonmc.cotton.gui.client.CottonClientScreen +import io.github.moulberry.repo.NEURepositoryException import io.ktor.client.* import io.ktor.client.plugins.* import io.ktor.client.plugins.contentnegotiation.* @@ -18,6 +19,7 @@ import net.fabricmc.api.ModInitializer import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents import net.fabricmc.loader.api.FabricLoader import net.fabricmc.loader.api.Version import net.fabricmc.loader.api.metadata.ModMetadata @@ -67,14 +69,20 @@ object NotEnoughUpdates : ModInitializer, ClientModInitializer { ) { dispatcher.register(ClientCommandManager.literal("neureload").executes { it.source.sendFeedback(Component.literal("Reloading repository from disk. This may lag a bit.")) - RepoManager.neuRepo.reload() + try { + RepoManager.reload() + } catch (exc: NEURepositoryException) { + it.source.sendError(Component.literal("There has been an error reloading the repository. Please try again. IF this persists, delete the .notenoughupdates folder in your mincraft folder")) + exc.printStackTrace() + } Command.SINGLE_SUCCESS }) - dispatcher.register(ClientCommandManager.literal("neu") - .then(ClientCommandManager.literal("repo").executes { - setScreenLater(CottonClientScreen(RepoManagementGui())) - Command.SINGLE_SUCCESS - }) + dispatcher.register( + ClientCommandManager.literal("neu") + .then(ClientCommandManager.literal("repo").executes { + setScreenLater(CottonClientScreen(RepoManagementGui())) + Command.SINGLE_SUCCESS + }) ) } @@ -82,6 +90,12 @@ object NotEnoughUpdates : ModInitializer, ClientModInitializer { RepoManager.initialize() ConfigHolder.registerEvents() ClientCommandRegistrationCallback.EVENT.register(this::registerCommands) + ClientLifecycleEvents.CLIENT_STOPPING.register(ClientLifecycleEvents.ClientStopping { + runBlocking { + logger.info("Shutting down NEU coroutines") + globalJob.cancel() + } + }) } override fun onInitializeClient() { |