Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Forge clientSideOnly support #2236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ 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.
Expand All @@ -74,7 +76,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='''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ModsTomlCompletionContributor : CompletionContributor() {
extendBooleanValues("showAsResourcePack")
extendBooleanValues("logoBlur")
extendBooleanValues("mandatory")
extendBooleanValues("clientSideOnly")
}

private fun extendKnownValues(key: String, values: Set<String>) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ class ModsTomlValidationInspection : LocalInspectionTool() {
holder.registerProblem(value, TextRange(1, endOffset), "Order $order does not exist")
}
}
"clientSideOnly" -> {
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")
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/platform/forge/ModsTomlCompletionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ModsTomlCompletionTest : BasePlatformTestCase() {
"license",
"showAsResourcePack",
"issueTrackerURL",
"clientSideOnly",
)
}

Expand Down
Loading