banana-mc/scripts/preStartup.groovy

42 lines
1.1 KiB
Groovy
Raw Normal View History

2026-05-26 22:40:38 +02:00
import org.apache.groovy.parser.antlr4.util.StringUtils
if(!(new File("packwiz-installer-bootstrap.jar").exists())){
System.exit(1)
}
String side = System.getProperty("modpack.side","client")
String uri = System.getProperty("modpack.uri","https://baka.materus.pl/materus/banana-mc/raw/branch/1.21.1-v2/pack.toml")
String gui = System.getProperty("modpack.gui","true")
String instanceJava = System.getenv("INST_JAVA")
def args = [ StringUtils.isEmpty(instanceJava) ? (
System.getProperty("os.name").toLowerCase().contains("windows") ? "javaw" : "java"
) : instanceJava ]
args += "-jar"
args += "packwiz-installer-bootstrap.jar"
args += "-s"
args += side
if(gui.equals("false")) args+= "-g"
args += uri
print(args)
def packwizProc = args.execute()
packwizProc.in.eachLine {println(it)}
packwizProc.err.eachLine {println(it)}
int code = packwizProc.waitFor()
if(code != 0){
System.exit(code)
}
def postPackwiz = new File("scripts/postPackwiz.groovy")
if(postPackwiz.exists()){
evaluate(postPackwiz);
} else {
print("No postPackwiz.groovy found")
}