From 2a632664a33a5fb461dcf4bb5cda24a050a8614e Mon Sep 17 00:00:00 2001 From: Paint_Ninja Date: Sun, 18 Feb 2024 13:00:05 +0000 Subject: [PATCH 1/3] Improve support for `clientSideOnly` in mods.toml --- src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt | 5 ++++- .../forge/completion/ModsTomlCompletionContributor.kt | 1 + .../forge/inspections/ModsTomlValidationInspection.kt | 10 ++++++++++ .../kotlin/platform/forge/ModsTomlCompletionTest.kt | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt b/src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt index fa60abab7..4cd7c1562 100644 --- a/src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt +++ b/src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt @@ -48,6 +48,9 @@ license="All rights reserved" showAsResourcePack=false # A URL to refer people to when problems occur with this mod. issueTrackerURL="http://my.issue.tracker/" +# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN), +# set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers. +clientSideOnly=false # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] # The modid of the mod. @@ -74,7 +77,7 @@ authors="Love, Cheese and small house plants" # IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. # NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. # IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. -displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) +displayTest="MATCH_VERSION" # if nothing is specified, MATCH_VERSION is the default when clientSideOnly=false, otherwise IGNORE_ALL_VERSION when clientSideOnly=true (#optional) # The description text for the mod (multi line!) description=''' diff --git a/src/main/kotlin/toml/platform/forge/completion/ModsTomlCompletionContributor.kt b/src/main/kotlin/toml/platform/forge/completion/ModsTomlCompletionContributor.kt index 7b87c4ac7..45de2e1f2 100644 --- a/src/main/kotlin/toml/platform/forge/completion/ModsTomlCompletionContributor.kt +++ b/src/main/kotlin/toml/platform/forge/completion/ModsTomlCompletionContributor.kt @@ -58,6 +58,7 @@ class ModsTomlCompletionContributor : CompletionContributor() { extendBooleanValues("showAsResourcePack") extendBooleanValues("logoBlur") extendBooleanValues("mandatory") + extendBooleanValues("clientSideOnly") } private fun extendKnownValues(key: String, values: Set) = diff --git a/src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt b/src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt index 44a7170d8..a9e506ba2 100644 --- a/src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt +++ b/src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt @@ -112,6 +112,16 @@ class ModsTomlValidationInspection : LocalInspectionTool() { holder.registerProblem(value, TextRange(1, endOffset), "Order $order does not exist") } } + "clientSideOnly" -> { + val value = keyValue.value ?: return + val forgeVersion = runCatching { + keyValue.findMcpModule()?.getSettings()?.platformVersion?.let(SemanticVersion::parse) + }.getOrNull() + val minVersion = ForgeConstants.CLIENT_ONLY_MANIFEST_VERSION + if (forgeVersion != null && forgeVersion < minVersion) { + holder.registerProblem(keyValue.key, "ClientSideOnly is only available since $minVersion") + } + } } } diff --git a/src/test/kotlin/platform/forge/ModsTomlCompletionTest.kt b/src/test/kotlin/platform/forge/ModsTomlCompletionTest.kt index 5c222c6c1..a62d2fafe 100644 --- a/src/test/kotlin/platform/forge/ModsTomlCompletionTest.kt +++ b/src/test/kotlin/platform/forge/ModsTomlCompletionTest.kt @@ -53,6 +53,7 @@ class ModsTomlCompletionTest : BasePlatformTestCase() { "license", "showAsResourcePack", "issueTrackerURL", + "clientSideOnly", ) } From 2e6e938ad27349cddbfe355a0d204ffc6b8df303 Mon Sep 17 00:00:00 2001 From: Paint_Ninja Date: Sun, 18 Feb 2024 15:42:26 +0000 Subject: [PATCH 2/3] Fix comment --- src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt b/src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt index 4cd7c1562..800a6cc2f 100644 --- a/src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt +++ b/src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt @@ -48,8 +48,7 @@ license="All rights reserved" showAsResourcePack=false # A URL to refer people to when problems occur with this mod. issueTrackerURL="http://my.issue.tracker/" -# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN), -# set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers. +# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN), set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers. clientSideOnly=false # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] From 4d06ccd2c31e293f221879068e001b3c7c101058 Mon Sep 17 00:00:00 2001 From: Paint_Ninja Date: Sun, 18 Feb 2024 21:26:39 +0000 Subject: [PATCH 3/3] Update ModsTomlValidationInspection.kt --- .../platform/forge/inspections/ModsTomlValidationInspection.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt b/src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt index a9e506ba2..d5490af52 100644 --- a/src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt +++ b/src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt @@ -113,7 +113,6 @@ class ModsTomlValidationInspection : LocalInspectionTool() { } } "clientSideOnly" -> { - val value = keyValue.value ?: return val forgeVersion = runCatching { keyValue.findMcpModule()?.getSettings()?.platformVersion?.let(SemanticVersion::parse) }.getOrNull()