Skip to content

Commit

Permalink
Setup publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Sep 24, 2023
1 parent 90c49b2 commit 6304362
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 33 deletions.
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ preprocess {
// }
}

gradle.projectsEvaluated {
subprojects.asSequence().zipWithNext().forEach { (left, right) ->
right.tasks.named("modrinth").get().mustRunAfter(left.tasks.named("modrinth"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
};
Expand Down Expand Up @@ -183,7 +183,7 @@ private interface ConfigOption {
}

private record YesNoOption(
String translationBase,
String name,
Function<WorldHostConfig, Boolean> get,
BiConsumer<WorldHostConfig, Boolean> set,
@Nullable Runnable onSet
Expand All @@ -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,
Expand All @@ -217,7 +218,7 @@ public Button createButton(int x, int y, int width, int height) {
}

private record EnumOption<E extends Enum<E> & StringRepresentable>(
String translationBase,
String name,
Function<WorldHostConfig, E> get,
BiConsumer<WorldHostConfig, E> set,
E... typeGetter
Expand All @@ -231,6 +232,7 @@ private record EnumOption<E extends Enum<E> & 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<E> button = new EnumButton<>(
x, y, width, height,
Expand Down
67 changes: 45 additions & 22 deletions version.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.+"
}


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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}"
))
Expand Down

0 comments on commit 6304362

Please sign in to comment.