From 144551070df11c640691d91f3deb897f87c09bddb1f6cee8da522d1263cb23a2 Mon Sep 17 00:00:00 2001 From: JaniSoto Date: Thu, 13 Aug 2026 02:01:50 +0000 Subject: [PATCH] bug fixes --- .../patches/lts-auth/build.py | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/instances/forge-1.20.1-survival/patches/lts-auth/build.py b/instances/forge-1.20.1-survival/patches/lts-auth/build.py index e7d3de0..9721f46 100644 --- a/instances/forge-1.20.1-survival/patches/lts-auth/build.py +++ b/instances/forge-1.20.1-survival/patches/lts-auth/build.py @@ -28,14 +28,34 @@ if os.path.exists(JAR_HOST_PATH): prepare_tmp() + # Extract original JAR with zipfile.ZipFile(JAR_HOST_PATH, "r") as z: z.extractall(TMP_HOST_DIR) + # Copy local .java source files into TMP_HOST_DIR/src based on their package declaration + src_base = os.path.join(TMP_HOST_DIR, "src") + os.makedirs(src_base, exist_ok=True) + + for root, _, files in os.walk("."): + for file in files: + if file.endswith(".java"): + filepath = os.path.join(root, file) + pkg = "" + with open(filepath, "r", encoding="utf-8") as f: + for line in f: + line = line.strip() + if line.startswith("package ") and line.endswith(";"): + pkg = line[8:-1].strip() + break + target_dir = os.path.join(src_base, *pkg.split(".")) if pkg else src_base + os.makedirs(target_dir, exist_ok=True) + shutil.copyfile(filepath, os.path.join(target_dir, file)) + run_cmd(f"docker exec -u 0 -i {CONTAINER_NAME} apt-get update >/dev/null 2>&1") run_cmd(f"docker exec -u 0 -i {CONTAINER_NAME} apt-get install -y openjdk-17-jdk-headless >/dev/null 2>&1") run_cmd(f"docker exec -u 0 -i {CONTAINER_NAME} chmod -R 777 {TMP_CONTAINER_DIR}") - compile_cmd = f'docker exec -i {CONTAINER_NAME} bash -c \'CP=$(find /data/libraries /data/mods -name "*.jar" | tr "\\n" ":"); javac -cp "$CP" -d {TMP_CONTAINER_DIR} {TMP_CONTAINER_DIR}/src/com/rtxbb/lts_auth/LtsAuthMod.java {TMP_CONTAINER_DIR}/src/com/rtxbb/lts_auth/command/LoginCommand.java\'' + compile_cmd = f'docker exec -i {CONTAINER_NAME} bash -c \'CP=$(find /data/libraries /data/mods -name "*.jar" | tr "\\n" ":"); javac -cp "$CP:{TMP_CONTAINER_DIR}" -d {TMP_CONTAINER_DIR} {TMP_CONTAINER_DIR}/src/com/rtxbb/lts_auth/LtsAuthMod.java {TMP_CONTAINER_DIR}/src/com/rtxbb/lts_auth/command/LoginCommand.java\'' if run_cmd(compile_cmd): print("Compilation successful! Re-zipping mod JAR...") run_cmd(f"docker exec -u 0 -i {CONTAINER_NAME} chmod -R 777 {TMP_CONTAINER_DIR}")