diff options
author | nea <nea@nea.moe> | 2023-07-30 16:31:23 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-07-30 16:31:23 +0200 |
commit | b9a22305dce467764b55b81cd0ae4e8fa6f6990d (patch) | |
tree | 9af1af79c78a2e02f0315a7ee056750b717f0a67 /src/main/kotlin/moe/nea/firmament/Firmament.kt | |
parent | d47f2da4f6289f106d9003ade2e7cd60cb760e2a (diff) | |
download | Firmament-b9a22305dce467764b55b81cd0ae4e8fa6f6990d.tar.gz Firmament-b9a22305dce467764b55b81cd0ae4e8fa6f6990d.tar.bz2 Firmament-b9a22305dce467764b55b81cd0ae4e8fa6f6990d.zip |
Fix overlapping config elements in config overview
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/Firmament.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/Firmament.kt | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/Firmament.kt b/src/main/kotlin/moe/nea/firmament/Firmament.kt index 6564e9b..c3bb0fc 100644 --- a/src/main/kotlin/moe/nea/firmament/Firmament.kt +++ b/src/main/kotlin/moe/nea/firmament/Firmament.kt @@ -27,6 +27,7 @@ import io.ktor.client.plugins.compression.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.plugins.logging.* import io.ktor.serialization.kotlinx.json.* +import java.lang.Exception import java.nio.file.Files import java.nio.file.Path import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback @@ -39,6 +40,7 @@ import net.fabricmc.loader.api.metadata.ModMetadata import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger import org.freedesktop.dbus.connections.impl.DBusConnectionBuilder +import org.freedesktop.dbus.exceptions.DBusException import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -98,8 +100,12 @@ object Firmament { } val globalJob = Job() - val dbusConnection = DBusConnectionBuilder.forSessionBus() - .build() + val dbusConnection = try { + DBusConnectionBuilder.forSessionBus() + .build() + } catch (e: Exception) { + null + } val coroutineScope = CoroutineScope(EmptyCoroutineContext + CoroutineName("Firmament")) + SupervisorJob(globalJob) @@ -117,12 +123,16 @@ object Firmament { @JvmStatic fun onClientInitialize() { - dbusConnection.requestBusName("moe.nea.firmament") + try { + dbusConnection?.exportObject(FirmamentDbusObject) + dbusConnection?.requestBusName("moe.nea.firmament") + } catch (e: DBusException) { + // :( + } var tick = 0 ClientTickEvent.CLIENT_POST.register(ClientTickEvent.Client { instance -> TickEvent.publish(TickEvent(tick++)) }) - dbusConnection.exportObject(FirmamentDbusObject) IDataHolder.registerEvents() RepoManager.initialize() SBData.init() |