From 63043628cc44f9f1bbb5149eded5f8ec1917a597 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Sun, 24 Sep 2023 06:55:17 -0500 Subject: [PATCH] Setup publishing --- build.gradle.kts | 5 ++ .../gui/screen/WorldHostConfigScreen.java | 24 ++++--- version.gradle.kts | 67 +++++++++++++------ 3 files changed, 63 insertions(+), 33 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3ea8018..0433af7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -50,3 +50,8 @@ preprocess { // } } +gradle.projectsEvaluated { + subprojects.asSequence().zipWithNext().forEach { (left, right) -> + right.tasks.named("modrinth").get().mustRunAfter(left.tasks.named("modrinth")) + } +} diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostConfigScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostConfigScreen.java index 6d7f220..48712e0 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostConfigScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostConfigScreen.java @@ -33,40 +33,40 @@ public class WorldHostConfigScreen extends WorldHostScreen { private static final ConfigOption[] OPTIONS = { new EnumOption<>( - "world-host.config.onlineStatusLocation", + "onlineStatusLocation", WorldHostConfig::getOnlineStatusLocation, WorldHostConfig::setOnlineStatusLocation ), new YesNoOption( - "world-host.config.enableFriends", + "enableFriends", WorldHostConfig::isEnableFriends, WorldHostConfig::setEnableFriends ), new YesNoOption( - "world-host.config.enableReconnectionToasts", + "enableReconnectionToasts", WorldHostConfig::isEnableReconnectionToasts, WorldHostConfig::setEnableReconnectionToasts ), new YesNoOption( - "world-host.config.noUPnP", + "noUPnP", WorldHostConfig::isNoUPnP, WorldHostConfig::setNoUPnP, WorldHost::scanUpnp ), new YesNoOption( - "world-host.config.useShortIp", + "useShortIp", WorldHostConfig::isUseShortIp, WorldHostConfig::setUseShortIp ), new YesNoOption( - "world-host.config.showOutdatedWorldHost", + "showOutdatedWorldHost", WorldHostConfig::isShowOutdatedWorldHost, WorldHostConfig::setShowOutdatedWorldHost ), new YesNoOption( - "world-host.config.shareButton", + "shareButton", WorldHostConfig::isShareButton, WorldHostConfig::setShareButton ), new YesNoOption( - "world-host.config.allowFriendRequests", + "allowFriendRequests", WorldHostConfig::isAllowFriendRequests, WorldHostConfig::setAllowFriendRequests ), new YesNoOption( - "world-host.config.announceFriendsOnline", + "announceFriendsOnline", WorldHostConfig::isAnnounceFriendsOnline, WorldHostConfig::setAnnounceFriendsOnline ), }; @@ -183,7 +183,7 @@ private interface ConfigOption { } private record YesNoOption( - String translationBase, + String name, Function get, BiConsumer set, @Nullable Runnable onSet @@ -198,6 +198,7 @@ private record YesNoOption( @Override public Button createButton(int x, int y, int width, int height) { + final String translationBase = "world-host.config." + name; final String tooltipKey = translationBase + ".tooltip"; final YesNoButton button = new YesNoButton( x, y, width, height, @@ -217,7 +218,7 @@ public Button createButton(int x, int y, int width, int height) { } private record EnumOption & StringRepresentable>( - String translationBase, + String name, Function get, BiConsumer set, E... typeGetter @@ -231,6 +232,7 @@ private record EnumOption & StringRepresentable>( @Override public Button createButton(int x, int y, int width, int height) { + final String translationBase = "world-host.config." + name; final String tooltipKey = translationBase + ".tooltip"; @SuppressWarnings("unchecked") final EnumButton button = new EnumButton<>( x, y, width, height, diff --git a/version.gradle.kts b/version.gradle.kts index 44f1d2e..6492661 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -1,3 +1,4 @@ +import com.modrinth.minotaur.ModrinthExtension import groovy.lang.GroovyObjectSupport import net.raphimc.javadowngrader.gradle.task.DowngradeSourceSetTask import xyz.wagyourtail.unimined.api.minecraft.MinecraftConfig @@ -14,6 +15,7 @@ plugins { id("xyz.deftu.gradle.preprocess") id("xyz.wagyourtail.unimined") id("com.github.johnrengelman.shadow") version "8.1.1" + id("com.modrinth.minotaur") version "2.+" } @@ -276,27 +278,48 @@ preprocess { keywords.value(keywords.get()) keywords.put(".json", keywords.get().getValue(".json").copy(eval = "//??")) } -// TODO: fix -// -//toolkitReleases { -// modrinth { -// projectId.set("world-host") -// } -// rootProject.file("changelogs/${modData.version}.md").let { -// if (it.exists()) { -// changelogFile.set(it) -// } -// } -// describeFabricWithQuilt.set(true) -// useSourcesJar.set(true) -// if (mcData.isFabric) { -// if (mcVersion == 1_19_04) { -// gameVersions.add("23w13a_or_b") -// } else if (mcVersion == 1_20_01) { -// gameVersions.add("1.20") -// } -// } -//} + +//println("Parallel: ${gradle.startParameter.isParallelProjectExecutionEnabled}") + +modrinth { + val isStaging = (project.properties["modrinth.staging"] as String?)?.toBoolean() + ?: (System.getenv("MODRINTH_STAGING") == "1") + token.set( + project.properties["modrinth.token${".staging".takeIf { isStaging }}"] as String? + ?: System.getenv("MODRINTH_TOKEN${"_STAGING".takeIf { isStaging }}") + ) + if (isStaging) { + apiUrl.set(ModrinthExtension.STAGING_API_URL) + } + projectId.set("world-host") + versionNumber.set(version.toString()) + versionName.set("[${if (loaderName == "fabric") "Fabric/Quilt" else "Forge"} $mcVersionString] World Host $vers") + uploadFile.set(tasks.shadowJar) + additionalFiles.add(tasks.named("sourcesJar")) + gameVersions.add(mcVersionString) + if (mcVersion == 1_19_04) { + gameVersions.add("23w13a_or_b") + } else if (mcVersion == 1_20_01) { + gameVersions.add("1.20") + } + loaders.add(loaderName) + if (loaderName == "fabric") { + loaders.add("quilt") + } + dependencies { + if (loaderName == "fabric") { + optional.project(if (isStaging) "fred-3" else "modmenu") + } + } + rootProject.file("changelogs/$version.md").let { + if (it.exists()) { + println("Setting changelog file to $it") + changelog.set(it.readText()) + } else { + println("Changelog file $it does not exist!") + } + } +} tasks.shadowJar { configurations = listOf(shade) @@ -337,7 +360,7 @@ tasks.processResources { "*.mixins.json" )) { expand(mapOf( - "version" to project.version, + "version" to vers, "mc_version" to mcVersionString, "java_version" to "JAVA_${mcJavaVersion.majorVersion}" ))