From c969074af3ba24f7304cf78ab9fb95eb52743ba9 Mon Sep 17 00:00:00 2001 From: nea Date: Thu, 1 Jun 2023 15:23:32 +0200 Subject: Fix crash in auto reload when using outside a devenv --- .../kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main/kotlin/moe/nea/firmament') diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt b/src/main/kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt index ff69cd1..e4774f2 100644 --- a/src/main/kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt +++ b/src/main/kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt @@ -22,11 +22,10 @@ object DeveloperFeatures : FirmamentFeature { override val defaultEnabled: Boolean get() = false - val gradleDir by lazy { + val gradleDir = Path.of(".").absolute() .iterate { it.parent } - .find { it.resolve("settings.gradle.kts").exists() }!! - } + .find { it.resolve("settings.gradle.kts").exists() } object TConfig : ManagedConfig("developer") { val autoRebuildResources by toggle("auto-rebuild") { false } @@ -34,7 +33,7 @@ object DeveloperFeatures : FirmamentFeature { @JvmStatic fun hookOnBeforeResourceReload(client: MinecraftClient): CompletableFuture { - val reloadFuture = if (TConfig.autoRebuildResources && isEnabled) { + val reloadFuture = if (TConfig.autoRebuildResources && isEnabled && gradleDir != null) { val builder = ProcessBuilder("./gradlew", ":processResources") builder.directory(gradleDir.toFile()) builder.inheritIO() -- cgit