Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
Develop

See merge request Griefed/ServerPackCreator!635
  • Loading branch information
Griefed committed Jan 24, 2025
2 parents aab0deb + 6e7b4fc commit 8f565d6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/devbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ jobs:
cp checksum.txt continuous/
- name: Upload to GitHub Releases
uses: "marvinpinto/action-automatic-releases@latest"
uses: "slord399/action-automatic-releases@v1.0.1"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "continuous"
prerelease: true
title: "Development Build"
files: |
continuous/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class ApiProperties(propertiesFile: File = File("serverpackcreator.properties"))
"chat_heads-", //https://www.curseforge.com/minecraft/mc-mods/chat-heads
"cherishedworlds-", //https://www.curseforge.com/minecraft/mc-mods/cherished-worlds
"cirback-1.0-", //Gone? Reduces to atoms?
"citresewn-", //https://www.curseforge.com/minecraft/mc-mods/forge-cit
"classicbar-", //https://www.curseforge.com/minecraft/mc-mods/classic-bars
"clickadv-", //https://www.curseforge.com/minecraft/mc-mods/clickable-advancements
"clienttweaks-", //https://www.curseforge.com/minecraft/mc-mods/client-tweaks
Expand Down Expand Up @@ -377,6 +378,7 @@ class ApiProperties(propertiesFile: File = File("serverpackcreator.properties"))
"fancymenu_video_extension", //https://www.curseforge.com/minecraft/mc-mods/video-extension-for-fancymenu-forge
"fast-ip-ping-", //https://www.curseforge.com/minecraft/mc-mods/fast-ip-ping
"firstperson-", //https://www.curseforge.com/minecraft/mc-mods/first-person-model
"flerovium-", //https://www.curseforge.com/minecraft/mc-mods/flerovium
"flickerfix-", //https://www.curseforge.com/minecraft/mc-mods/flickerfix
"fm_audio_extension_", //https://www.curseforge.com/minecraft/mc-mods/audio-extension-for-fancymenu-forge
"fabricmod_VoxelMap-", //https://www.curseforge.com/minecraft/mc-mods/voxelmap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,19 @@ class ServerPackHandler(
} catch (ignored: IOException) {
}
acquired = mutableListOf()
for (mod in compileModList(clientDir.absolutePath, clientMods, whitelist, minecraftVersion, modloader)) {
val mods = compileModList(clientDir.absolutePath, clientMods, whitelist, minecraftVersion, modloader)
for (mod in mods.first) {
acquired.add(ServerPackFile(mod, File(serverDir, mod.name)))
}
var destinationName: String
for (disabled in mods.second) {
destinationName = if (disabled.name.endsWith("disabled")) {
disabled.name
} else {
"${disabled.name}.disabled"
}
acquired.add(ServerPackFile(disabled, File(serverDir, destinationName)))
}
processed = runFilters(acquired, inclusion, modpackDir)
serverPackFiles.addAll(processed)
}
Expand Down Expand Up @@ -669,7 +679,7 @@ class ServerPackHandler(
for (file in acquired) {
if (file.sourceFile.absolutePath.replace(modpackDir + File.separator, "").matches(inclusionFilter)) {
processed.add(file)
log.debug("$file matched Inclusion-Filter $inclusionFilter.")
log.info("Including ${file.sourceFile} due to inclusion-filter $inclusionFilter.")
}
}
} else {
Expand All @@ -679,7 +689,7 @@ class ServerPackHandler(
processed.removeIf { file ->
val source = file.sourceFile.absolutePath.replace(modpackDir + File.separator, "")
return@removeIf if (source.matches(exclusionFilter)) {
log.debug("${file.sourceFile} matched Inclusion-Filter $exclusionFilter.")
log.info("Excluding ${file.sourceFile} due to exclusion-filter $exclusionFilter.")
true
} else {
false
Expand Down Expand Up @@ -1058,51 +1068,53 @@ class ServerPackHandler(
whitelistStrings: List<String>,
minecraftVersion: String,
modloader: String
): List<File> {
): Pair<List<File>,List<File>> {
log.info("Preparing a list of mods to include in server pack...")
val filesInModsDir: Collection<File> = File(modsDir).filteredWalk(modFileEndings, FilterType.ENDS_WITH, FileWalkDirection.TOP_DOWN, recursive = false)
val modsInModpack = TreeSet(filesInModsDir)
val autodiscoveredClientMods: MutableList<File> = ArrayList(100)
val modsForServerPack = TreeSet(filesInModsDir)
val disabledMods = TreeSet<File>()
val autoDiscoveredClientMods: MutableList<File> = ArrayList(100)

// Check whether scanning mods for sideness is activated.
if (apiProperties.isAutoExcludingModsEnabled) {
val scanningStopWatch = SimpleStopWatch().start()
when (modloader) {
"LegacyFabric", "Fabric" -> autodiscoveredClientMods.addAll(modScanner.fabricScanner.scan(filesInModsDir))
"LegacyFabric", "Fabric" -> autoDiscoveredClientMods.addAll(modScanner.fabricScanner.scan(filesInModsDir))

"Forge" -> if (minecraftVersion.split(".").dropLastWhile { it.isEmpty() }
.toTypedArray()[1].toInt() > 12) {
autodiscoveredClientMods.addAll(modScanner.forgeTomlScanner.scan(filesInModsDir))
autoDiscoveredClientMods.addAll(modScanner.forgeTomlScanner.scan(filesInModsDir))
} else {
autodiscoveredClientMods.addAll(modScanner.forgeAnnotationScanner.scan(filesInModsDir))
autoDiscoveredClientMods.addAll(modScanner.forgeAnnotationScanner.scan(filesInModsDir))
}

"NeoForge" -> {
if (SemanticVersionComparator.compareSemantics("1.20.5", minecraftVersion, Comparison.EQUAL_OR_NEW)) {
log.debug("Scanning using NeoForge scanner.")
autodiscoveredClientMods.addAll(modScanner.neoForgeTomlScanner.scan(filesInModsDir))
autoDiscoveredClientMods.addAll(modScanner.neoForgeTomlScanner.scan(filesInModsDir))
} else {
log.debug("Scanning using Forge scanner.")
autodiscoveredClientMods.addAll(modScanner.forgeTomlScanner.scan(filesInModsDir))
autoDiscoveredClientMods.addAll(modScanner.forgeTomlScanner.scan(filesInModsDir))
}
}

"Quilt" -> {
val discoMods = TreeSet<File>()
discoMods.addAll(modScanner.fabricScanner.scan(filesInModsDir))
discoMods.addAll(modScanner.quiltScanner.scan(filesInModsDir))
autodiscoveredClientMods.addAll(discoMods)
autoDiscoveredClientMods.addAll(discoMods)
discoMods.clear()
}
}

// Exclude scanned mods from copying if said functionality is enabled.
if (autodiscoveredClientMods.isNotEmpty()) {
log.info("Automatically detected mods: ${autodiscoveredClientMods.size}")
for (discoveredMod in autodiscoveredClientMods) {
modsInModpack.removeIf {
if (autoDiscoveredClientMods.isNotEmpty()) {
log.info("Automatically detected mods: ${autoDiscoveredClientMods.size}")
for (discoveredMod in autoDiscoveredClientMods) {
modsForServerPack.removeIf {
if (it.name.contains(discoveredMod.name)) {
log.warn("Automatically excluding mod: ${discoveredMod.name}")
disabledMods.add(it)
return@removeIf true
} else {
return@removeIf false
Expand All @@ -1124,7 +1136,7 @@ class ServerPackHandler(
if (exclusionStrings.isNotEmpty()) {
log.info("Performing ${apiProperties.exclusionFilter}-type checks for user-specified clientside-only mod exclusion.")
for (userSpecifiedExclusion in exclusionStrings) {
modsInModpack.removeIf { modToCheck ->
modsForServerPack.removeIf { modToCheck ->
val excluded: Boolean
val modName = modToCheck.name
excluded = when (apiProperties.exclusionFilter) {
Expand All @@ -1140,14 +1152,16 @@ class ServerPackHandler(
}
if (excluded) {
log.info("Excluding ${modToCheck.name}. It matched clientside-mod entry: $userSpecifiedExclusion")
disabledMods.add(modToCheck)
}
excluded
}
}
} else {
log.warn("User specified no clientside-only mods.")
}
return ArrayList(modsInModpack)

return Pair(modsForServerPack.toList(), disabledMods.toList())
}

/**
Expand Down
Loading

0 comments on commit 8f565d6

Please sign in to comment.