Skip to content

Commit

Permalink
Merge branch 'pr/1'
Browse files Browse the repository at this point in the history
  • Loading branch information
darksaid98 committed May 20, 2024
2 parents d13247e + cea06f6 commit 776d678
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 29 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- uses: gradle/gradle-build-action@v2
with:
arguments: build
- uses: actions/upload-artifact@v3
with:
name: jar
path: build/libs
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = 'atm.bloodworkxgaming'
version = '2.3.1'
version = '2.4.0'

sourceCompatibility = 1.8

Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions server-setup-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ install:
# Whether to install the Loader (Forge or Fabric) or not, should always be true unless you only want to install the pack
installLoader: true

# Whether to install the Pack from supplied link or zipfile or just run an already installed pack
# Will download mods from manifest or minecraftinstance.json depending on modpackformat
installPack: true

# Sponge bootstrapper jar URL
# Only needed if you have spongefix enabled
spongeBootstrapper: https://github.com/simon816/SpongeBootstrap/releases/download/v0.7.1/SpongeBootstrap-0.7.1.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ServerStarter(args: Array<String>) {
info(" This jar will launch a Minecraft Forge/Fabric Modded server")
info("")
info(ansi().a(" Github: ").fgBrightBlue().a("https://github.com/BloodyMods/ServerStarter"))
info(ansi().a(" Discord: ").fgBrightBlue().a("https://discord.gg/A3c5YfV"))
info(ansi().a(" Discord: ").fgBrightBlue().a("https://discord.gg/enigmatica"))
info("")
info(ansi().a("You are playing ").fgGreen().a(config.modpack.name))
info("Starting to install/launch the server, lean back!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ data class InstallConfig(

var checkFolder: Boolean = false,
var installLoader: Boolean = false,
var installPack: Boolean = true,

var spongeBootstrapper: String = "",
var connectTimeout: Long = 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ abstract class AbstractZipbasedPackType(private val configFile: ConfigFile, prot
protected val basePath = configFile.install.baseInstallPath

override fun installPack() {
if (configFile.install.modpackUrl.isNotEmpty()) {
val url = configFile.install.modpackUrl
File(basePath).mkdirs()

try {
try {
if (configFile.install.installPack && configFile.install.modpackUrl.isNotEmpty()) {
val url = configFile.install.modpackUrl
File(basePath).mkdirs()
val patterns = configFile.install.ignoreFiles
.map {
val s = if (it.startsWith("glob:") || it.startsWith("regex:"))
Expand All @@ -29,11 +28,10 @@ abstract class AbstractZipbasedPackType(private val configFile: ConfigFile, prot
}

handleZip(obtainZipFile(url), patterns)
postProcessing()
} catch (e: IOException) {
ServerStarter.LOGGER.error("Error while installing pack", e)
throw e
}
postProcessing()
} catch (e: IOException) {
ServerStarter.LOGGER.error("Error while installing pack", e)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,63 @@ open class CursePackType(private val configFile: ConfigFile, internetManager: In
@Throws(IOException::class)
override fun postProcessing() {
val mods = ArrayList<ModEntryRaw>()
var manifest = true
var file = File(basePath + "manifest.json")
if(!file.exists()) {
file = File(basePath + "minecraftinstance.json")
manifest = false
}
if(!file.exists()){
LOGGER.error("No Manifest or minecraftinstance json found. Skipping mod downloads")
return
}

InputStreamReader(FileInputStream(File(basePath + "manifest.json")), "utf-8").use { reader ->
InputStreamReader(FileInputStream(file), "utf-8").use { reader ->
val json = JsonParser().parse(reader).asJsonObject
LOGGER.info("manifest JSON Object: $json", true)
val mcObj = json.getAsJsonObject("minecraft")
if (manifest)
{
val mcObj = json.getAsJsonObject("minecraft")

if (mcVersion.isEmpty()) {
mcVersion = mcObj.getAsJsonPrimitive("version").asString
}
if (mcVersion.isEmpty()) {
mcVersion = mcObj.getAsJsonPrimitive("version").asString
}

// gets the forge version
if (forgeVersion.isEmpty()) {
val loaders = mcObj.getAsJsonArray("modLoaders")
if (loaders.size() > 0) {
forgeVersion = loaders[0].asJsonObject.getAsJsonPrimitive("id").asString.substring(6)
// gets the forge version
if (forgeVersion.isEmpty()) {
val loaders = mcObj.getAsJsonArray("modLoaders")
if (loaders.size() > 0) {
forgeVersion = loaders[0].asJsonObject.getAsJsonPrimitive("id").asString.substring(6)
}
}
}

// gets all the mods
for (jsonElement in json.getAsJsonArray("files")) {
val obj = jsonElement.asJsonObject
mods.add(ModEntryRaw(
obj.getAsJsonPrimitive("projectID").asString,
obj.getAsJsonPrimitive("fileID").asString))
// gets all the mods
for (jsonElement in json.getAsJsonArray("files")) {
val obj = jsonElement.asJsonObject
mods.add(ModEntryRaw(
obj.getAsJsonPrimitive("projectID").asString,
obj.getAsJsonPrimitive("fileID").asString,
obj.getAsJsonPrimitive("downloadUrl")?.asString ?: ""))
}
} else {
val mcObj = json.getAsJsonObject("baseModLoader")
if (mcVersion.isEmpty()) {
mcVersion = mcObj.getAsJsonPrimitive("minecraftVersion").asString
}
if (forgeVersion.isEmpty()) {
forgeVersion = mcObj.getAsJsonPrimitive("forgeVersion").asString
}

for (jsonElement in json.getAsJsonArray("installedAddons")) {
val obj = jsonElement.asJsonObject
val projectID = obj.getAsJsonPrimitive("addonID").asString
val fileID = obj.getAsJsonObject("installedFile").getAsJsonPrimitive("id").asString
val downloadUrl = obj.getAsJsonObject("installedFile").getAsJsonPrimitive("downloadUrl").asString

mods.add(ModEntryRaw(projectID,fileID,downloadUrl))
}
}

}

downloadMods(mods)
Expand Down Expand Up @@ -323,4 +355,4 @@ open class CursePackType(private val configFile: ConfigFile, internetManager: In
/**
* Data class to keep projectID and fileID together
*/
data class ModEntryRaw(val projectID: String, val fileID: String)
data class ModEntryRaw(val projectID: String, val fileID: String, val downloadUrl: String)

0 comments on commit 776d678

Please sign in to comment.