diff --git a/cloud-minecraft/cloud-fabric/build.gradle.kts b/cloud-minecraft/cloud-fabric/build.gradle.kts index 07372f07..1a8a7ad7 100644 --- a/cloud-minecraft/cloud-fabric/build.gradle.kts +++ b/cloud-minecraft/cloud-fabric/build.gradle.kts @@ -1,3 +1,4 @@ +import net.fabricmc.loom.task.AbstractRunTask import net.ltgt.gradle.errorprone.errorprone plugins { @@ -41,6 +42,19 @@ tasks { links("https://maven.fabricmc.net/docs/yarn-${Versions.fabricMc}+build.${Versions.fabricYarn}/") } } + + withType(AbstractRunTask::class).configureEach { + standardInput = System.`in` + jvmArgumentProviders += CommandLineArgumentProvider { + if (System.getProperty("idea.active")?.toBoolean() == true || // IntelliJ + System.getenv("TERM") != null || // linux terminals + System.getenv("WT_SESSION") != null) { // Windows terminal + listOf("-Dfabric.log.disableAnsi=false") + } else { + listOf() + } + } + } } @@ -49,6 +63,7 @@ dependencies { mappings("net.fabricmc", "yarn", "${Versions.fabricMc}+build.${Versions.fabricYarn}", classifier = "v2") modImplementation("net.fabricmc", "fabric-loader", Versions.fabricLoader) modImplementation(fabricApi.module("fabric-command-api-v1", Versions.fabricApi)) + modImplementation(fabricApi.module("fabric-lifecycle-events-v1", Versions.fabricApi)) modApi(include("me.lucko", "fabric-permissions-api", "0.1-SNAPSHOT")) diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricServerCommandManager.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricServerCommandManager.java index 380c6f78..2d9db08d 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricServerCommandManager.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricServerCommandManager.java @@ -36,6 +36,7 @@ import cloud.commandframework.fabric.data.MultipleEntitySelector; import cloud.commandframework.fabric.data.MultiplePlayerSelector; import cloud.commandframework.fabric.data.SingleEntitySelector; import cloud.commandframework.fabric.data.SinglePlayerSelector; +import cloud.commandframework.fabric.internal.LateRegistrationCatcher; import cloud.commandframework.meta.CommandMeta; import io.leangen.geantyref.TypeToken; import me.lucko.fabric.api.permissions.v0.Permissions; @@ -128,6 +129,11 @@ public final class FabricServerCommandManager extends FabricCommandManager LateRegistrationCatcher.serverStartingCalled = true); + } + + /** + * Get whether at least one server in the current environment has already begun starting. + * + *

This indicates that pre-initialization tasks must have completed.

+ * + * @return whether a server has already started. + */ + public static boolean hasServerAlreadyStarted() { + return LateRegistrationCatcher.serverStartingCalled; + } + +} diff --git a/cloud-minecraft/cloud-fabric/src/main/resources/fabric.mod.json b/cloud-minecraft/cloud-fabric/src/main/resources/fabric.mod.json index 00f3c62d..fbf27abe 100644 --- a/cloud-minecraft/cloud-fabric/src/main/resources/fabric.mod.json +++ b/cloud-minecraft/cloud-fabric/src/main/resources/fabric.mod.json @@ -13,6 +13,12 @@ "license": "MIT", "icon": "assets/cloud/logo.png", + "entrypoints": { + "main": [ + "cloud.commandframework.fabric.internal.LateRegistrationCatcher" + ] + }, + "mixins": [ "cloud.mixins.json" ],