Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d4e4378602 | |||
| 9e9eae0920 | |||
| 082dae5a90 | |||
| 7508f3b11b | |||
| bed47e88a0 | |||
| ab928b13e0 | |||
| 57e85e0352 | |||
| a8698ef394 | |||
| 80059d6696 | |||
| 68e2312ce7 | |||
| f79074930f | |||
| 89370e5f89 | |||
| 13e4e0eb13 | |||
| e80933d21e | |||
| df5947f8bb | |||
| 3c404ecd8c | |||
| e30d7418df |
56
README.md
56
README.md
@@ -3,8 +3,8 @@
|
||||
마인크래프트 음악퀴즈를 한 번에 배포·관리할 수 있도록 만든 통합 프로젝트입니다.
|
||||
|
||||
- **관리 사이트** — 음악퀴즈 정보(JSON)와 음악·사진 목록, 데이터팩 출력을 한 곳에서 운영.
|
||||
- **음악퀴즈 간편설치기 (`.exe`)** — `manifest.json` 기반으로 사용자가 마인크래프트 본체·서버·모드를 자동 설치.
|
||||
- **리소스팩 간편설치기 (`.exe`)** — 음악퀴즈 음악·표지를 yt-dlp 로 받아 painting variant 텍스처 리소스팩으로 패키징.
|
||||
- **음악퀴즈 간편설치기 (`.exe`)** — `manifest.json` 기반으로 마인크래프트 본체·모드·(멀티 호스트면)서버를 자동 설치. 서버용 JDK 자동 탐색·설치와 `run.bat` 자바 경로 보정, 완료 단계에서 최종 리소스팩 선택 설치까지 처리.
|
||||
- **리소스팩 간편설치기 (`.exe`)** — 음악퀴즈 음악·표지를 yt-dlp 로 받아 painting variant 텍스처 리소스팩으로 패키징(429/403 재시도·동시 다운로드).
|
||||
- **간편포트포워딩 (`.exe`)** — 원하는 포트를 입력해 UPnP 로 개방. 프로그램을 켜 두는 동안만 열려 있고 창을 닫으면 자동으로 닫힙니다.
|
||||
- **음악퀴즈 파일제거 (`.exe`)** — 설치기들이 만든 게임 폴더·캐시와 런처 프로필을 휴지통 이동 또는 완전 삭제로 한 번에 정리.
|
||||
|
||||
@@ -29,28 +29,40 @@
|
||||
|
||||
## 핵심 컨셉
|
||||
|
||||
설치기는 사용자의 `%APPDATA%\.minecraft` 를 더럽히지 않기 위해 **`.mc_custom`** 을 별도 게임 디렉터리로 사용합니다.
|
||||
설치기는 사용자의 평소 마인크래프트와 음악퀴즈 설정이 섞이지 않도록 **`.mc_custom`** 을 별도 게임 디렉터리(gameDir)로 씁니다. 단, 마인크래프트 **런처는 게임 실행에 필요한 공용 데이터(`versions` / `libraries` / `assets` / `runtime`)를 런처 폴더(`.minecraft`)에서 찾으므로**, 이 데이터(바닐라 + fabric)는 `.minecraft` 에 둡니다. 그중 `assets` / `libraries` / `versions` 세 폴더만 `.mc_custom` 에 junction 링크하고(게임이 gameDir 기준으로 찾아도 되도록), `runtime`(JRE)은 링크하지 않고 런처가 `.minecraft\runtime` 에서 직접 씁니다. 게임 데이터(모드/세이브/리소스팩)만 `.mc_custom` 에 별도로 둡니다.
|
||||
|
||||
```
|
||||
%APPDATA%\
|
||||
├─ .minecraft\ ← 원래 마인크래프트 폴더(공용 자원: assets, libraries, versions, runtime)
|
||||
└─ .mc_custom\ ← 음악퀴즈 전용 게임 폴더(설치기가 자동 생성)
|
||||
├─ .minecraft\ ← 런처 폴더. 게임 실행에 필요한 공용 데이터는 반드시 여기에 있어야 함
|
||||
│ ├─ assets\ ← 에셋(사운드/번역/스킨 등)
|
||||
│ ├─ libraries\ ← 자바 라이브러리(바닐라 + fabric) ※ assets 밖의 형제 폴더
|
||||
│ ├─ versions\ ← 버전 JSON(바닐라 + fabric-loader-*) ※ fabric 은 여기에 설치
|
||||
│ ├─ runtime\ ← 런처 번들 JRE(런처가 직접 사용)
|
||||
│ └─ launcher_profiles.json ← 음악퀴즈 프로필(gameDir=.mc_custom)을 추가/갱신
|
||||
└─ .mc_custom\ ← 음악퀴즈 전용 게임 폴더(gameDir). 설치기가 자동 생성
|
||||
├─ mods\ ← 음악퀴즈가 지정한 모드(.jar)
|
||||
├─ resourcepacks\ ← 리소스팩(.zip)
|
||||
├─ resourcepacks\ ← 리소스팩(.zip). 최종 리소스팩도 여기에 저장
|
||||
├─ saves\ ← 단일 맵 .zip 압축 해제 결과
|
||||
├─ assets\ (junction → .minecraft\assets)
|
||||
├─ libraries\ (junction → .minecraft\libraries)
|
||||
├─ versions\ (junction → .minecraft\versions)
|
||||
├─ options.txt 등 ← `.minecraft` 의 최상위 설정 파일을 복사해 사용
|
||||
└─ launcher_profiles ← 실제 파일은 `.minecraft\launcher_profiles.json` 을 수정해 gameDir=.mc_custom 으로 지정
|
||||
├─ jdk\ ← 설치기가 자동 설치한 JDK(temurin-<버전>)
|
||||
├─ assets\ · libraries\ · versions\ ← `.minecraft` 로의 junction 링크(공용 데이터)
|
||||
└─ options.txt 등 ← `.minecraft` 최상위 설정 파일을 복사해 사용
|
||||
```
|
||||
|
||||
이렇게 분리해 두면 사용자가 평소 쓰던 마인크래프트와 음악퀴즈 설정이 섞이지 않고, 음악퀴즈만 삭제해도 본체에는 영향이 없습니다.
|
||||
이렇게 분리해 두면 음악퀴즈만 삭제해도(파일제거 도구) 본체 마인크래프트에는 영향이 없습니다. fabric 을 `.mc_custom` 이 아닌 `.minecraft` 에 설치하는 이유는, 게임 폴더에 설치하면 바닐라 버전/라이브러리가 빠져 런처가 "Unable to prepare assets for download" 로 실패하기 때문입니다(자세한 흐름은 [`docs/installer.md`](docs/installer.md)).
|
||||
|
||||
> **폴더 이름 바꾸기.** 기본값은 `.mc_custom` 이지만 `.env` / `.env.build` 의 `MC_CUSTOM_DIR` 로 다른 이름을 지정할 수 있습니다. 설치기·리소스팩설치기·파일제거기가 모두 이 값을 공유하므로, 값을 바꾸면 세 exe 를 같은 값으로 다시 빌드해야 서로 같은 폴더를 가리킵니다. (경로 구분자 `/ \` 와 `..` 는 무시되어 항상 `%APPDATA%` 바로 아래 단일 폴더가 됩니다.)
|
||||
|
||||
---
|
||||
|
||||
## 간편설치기 동작 요약
|
||||
|
||||
- **JDK(서버용)** — 탐색 순서: ① `.mc_custom\jdk`(설치기 자동 설치분)에 JDK 가 있으면 먼저 사용 → ② 없으면 환경변수(`JAVA_HOME`/`JDK_HOME`)의 JDK 가 **권장 버전(`recommendedJdk`)** 이면 사용 → ③ 그래도 없으면 `C:\Program Files\Java` 에서 권장 버전을 찾아 사용. 권장 버전을 어디서도 못 찾으면 환경변수 자바(없으면 Program Files 자바)로 폴백하고 "권장과 다름" 경고를 띄웁니다. 아무 JDK 도 없으면 Adoptium Temurin(권장 버전)을 `.mc_custom\jdk` 에 자동 설치합니다.
|
||||
- **서버 `run.bat`** — 서버 zip 의 `run.bat` 이 시스템 PATH 의 낡은 자바를 쓰지 않도록, 준비/선택한 JDK 의 `java` 를 쓰도록 자동 수정합니다(자동 설치 JDK 는 `%APPDATA%` 전개형 경로라 한글 사용자명에도 안전).
|
||||
- **최종 리소스팩** — 완료 단계에서 "리소스팩을 설치하시겠습니까?"(예/아니요). 예 → 최종 리소스팩 약관 동의 → `/file/resourcepacks/outputs/` 에서 진행률과 함께 다운로드. `finalResourcepackPath` 가 `"."` 이면 이 질문을 건너뜁니다.
|
||||
- **약관 표시 대상** — 사이트 약관마다 표시 위치(설치기 / 리소스팩 설치기 / 최종 리소스팩)를 개별 토글합니다.
|
||||
|
||||
---
|
||||
|
||||
## 빠른 시작
|
||||
|
||||
전제: Node.js 18+, npm. 윈도우 빌드를 만들 때만 추가로 Electron 의 PE 서명·아이콘 도구가 필요합니다.
|
||||
@@ -128,21 +140,27 @@ npm run dist:win:rp:dev # (개발자용) 음악퀴즈 리소스팩설치기
|
||||
"loaderVersion": "0.16.10"
|
||||
},
|
||||
"modsFolder": "mq-v1",
|
||||
"resourcepackPath": "mq-v1.zip",
|
||||
"resourcepackPath": "mq-v1-base.zip",
|
||||
"finalResourcepackPath": "mq-v1.zip",
|
||||
"outputPackName": "음악퀴즈 v1 리소스팩",
|
||||
"mapPath": "mq-v1-map.zip",
|
||||
"serverPath": "mq-v1-server.zip",
|
||||
"serverMinRam": 4096,
|
||||
"serverMaxRam": 8192,
|
||||
"clientMinRam": 4096,
|
||||
"clientRecommendedRam": 8192
|
||||
"clientRecommendedRam": 8192,
|
||||
"recommendedJdk": 25
|
||||
}
|
||||
```
|
||||
|
||||
- `platform.type` = `vanilla` / `forge` / `fabric` / `neoforge`.
|
||||
- `fabric` 은 `loaderVersion` 만 지정하면 설치기가 최신 fabric-installer 로 자동 CLI 설치합니다.
|
||||
- `fabric` 은 `loaderVersion` 만 지정하면 설치기가 최신 fabric-installer 로 `.minecraft` 에 자동 CLI 설치합니다.
|
||||
- 나머지(forge/neoforge) 는 `platform.downloadUrl` 에 설치 jar URL.
|
||||
- `modsFolder` → `/file/mods/<폴더>/` 의 모든 `.jar` 를 자동으로 받습니다.
|
||||
- `serverPath` / `mapPath` / `resourcepackPath` → `/file/servers/`, `/file/maps/`, `/file/resourcepacks/` 아래 zip 파일명.
|
||||
- `serverPath` / `mapPath` / `resourcepackPath` → `/file/servers/`, `/file/maps/`, `/file/resourcepacks/` 아래 zip 파일명. `resourcepackPath` 는 리소스팩 설치기의 **베이스** 팩입니다.
|
||||
- `finalResourcepackPath` → `/file/resourcepacks/outputs/` 의 **최종 리소스팩** zip. 간편설치기 완료 단계에서 사용자가 선택 설치합니다. `"."` 이면 없음(질문 자체를 건너뜀). 최종 리소스팩이 지정되면 간편설치기는 중복인 베이스 리소스팩을 받지 않습니다.
|
||||
- `outputPackName` → 리소스팩 설치기가 만들 zip 이름/마인크래프트 목록 제목.
|
||||
- `recommendedJdk` → 서버 실행 권장 JDK 메이저(사이트 편집기의 Adoptium 목록에서 선택). 설치기가 이 버전을 우선 탐색하고 없으면 자동 설치합니다.
|
||||
|
||||
### `/file/list/<key>.json` — 음악·사진 목록 (리소스팩 설치기용)
|
||||
|
||||
@@ -184,12 +202,14 @@ minecraft_launcher/
|
||||
│ ├─ servers/ 서버 zip
|
||||
│ ├─ maps/ 맵 zip
|
||||
│ ├─ mods/<폴더>/ 모드 jar 묶음 (index.json 자동 생성)
|
||||
│ ├─ resourcepacks/ 리소스팩 zip
|
||||
│ ├─ resourcepacks/ 베이스 리소스팩 zip
|
||||
│ │ └─ outputs/ 최종 리소스팩 zip (간편설치기 완료 단계용)
|
||||
│ ├─ platforms/ Forge / NeoForge 설치 jar
|
||||
│ └─ list/<key>.json 음악·사진 목록
|
||||
├─ docs/ 사용·운영 문서
|
||||
├─ manifest.json 사이트 루트 매니페스트 (자동 관리)
|
||||
├─ account.json 관리자 계정 (절대 외부 노출 금지)
|
||||
├─ account.json 관리자 계정 시드/레거시(추적됨). 실제 운영 계정은 아래 우선
|
||||
├─ account.local.json 실제 운영 계정(해시 비밀번호, .gitignore, 0600). 없으면 account.json 을 시드로 사용
|
||||
├─ package.json
|
||||
└─ tsconfig.{,server,installer,installer-rp,installer-pf,installer-uninstall}.json
|
||||
```
|
||||
|
||||
@@ -78,9 +78,9 @@
|
||||
2. `.minecraft` 최상위 설정 파일(`options.txt`, `optionsof.txt`, `servers.dat`, `usercache.json`, …) 을 `.mc_custom` 으로 복사. 이미 같은 이름이 있으면 보존.
|
||||
3. 플랫폼 설치:
|
||||
- `vanilla` → 건너뜀.
|
||||
- `fabric` → Adoptium 자동 설치 → 최신 fabric-installer.jar 다운로드 → `java -jar fabric-installer.jar client -mcversion X -loader Y -dir .mc_custom -noprofile` 자동 실행.
|
||||
- `fabric` → fabric-installer(자바 필요) 를 돌리지 않고, fabric meta 에서 버전 프로필 JSON 을 직접 받아 `.minecraft\versions\fabric-loader-Y-X\fabric-loader-Y-X.json` 으로 저장한다(`https://meta.fabricmc.net/v2/versions/loader/<mc>/<loader>/profile/json`). 자바가 없어도 되므로 "spawn java ENOENT" 나 바닐라 선행 실행이 필요 없다. 라이브러리는 프로필 JSON 에 적힌 maven url 을 보고 런처가 실행 시 자동으로 받는다. (fabric 버전/라이브러리는 런처 폴더 `.minecraft` 에 있어야 런처가 찾으며, `.mc_custom` 에 두면 "Unable to prepare assets for download" 로 실패한다.)
|
||||
- `forge` / `neoforge` → `platform.downloadUrl` 의 설치 jar 다운로드(사용자가 직접 실행하거나 마인크래프트 런처가 인식).
|
||||
4. `modsFolder` 의 모든 `.jar` 와 `resourcepackPath` zip, `mapPath` zip 을 자동 다운로드.
|
||||
4. `modsFolder` 의 모든 `.jar` 와 `resourcepackPath` zip, `mapPath` zip, `configPath` zip 을 자동 다운로드. (`configPath` zip 은 `.mc_custom` 루트에 그대로 풀려 `config/` 등이 배치됨)
|
||||
5. `.minecraft\{assets,libraries,versions}` 를 `.mc_custom\{assets,libraries,versions}` 로 junction 링크. (없으면 "Unable to prepare assets for download" 오류로 마인크래프트가 실패하기 때문)
|
||||
6. `.minecraft\launcher_profiles.json` 에 해당 음악퀴즈 이름의 프로필을 추가/갱신:
|
||||
- `gameDir` = `%APPDATA%\.mc_custom`
|
||||
|
||||
0
file/configs/.gitkeep
Normal file
0
file/configs/.gitkeep
Normal file
@@ -1133,20 +1133,53 @@ function downloadFinalResourcepack() {
|
||||
section.innerHTML =
|
||||
'<h2>' + tt('resourcepack.downloadHeading') + '</h2>' +
|
||||
'<div class="formMessage" id="rpMsg">' + tt('resourcepack.downloading') + '</div>' +
|
||||
'<div id="rpBarWrap" style="margin-top:10px;height:16px;background:rgba(255,255,255,0.08);border:1px solid var(--border,#30363d);border-radius:8px;overflow:hidden;">' +
|
||||
' <div id="rpBar" style="height:100%;width:0%;background:var(--accent,#6cf);transition:width 0.15s;"></div>' +
|
||||
'</div>' +
|
||||
'<div class="formMessage" id="rpPercent" style="margin-top:6px;">0%</div>' +
|
||||
'<div class="actionRow" id="rpActions" hidden></div>'
|
||||
pageHost.appendChild(section)
|
||||
var msg = section.querySelector('#rpMsg')
|
||||
var actions = section.querySelector('#rpActions')
|
||||
var bar = section.querySelector('#rpBar')
|
||||
var barWrap = section.querySelector('#rpBarWrap')
|
||||
var percentEl = section.querySelector('#rpPercent')
|
||||
|
||||
function proceed() { state.finalRpHandled = true; renderStep5() }
|
||||
// 다운로드 진행률(퍼센트) 구독. 완료/실패 시 해제.
|
||||
var unsubscribe = null
|
||||
if (installerApi.onFinalResourcepackProgress) {
|
||||
unsubscribe = installerApi.onFinalResourcepackProgress(function (info) {
|
||||
if (info && info.percent >= 0) {
|
||||
bar.style.width = info.percent + '%'
|
||||
percentEl.textContent = info.percent + '%'
|
||||
} else if (info) {
|
||||
// 전체 크기를 모르면 받은 용량(MB)만 표시.
|
||||
percentEl.textContent = (info.loaded / 1048576).toFixed(1) + ' MB'
|
||||
}
|
||||
})
|
||||
}
|
||||
function stopProgress() { if (unsubscribe) { unsubscribe(); unsubscribe = null } }
|
||||
|
||||
function proceed() { stopProgress(); state.finalRpHandled = true; renderStep5() }
|
||||
|
||||
installerApi.installFinalResourcepack().then(function (res) {
|
||||
stopProgress()
|
||||
if (res && res.ok) {
|
||||
bar.style.width = '100%'
|
||||
percentEl.textContent = '100%'
|
||||
if (res.applied === false) {
|
||||
// 다운로드는 됐지만 자동 적용(options.txt) 실패 → 직접 켜라고 경고.
|
||||
msg.textContent = tt('resourcepack.downloadDoneNotApplied', { message: res.applyMessage || '' })
|
||||
msg.classList.add('error')
|
||||
} else {
|
||||
msg.textContent = tt('resourcepack.downloadDone')
|
||||
msg.classList.add('success')
|
||||
}
|
||||
actions.innerHTML = '<button class="primaryBtn" id="rpNext">' + tt('common.next') + '</button>'
|
||||
actions.querySelector('#rpNext').addEventListener('click', proceed)
|
||||
} else {
|
||||
barWrap.hidden = true
|
||||
percentEl.hidden = true
|
||||
msg.textContent = tt('resourcepack.downloadFailed', { message: (res && res.message) || 'unknown' })
|
||||
msg.classList.add('error')
|
||||
actions.innerHTML =
|
||||
@@ -1157,6 +1190,9 @@ function downloadFinalResourcepack() {
|
||||
}
|
||||
actions.hidden = false
|
||||
}).catch(function (err) {
|
||||
stopProgress()
|
||||
barWrap.hidden = true
|
||||
percentEl.hidden = true
|
||||
msg.textContent = tt('resourcepack.downloadFailed', { message: (err && err.message) ? err.message : String(err) })
|
||||
msg.classList.add('error')
|
||||
actions.innerHTML =
|
||||
|
||||
@@ -162,12 +162,13 @@
|
||||
},
|
||||
"resourcepack": {
|
||||
"promptHeading": "리소스팩 설치",
|
||||
"promptBody": "이 음악퀴즈의 최종 리소스팩을 설치하시겠습니까? 설치 후에는 마인크래프트 내에서 직접 리소스팩을 적용해야 합니다.",
|
||||
"promptBody": "이 음악퀴즈의 최종 리소스팩을 설치하시겠습니까? 설치하면 마인크래프트에서 자동으로 적용됩니다.",
|
||||
"yes": "예",
|
||||
"no": "아니요",
|
||||
"downloadHeading": "최종 리소스팩 다운로드",
|
||||
"downloading": "최종 리소스팩을 다운로드하는 중…",
|
||||
"downloadDone": "최종 리소스팩 다운로드 완료. 마인크래프트 설정 → 리소스팩에서 직접 적용해 주세요.",
|
||||
"downloadDone": "최종 리소스팩 다운로드 완료. 마인크래프트를 켜면 자동으로 적용됩니다.",
|
||||
"downloadDoneNotApplied": "최종 리소스팩은 받았지만 자동 적용에 실패했습니다({{message}}). 마인크래프트 설정 → 리소스팩에서 직접 켜주세요.",
|
||||
"downloadFailed": "최종 리소스팩 다운로드 실패: {{message}}"
|
||||
},
|
||||
"step5": {
|
||||
@@ -207,9 +208,11 @@
|
||||
"jdkBusy": "이미 JDK 설치가 진행 중입니다.",
|
||||
"javaExeMissing": "설치 후 java 실행 파일을 찾지 못했습니다: {{path}}",
|
||||
"javaSpawnFailed": "Java 실행 실패: {{message}}",
|
||||
"javaNotFoundRunVanilla": "자바를 찾지 못해 설치를 진행할 수 없습니다. 먼저 마인크래프트 런처에서 [{{version}}] 바닐라를 한 번 실행해 자바 런타임을 받은 다음, 이 설치기를 다시 시도해 주세요.",
|
||||
"fabricInstallerExit": "fabric-installer 종료 코드 {{code}}{{detail}}",
|
||||
"fabricLoaderRequired": "Fabric 로더 버전이 음악퀴즈에 지정되지 않았습니다. 관리 사이트에서 platform.loaderVersion 을 설정해 주세요.",
|
||||
"fabricInstallerListEmpty": "Fabric installer 목록을 받지 못했습니다.",
|
||||
"fabricProfileInvalid": "Fabric 버전 프로필을 읽지 못했습니다: {{message}}",
|
||||
"portAllocFail": "포트를 할당할 수 없습니다.",
|
||||
"parseResponseFailed": "응답 파싱 실패: {{snippet}}"
|
||||
},
|
||||
@@ -230,8 +233,10 @@
|
||||
"labelExtract": "{{label}} 압축 해제: {{dir}}",
|
||||
"labelServerFile": "서버 파일",
|
||||
"labelMap": "맵",
|
||||
"labelConfigFile": "config 파일",
|
||||
"skipServerZip": "서버 파일(serverPath)이 비어 있어 서버 zip 다운로드를 건너뜁니다.",
|
||||
"skipMapZip": "맵 다운로드를 건너뜁니다 (mapPath 비어 있음 또는 참가자 모드).",
|
||||
"skipConfigZip": "config 파일(configPath)이 비어 있어 config zip 다운로드를 건너뜁니다.",
|
||||
"cleanupInstallerMap": "이전 설치에서 풀어둔 맵 {{count}}개를 정리합니다.",
|
||||
"mapInstalledAs": "맵을 saves/{{name}} 으로 설치했습니다.",
|
||||
"clearMods": "기존 mods 폴더({{dir}})를 비우고 새로 받습니다.",
|
||||
@@ -241,8 +246,11 @@
|
||||
"modDownload": "모드 다운로드: {{file}}",
|
||||
"skipResourcepack": "resourcepackPath가 비어 있어 리소스팩 다운로드를 건너뜁니다.",
|
||||
"resourcepackDownload": "리소스팩 다운로드: {{url}}",
|
||||
"skipBaseForFinal": "최종 리소스팩이 등록돼 있어 베이스 리소스팩은 건너뜁니다(설치 마지막에 최종 리소스팩만 받음).",
|
||||
"finalResourcepackDownload": "최종 리소스팩 다운로드: {{url}}",
|
||||
"finalResourcepackSaved": "최종 리소스팩 저장: {{path}}",
|
||||
"finalResourcepackApplied": "최종 리소스팩을 options.txt 에 등록해 자동 적용되게 했습니다: {{name}}",
|
||||
"finalResourcepackApplyFail": "최종 리소스팩 자동 적용 실패(마인크래프트에서 직접 켜주세요): {{message}}",
|
||||
"serverInstallPath": "서버 설치 경로: {{path}}",
|
||||
"runBatJavaPatched": "run.bat 이 설치기가 준비한 자바를 쓰도록 수정했습니다: {{java}}",
|
||||
"runBatJavaSkip": "설치기가 준비한 JDK 를 찾지 못해 run.bat 의 자바 경로는 그대로 둡니다(시스템 자바 사용).",
|
||||
@@ -275,6 +283,7 @@
|
||||
"platformSaved": "플랫폼 설치파일 저장: {{path}} (사용자가 직접 실행하거나 마인크래프트 런처에서 인식할 수 있습니다.)",
|
||||
"platformSkipped": "플랫폼 설치 건너뜀. 바닐라로 진행합니다.",
|
||||
"fabricFetchInstallerList": "Fabric installer 최신 버전 조회 중...",
|
||||
"fabricProfileFetch": "Fabric 버전 프로필 다운로드: {{url}}",
|
||||
"fabricInstallerDownload": "Fabric installer {{version}} 다운로드: {{url}}",
|
||||
"javaUsed": "Java 사용: {{path}}",
|
||||
"fabricInstallStart": "Fabric 자동 설치 시작: {{mc}} / loader {{loader}} → {{dir}}",
|
||||
@@ -289,9 +298,11 @@
|
||||
"settingCopyFail": "설정 복사 실패 ({{name}}): {{message}}",
|
||||
"settingCopySummary": "기존 마인크래프트 설정 복사: 새로 복사 {{copied}}개 / 동기화(options 류 덮어쓰기) {{synced}}개 / 보존(이미 존재) {{skipped}}개.",
|
||||
"settingCopyError": "기존 설정 복사 중 오류: {{message}}",
|
||||
"runtimeDirMissing": ".minecraft/{{dir}} 가 없습니다. 마인크래프트 런처를 한 번 실행한 뒤 다시 시도해주세요.",
|
||||
"runtimeDirMissing": ".minecraft/{{dir}} 가 없어 공용 링크를 만들 수 없습니다(런처가 이 폴더에 직접 받게 됩니다).",
|
||||
"runtimeDirCreated": ".mc_custom/{{dir}} 폴더를 새로 만들었습니다(런처가 여기에 직접 다운로드).",
|
||||
"runtimeDirExists": ".mc_custom/{{dir}} 가 실제 폴더로 이미 존재 — 건너뜀.",
|
||||
"runtimeLinkCreated": "링크 생성: .mc_custom/{{dir}} → .minecraft/{{dir}}",
|
||||
"runtimeLinkReplaced": "불완전한 .mc_custom/{{dir}} 폴더를 .minecraft/{{dir}} 링크로 교체했습니다(바닐라 데이터 포함).",
|
||||
"runtimeLinkFail": "링크 생성 실패 ({{dir}}): {{message}}",
|
||||
"shortcutCreated": "바로가기 생성: {{path}}",
|
||||
"shortcutFailed": "바로가기 생성 실패",
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
"platformDownloadUrl": "플랫폼 설치파일 URL",
|
||||
"platformDownloadHint": "도메인 없이 입력하면 manifest.json 도메인의 <code>/file/platforms/<파일명></code>으로 해석됩니다.",
|
||||
"platformLoaderVersion": "Fabric Loader 버전",
|
||||
"platformLoaderHint": "선택한 마인크래프트 버전 기준 Fabric Loader 목록입니다. 설치기는 최신 fabric-installer 를 받아 자동으로 CLI 설치합니다.",
|
||||
"platformLoaderHint": "선택한 마인크래프트 버전 기준 Fabric Loader 목록입니다. 설치기는 자바 없이 Fabric Meta 의 프로필 JSON 을 받아 .minecraft/versions 에 직접 저장합니다.",
|
||||
"platformLoaderEmpty": "호환 로더 없음",
|
||||
"platformLoaderPickMc": "마인크래프트 버전을 먼저 선택하세요",
|
||||
"platformLoaderLoadFailed": "로더 목록 로드 실패: {{message}}",
|
||||
@@ -134,6 +134,8 @@
|
||||
"jdkLtsSuffix": " (LTS)",
|
||||
"mapPath": "맵 파일 (.zip)",
|
||||
"mapPathHint": "/file/maps/ 아래 zip 파일 이름.",
|
||||
"configPath": "config 파일 (.zip)",
|
||||
"configPathHint": "/file/configs/ 아래 zip 파일 이름. 게임 폴더 루트에 그대로 풀립니다(보통 zip 안에 config/ 폴더).",
|
||||
"serverPath": "서버 파일 (.zip)",
|
||||
"serverPathHint": "/file/servers/ 아래 zip 파일 이름. 멀티 모드 전용.",
|
||||
"modsFolder": "모드 폴더 이름",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minecraft-music-quiz-installer",
|
||||
"version": "0.4.17",
|
||||
"version": "0.4.30",
|
||||
"description": "마인크래프트 음악퀴즈 간편설치기 + 관리 사이트",
|
||||
"main": "dist/installer/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -152,7 +152,7 @@ function fetchBuffer(url: string, redirects = 0, attempt = 0): Promise<Buffer> {
|
||||
}
|
||||
if (code >= 400) {
|
||||
response.resume()
|
||||
reject(new Error(`HTTP ${code}`))
|
||||
reject(new Error(`HTTP ${code}: ${url}`))
|
||||
return
|
||||
}
|
||||
const chunks: Buffer[] = []
|
||||
@@ -280,25 +280,100 @@ ipcMain.handle('terms:listFinal', async (): Promise<{ ok: boolean; terms?: Array
|
||||
})
|
||||
|
||||
// 최종 리소스팩(zip)을 /file/resourcepacks/outputs/ 에서 받아 .mc_custom/resourcepacks/ 에 저장.
|
||||
ipcMain.handle('finalResourcepack:install', async (): Promise<{ ok: boolean; path?: string; message?: string }> => {
|
||||
ipcMain.handle('finalResourcepack:install', async (): Promise<{ ok: boolean; path?: string; message?: string; applied?: boolean; applyMessage?: string }> => {
|
||||
const pack = state.selectedKey ? state.packs.get(state.selectedKey) : undefined
|
||||
if (!pack) return { ok: false, message: t('errors.packNotFound2') }
|
||||
const finalName = pack.pack.finalResourcepackPath
|
||||
if (!finalName || finalName === '.') return { ok: false, message: 'no final resourcepack' }
|
||||
let dest = ''
|
||||
try {
|
||||
const cleaned = path.basename(finalName.replace(/^\/+/, ''))
|
||||
const url = `${state.baseUrl}/file/resourcepacks/outputs/${encodeURIComponent(cleaned)}`
|
||||
const destDir = path.join(getAppDataDir(), getMcCustomDirName(), 'resourcepacks')
|
||||
const dest = path.join(destDir, cleaned)
|
||||
dest = path.join(destDir, cleaned)
|
||||
await fsp.mkdir(destDir, { recursive: true })
|
||||
sendLog(t('log.finalResourcepackDownload', { url }))
|
||||
await downloadFile(url, dest)
|
||||
// 진행률(퍼센트)을 렌더러로 흘려보내며 스트리밍 다운로드.
|
||||
let lastPct = -1
|
||||
const controller = new AbortController()
|
||||
await downloadStream(url, dest, controller.signal, (loaded, total) => {
|
||||
const percent = total > 0 ? Math.min(100, Math.max(0, Math.floor((loaded / total) * 100))) : -1
|
||||
if (percent !== lastPct) {
|
||||
lastPct = percent
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('finalResourcepack:progress', { loaded, total, percent })
|
||||
}
|
||||
}
|
||||
})
|
||||
sendLog(t('log.finalResourcepackSaved', { path: dest }))
|
||||
return { ok: true, path: dest }
|
||||
// 마인크래프트에서 직접 고르지 않아도 켜지도록 options.txt 의 resourcePacks 에 등록.
|
||||
const gameDir = path.join(getAppDataDir(), getMcCustomDirName())
|
||||
try {
|
||||
await enableResourcePackInOptions(gameDir, cleaned)
|
||||
sendLog(t('log.finalResourcepackApplied', { name: cleaned }))
|
||||
return { ok: true, path: dest, applied: true }
|
||||
} catch (err) {
|
||||
// 다운로드는 됐지만 자동 적용(options.txt)에 실패 → 성공으로 숨기지 말고 렌더러가
|
||||
// 경고를 띄우도록 applied=false 로 알린다(사용자가 직접 켤 수 있게).
|
||||
const msg = (err as Error).message
|
||||
sendLog(t('log.finalResourcepackApplyFail', { message: msg }))
|
||||
return { ok: true, path: dest, applied: false, applyMessage: msg }
|
||||
}
|
||||
} catch (error) {
|
||||
// 실패 시 부분/0바이트 zip 이 마인크래프트 리소스팩 목록에 깨진 채로 남지 않도록 삭제.
|
||||
if (dest) await fsp.rm(dest, { force: true }).catch(() => {})
|
||||
return { ok: false, message: (error as Error).message }
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* gameDir 의 options.txt 의 resourcePacks 목록에 `file/<packFileName>` 을 추가해,
|
||||
* 마인크래프트를 켜면 해당 리소스팩이 자동으로 적용되게 한다. (목록 마지막 = 최상위 우선)
|
||||
* options.txt 가 없으면 해당 한 줄만 새로 만든다(나머지 옵션은 게임이 기본값으로 채움).
|
||||
* incompatibleResourcePacks 목록에 있으면 제거해 실제로 켜지게 한다.
|
||||
*/
|
||||
async function enableResourcePackInOptions(gameDir: string, packFileName: string): Promise<void> {
|
||||
const optionsPath = path.join(gameDir, 'options.txt')
|
||||
const entry = `file/${packFileName}`
|
||||
let content = ''
|
||||
try { content = await fsp.readFile(optionsPath, 'utf8') } catch { content = '' }
|
||||
const lines = content.length ? content.split(/\r?\n/) : []
|
||||
// 파일이 \n 으로 끝났으면 split 결과 마지막에 빈 문자열이 생기므로 제거.
|
||||
if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop()
|
||||
|
||||
const parseList = (line: string, key: string): string[] => {
|
||||
const m = line.match(new RegExp(`^${key}:\\s*\\[(.*)\\]\\s*$`))
|
||||
if (!m) return []
|
||||
try {
|
||||
const arr = JSON.parse(`[${m[1]}]`) as unknown[]
|
||||
return arr.filter((x): x is string => typeof x === 'string')
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
const rpIdx = lines.findIndex((l) => l.startsWith('resourcePacks:'))
|
||||
if (rpIdx >= 0) {
|
||||
const items = parseList(lines[rpIdx], 'resourcePacks')
|
||||
if (!items.includes(entry)) items.push(entry)
|
||||
lines[rpIdx] = `resourcePacks:${JSON.stringify(items)}`
|
||||
} else {
|
||||
lines.push(`resourcePacks:${JSON.stringify([entry])}`)
|
||||
}
|
||||
|
||||
// 호환불가 목록에 들어가 있으면 빼서 실제로 적용되게 한다.
|
||||
const incIdx = lines.findIndex((l) => l.startsWith('incompatibleResourcePacks:'))
|
||||
if (incIdx >= 0) {
|
||||
const items = parseList(lines[incIdx], 'incompatibleResourcePacks')
|
||||
const filtered = items.filter((x) => x !== entry)
|
||||
if (filtered.length !== items.length) {
|
||||
lines[incIdx] = `incompatibleResourcePacks:${JSON.stringify(filtered)}`
|
||||
}
|
||||
}
|
||||
|
||||
await fsp.writeFile(optionsPath, `${lines.join('\n')}\n`, 'utf8')
|
||||
}
|
||||
|
||||
ipcMain.handle('packs:select', async (_event, packKey: string) => {
|
||||
if (!state.packs.has(packKey)) {
|
||||
throw new Error(t('errors.packNotFound'))
|
||||
@@ -552,7 +627,7 @@ function downloadStream(
|
||||
res.resume()
|
||||
fileStream.close(() => {
|
||||
signal.removeEventListener('abort', onAbort)
|
||||
if (!settled) { settled = true; reject(new Error(`HTTP ${sc}`)) }
|
||||
if (!settled) { settled = true; reject(new Error(`HTTP ${sc}: ${url}`)) }
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -690,6 +765,20 @@ async function downloadServerZip(pack: PackDefinition, targetDir: string): Promi
|
||||
await downloadAndExtractZip(url, t('log.labelServerFile'), targetDir)
|
||||
}
|
||||
|
||||
/**
|
||||
* config zip 을 게임 폴더(.mc_custom) 루트에 그대로 풀어 넣는다.
|
||||
* zip 안에 `config/` 폴더가 들어 있으면 `.mc_custom/config/` 로 배치된다.
|
||||
* configPath 가 비어 있으면 건너뛴다.
|
||||
*/
|
||||
async function downloadConfigZip(pack: PackDefinition, customRoot: string): Promise<void> {
|
||||
if (!pack.configPath) {
|
||||
sendLog(t('log.skipConfigZip'))
|
||||
return
|
||||
}
|
||||
const url = resolveManifestRelative(pack.configPath, 'configs')
|
||||
await downloadAndExtractZip(url, t('log.labelConfigFile'), customRoot)
|
||||
}
|
||||
|
||||
/**
|
||||
* 설치러가 saves/ 에 풀어놓은 최상위 폴더(또는 파일) 목록을 기록하는 마커 파일.
|
||||
* 재설치 시 잔여물을 안전하게 정리하고, 싱글→참가자 전환 시에도
|
||||
@@ -1326,7 +1415,7 @@ ipcMain.handle('client:install', async (_event, payload: ClientInstallPayload) =
|
||||
await copyMinecraftUserSettings(customRoot)
|
||||
|
||||
if (payload.installPlatform && pack.pack.platform.type === 'fabric') {
|
||||
await installFabricLoader(pack.pack, customRoot)
|
||||
await installFabricLoader(pack.pack)
|
||||
} else if (payload.installPlatform && pack.pack.platform.type !== 'vanilla' && pack.pack.platform.downloadUrl) {
|
||||
const platformUrl = resolveManifestRelative(pack.pack.platform.downloadUrl, 'platforms')
|
||||
const cacheDir = path.join(customRoot, 'platform-cache')
|
||||
@@ -1340,7 +1429,13 @@ ipcMain.handle('client:install', async (_event, payload: ClientInstallPayload) =
|
||||
}
|
||||
|
||||
await downloadModsFolder(pack.pack, customRoot)
|
||||
// 최종 리소스팩이 등록돼 있으면(finalResourcepackPath !== "."), 완성본을 설치 마지막에
|
||||
// 따로 받으므로 베이스 리소스팩은 받지 않는다("최종 리소스팩만 다운로드").
|
||||
if (pack.pack.finalResourcepackPath && pack.pack.finalResourcepackPath !== '.') {
|
||||
sendLog(t('log.skipBaseForFinal'))
|
||||
} else {
|
||||
await downloadResourcepackZip(pack.pack, customRoot)
|
||||
}
|
||||
|
||||
if (payload.skipMap) {
|
||||
// 참가자 모드: 이전 설치 흐름에서 설치러가 풀어둔 맵이 있다면 제거한다.
|
||||
@@ -1351,6 +1446,9 @@ ipcMain.handle('client:install', async (_event, payload: ClientInstallPayload) =
|
||||
await downloadMapZip(pack.pack, customRoot)
|
||||
}
|
||||
|
||||
// config zip 은 게임 폴더(.mc_custom) 루트에 그대로 풀어 config/ 등을 배치한다.
|
||||
await downloadConfigZip(pack.pack, customRoot)
|
||||
|
||||
// 런처가 .mc_custom 을 gameDir 로 잡아도 assets/libraries/versions 를
|
||||
// 찾을 수 있도록 .minecraft 의 해당 폴더로 junction 링크.
|
||||
await linkMinecraftRuntimeDirs(customRoot)
|
||||
@@ -1365,155 +1463,47 @@ ipcMain.handle('client:install', async (_event, payload: ClientInstallPayload) =
|
||||
}
|
||||
})
|
||||
|
||||
interface FabricInstallerMeta {
|
||||
url: string
|
||||
version: string
|
||||
stable: boolean
|
||||
}
|
||||
|
||||
async function installFabricLoader(pack: PackDefinition, customRoot: string): Promise<void> {
|
||||
async function installFabricLoader(pack: PackDefinition): Promise<void> {
|
||||
const loaderVersion = pack.platform.loaderVersion
|
||||
if (!loaderVersion) {
|
||||
throw new Error(t('errors.fabricLoaderRequired'))
|
||||
}
|
||||
|
||||
// 0) 이미 설치돼 있으면 건너뛴다. fabric-installer 는 매번 jar 를 지우고
|
||||
// 다시 쓰려고 시도해서, 마인크래프트나 다른 프로세스가 그 파일을 잡고
|
||||
// 있으면 FileSystemException 으로 실패한다. 결과 파일이 그대로 있으면
|
||||
// 재실행할 필요가 없으므로 그냥 통과.
|
||||
// fabric 은 .minecraft(런처 폴더)에 설치한다. gameDir(.mc_custom)에 설치하면 바닐라 버전/
|
||||
// 라이브러리가 빠져 런처가 "Unable to prepare assets for download" 로 실패한다.
|
||||
const mcRoot = path.join(getAppDataDir(), '.minecraft')
|
||||
const versionId = `fabric-loader-${loaderVersion}-${pack.mcVersion}`
|
||||
const versionDir = path.join(customRoot, 'versions', versionId)
|
||||
const versionJar = path.join(versionDir, `${versionId}.jar`)
|
||||
const versionDir = path.join(mcRoot, 'versions', versionId)
|
||||
const versionJson = path.join(versionDir, `${versionId}.json`)
|
||||
if (fs.existsSync(versionJar) && fs.existsSync(versionJson)) {
|
||||
if (fs.existsSync(versionJson)) {
|
||||
sendLog(t('log.fabricAlreadyInstalled', { id: versionId, dir: versionDir }))
|
||||
return
|
||||
}
|
||||
|
||||
// 1) 최신 fabric-installer 메타데이터 조회.
|
||||
sendLog(t('log.fabricFetchInstallerList'))
|
||||
const installerList = await fetchJson<FabricInstallerMeta[]>('https://meta.fabricmc.net/v2/versions/installer')
|
||||
if (!installerList || installerList.length === 0) {
|
||||
throw new Error(t('errors.fabricInstallerListEmpty'))
|
||||
// fabric-installer(자바 필요) 를 돌리는 대신, fabric meta 에서 버전 프로필 JSON 을 직접
|
||||
// 받아 versions/<id>/<id>.json 에 쓴다. 자바가 없어도 되므로 "spawn java ENOENT" 가
|
||||
// 사라지고, 바닐라를 미리 실행할 필요도 없다. 라이브러리는 프로필 JSON 의 각 library 에
|
||||
// 적힌 maven url 을 보고 런처가 실행 시 자동으로 받는다.
|
||||
const profileUrl =
|
||||
`https://meta.fabricmc.net/v2/versions/loader/${encodeURIComponent(pack.mcVersion)}/${encodeURIComponent(loaderVersion)}/profile/json`
|
||||
sendLog(t('log.fabricProfileFetch', { url: profileUrl }))
|
||||
const buf = await fetchBuffer(profileUrl)
|
||||
let profileId = ''
|
||||
try {
|
||||
const parsed = JSON.parse(buf.toString('utf8')) as { id?: unknown }
|
||||
if (typeof parsed.id === 'string') profileId = parsed.id
|
||||
} catch (err) {
|
||||
throw new Error(t('errors.fabricProfileInvalid', { message: (err as Error).message }))
|
||||
}
|
||||
const latest = installerList.find((item) => item.stable) || installerList[0]
|
||||
sendLog(t('log.fabricInstallerDownload', { version: latest.version, url: latest.url }))
|
||||
|
||||
// 2) installer jar 캐시.
|
||||
const cacheDir = path.join(customRoot, 'platform-cache')
|
||||
await fsp.mkdir(cacheDir, { recursive: true })
|
||||
const installerJar = path.join(cacheDir, `fabric-installer-${latest.version}.jar`)
|
||||
await downloadFile(latest.url, installerJar)
|
||||
|
||||
// 3) Java 실행파일 확보.
|
||||
const javaCmd = await findJavaExecutable()
|
||||
sendLog(t('log.javaUsed', { path: javaCmd }))
|
||||
|
||||
// 4) fabric-installer CLI 자동 실행.
|
||||
// client 모드 + -noprofile: launcher_profiles.json 은 우리 코드가 직접 갱신하므로 fabric-installer 가 덮어쓰지 않게 한다.
|
||||
// JVM stdout 인코딩 강제 UTF-8:
|
||||
// 한국 윈도우의 시스템 codepage 는 cp949(MS949) 라서 fabric-installer 가
|
||||
// 한글을 cp949 로 stdout 에 쓰면 우리가 utf-8 로 디코드해서 깨져 보인다.
|
||||
// `file.encoding` 은 default Charset, `stdout/stderr.encoding` 은
|
||||
// System.out/err 의 PrintStream 인코딩(Java 18+). 둘 다 지정하면
|
||||
// 구버전·신버전 JDK 모두에서 안전.
|
||||
const args = [
|
||||
'-Dfile.encoding=UTF-8',
|
||||
'-Dstdout.encoding=UTF-8',
|
||||
'-Dstderr.encoding=UTF-8',
|
||||
'-jar', installerJar,
|
||||
'client',
|
||||
'-mcversion', pack.mcVersion,
|
||||
'-loader', loaderVersion,
|
||||
'-dir', customRoot,
|
||||
'-noprofile'
|
||||
]
|
||||
sendLog(t('log.fabricInstallStart', { mc: pack.mcVersion, loader: loaderVersion, dir: customRoot }))
|
||||
await runJavaProcess(javaCmd, args)
|
||||
if (!profileId) {
|
||||
throw new Error(t('errors.fabricProfileInvalid', { message: 'missing id' }))
|
||||
}
|
||||
await fsp.mkdir(versionDir, { recursive: true })
|
||||
// 받은 바이트를 그대로 저장(무손실). 프로필의 id 는 versionId 와 동일하다.
|
||||
await fsp.writeFile(versionJson, buf)
|
||||
sendLog(t('log.fabricInstallDone'))
|
||||
}
|
||||
|
||||
async function findJavaExecutable(): Promise<string> {
|
||||
const javaName = process.platform === 'win32' ? 'java.exe' : 'java'
|
||||
|
||||
// 1) JAVA_HOME 우선.
|
||||
const javaHome = process.env.JAVA_HOME
|
||||
if (javaHome) {
|
||||
const exe = path.join(javaHome, 'bin', javaName)
|
||||
if (fs.existsSync(exe)) return exe
|
||||
}
|
||||
|
||||
// 2) 마인크래프트 런처가 번들한 자바 런타임. .minecraft\runtime\<name>\<os>\<name>\bin\java.exe 구조.
|
||||
try {
|
||||
const runtimeBase = path.join(getAppDataDir(), '.minecraft', 'runtime')
|
||||
if (fs.existsSync(runtimeBase)) {
|
||||
const priority = [
|
||||
'java-runtime-delta',
|
||||
'java-runtime-gamma',
|
||||
'java-runtime-beta',
|
||||
'java-runtime-alpha',
|
||||
'java-runtime-legacy',
|
||||
'jre-legacy'
|
||||
]
|
||||
const names = await fsp.readdir(runtimeBase)
|
||||
const sorted = names.slice().sort((a, b) => {
|
||||
const ia = priority.indexOf(a)
|
||||
const ib = priority.indexOf(b)
|
||||
if (ia === -1 && ib === -1) return 0
|
||||
if (ia === -1) return 1
|
||||
if (ib === -1) return -1
|
||||
return ia - ib
|
||||
})
|
||||
for (const name of sorted) {
|
||||
const dir = path.join(runtimeBase, name)
|
||||
try {
|
||||
const osDirs = await fsp.readdir(dir)
|
||||
for (const osDir of osDirs) {
|
||||
const exe = path.join(dir, osDir, name, 'bin', javaName)
|
||||
if (fs.existsSync(exe)) return exe
|
||||
}
|
||||
} catch {
|
||||
// skip
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// skip
|
||||
}
|
||||
|
||||
// 3) PATH 폴백.
|
||||
return javaName
|
||||
}
|
||||
|
||||
function runJavaProcess(cmd: string, args: string[]): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true })
|
||||
let stderrTail = ''
|
||||
const emitLines = (chunk: Buffer, prefix: string) => {
|
||||
const text = chunk.toString('utf8')
|
||||
text.split(/\r?\n/).forEach((line) => {
|
||||
if (line.trim().length === 0) return
|
||||
sendLog(` ${prefix} ${line}`)
|
||||
})
|
||||
}
|
||||
child.stdout?.on('data', (chunk: Buffer) => emitLines(chunk, '[fabric]'))
|
||||
child.stderr?.on('data', (chunk: Buffer) => {
|
||||
stderrTail += chunk.toString('utf8')
|
||||
if (stderrTail.length > 4000) stderrTail = stderrTail.slice(-4000)
|
||||
emitLines(chunk, '[fabric-err]')
|
||||
})
|
||||
child.on('error', (err) => reject(new Error(t('errors.javaSpawnFailed', { message: err.message }))))
|
||||
child.on('close', (code) => {
|
||||
if (code === 0) {
|
||||
resolve()
|
||||
} else {
|
||||
const detail = stderrTail.trim().split(/\r?\n/).slice(-3).join(' | ')
|
||||
reject(new Error(t('errors.fabricInstallerExit', { code: code ?? '', detail: detail ? ' — ' + detail : '' })))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function deriveFileName(url: string): string {
|
||||
try {
|
||||
const parsed = new URL(url)
|
||||
@@ -1734,13 +1724,39 @@ async function linkMinecraftRuntimeDirs(customRoot: string): Promise<void> {
|
||||
const src = path.join(mcRoot, dir)
|
||||
const dst = path.join(customRoot, dir)
|
||||
if (!fs.existsSync(src)) {
|
||||
// .minecraft 에 원본이 없으면(바닐라를 한 번도 안 받았거나 런처가 다른 위치를 쓰는
|
||||
// 환경) 링크를 만들 수 없다. 이때 그냥 건너뛰면 .mc_custom/<dir> 이 아예 없어
|
||||
// 런처가 "Unable to prepare assets for download" 로 실패한다. 빈 폴더라도 만들어
|
||||
// 런처가 그 gameDir 에 직접 받아갈 수 있게 한다(없을 때만).
|
||||
sendLog(t('log.runtimeDirMissing', { dir }))
|
||||
try {
|
||||
if (!fs.existsSync(dst)) {
|
||||
await fsp.mkdir(dst, { recursive: true })
|
||||
sendLog(t('log.runtimeDirCreated', { dir }))
|
||||
}
|
||||
} catch (err) {
|
||||
sendLog(t('log.runtimeLinkFail', { dir, message: (err as Error).message }))
|
||||
}
|
||||
continue
|
||||
}
|
||||
let existing: import('node:fs').Stats | null = null
|
||||
try { existing = await fsp.lstat(dst) } catch { existing = null }
|
||||
if (existing) {
|
||||
if (existing.isSymbolicLink()) continue // 이미 링크됨
|
||||
// versions/libraries 가 실제 폴더면, 예전 버전이 gameDir 에 fabric 을 설치하며 만든
|
||||
// 불완전한(바닐라 누락) 폴더일 수 있다. .minecraft 의 완전한 데이터로 링크되도록
|
||||
// 교체한다. 이 두 폴더는 런처가 관리하는 데이터라 삭제해도 세이브/리소스팩 같은
|
||||
// 사용자 데이터 손실은 없다. (assets 는 받아둔 에셋 보존을 위해 그대로 둔다.)
|
||||
if (dir === 'versions' || dir === 'libraries') {
|
||||
try {
|
||||
await fsp.rm(dst, { recursive: true, force: true })
|
||||
await fsp.symlink(src, dst, 'junction')
|
||||
sendLog(t('log.runtimeLinkReplaced', { dir }))
|
||||
} catch (err) {
|
||||
sendLog(t('log.runtimeLinkFail', { dir, message: (err as Error).message }))
|
||||
}
|
||||
continue
|
||||
}
|
||||
sendLog(t('log.runtimeDirExists', { dir }))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ const api = {
|
||||
// 최종 리소스팩 다운로드용 약관 목록 (showInFinalResourcepack 필터)
|
||||
getFinalTermsList: (): Promise<{ ok: boolean; terms?: Array<{ kind: string; label: string }>; message?: string }> =>
|
||||
ipcRenderer.invoke('terms:listFinal'),
|
||||
// 최종 리소스팩 다운로드 실행
|
||||
installFinalResourcepack: (): Promise<{ ok: boolean; path?: string; message?: string }> =>
|
||||
// 최종 리소스팩 다운로드 실행. applied=false 면 다운로드는 됐지만 자동 적용 실패.
|
||||
installFinalResourcepack: (): Promise<{ ok: boolean; path?: string; message?: string; applied?: boolean; applyMessage?: string }> =>
|
||||
ipcRenderer.invoke('finalResourcepack:install'),
|
||||
|
||||
// 3-1
|
||||
@@ -74,6 +74,15 @@ const api = {
|
||||
const listener = (_event: unknown, line: string) => handler(line)
|
||||
ipcRenderer.on('log', listener)
|
||||
return () => ipcRenderer.removeListener('log', listener)
|
||||
},
|
||||
|
||||
// 최종 리소스팩 다운로드 진행률 구독. 반환값을 호출하면 구독 해제.
|
||||
onFinalResourcepackProgress: (
|
||||
handler: (info: { loaded: number; total: number; percent: number }) => void
|
||||
): (() => void) => {
|
||||
const listener = (_event: unknown, info: { loaded: number; total: number; percent: number }) => handler(info)
|
||||
ipcRenderer.on('finalResourcepack:progress', listener)
|
||||
return () => ipcRenderer.removeListener('finalResourcepack:progress', listener)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -604,6 +604,7 @@ opRouter.post('/op/dashboard/:packName', requireAuth, async (req, res, next) =>
|
||||
clientRecommendedRam: Number(pickFirstValue(req.body.clientRecommendedRam)),
|
||||
recommendedJdk: Number(pickFirstValue(req.body.recommendedJdk)),
|
||||
mapPath: pickFirstValue(req.body.mapPath),
|
||||
configPath: pickFirstValue(req.body.configPath),
|
||||
serverPath: pickFirstValue(req.body.serverPath)
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ export function defaultPackDefinition(name: string): PackDefinition {
|
||||
clientRecommendedRam: 4096,
|
||||
recommendedJdk: DEFAULT_JDK_MAJOR,
|
||||
mapPath: '',
|
||||
configPath: '',
|
||||
serverPath: ''
|
||||
}
|
||||
}
|
||||
@@ -142,6 +143,7 @@ export function normalizePackDefinition(input: Partial<PackDefinition> & Record<
|
||||
clientRecommendedRam: clampNumber(input.clientRecommendedRam, fallback.clientRecommendedRam),
|
||||
recommendedJdk: normalizeRecommendedJdk(input.recommendedJdk),
|
||||
mapPath: sanitizeZipFileName(input.mapPath),
|
||||
configPath: sanitizeZipFileName(input.configPath),
|
||||
serverPath: sanitizeZipFileName(input.serverPath)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@ export interface PackDefinition {
|
||||
recommendedJdk: number
|
||||
/** /file/maps/<mapPath> 에서 받아 .mc_custom/saves 로 풀 zip 파일 이름. */
|
||||
mapPath: string
|
||||
/**
|
||||
* /file/configs/<configPath> 에서 받아 게임 폴더(.mc_custom) 루트에 그대로 푸는 zip
|
||||
* 파일 이름. 보통 zip 안에 `config/` 폴더를 담는다. 빈 문자열이면 받지 않는다.
|
||||
*/
|
||||
configPath: string
|
||||
/** /file/servers/<serverPath> 에서 받아 서버 설치 경로로 풀 zip 파일 이름. */
|
||||
serverPath: string
|
||||
}
|
||||
|
||||
@@ -96,6 +96,11 @@
|
||||
<input name="mapPath" value="<%= pack.mapPath %>" placeholder="my-map.zip" pattern=".+\.zip" />
|
||||
<small class="muted"><%= t('editor.mapPathHint') %></small>
|
||||
</label>
|
||||
<label>
|
||||
<span><%= t('editor.configPath') %></span>
|
||||
<input name="configPath" value="<%= pack.configPath %>" placeholder="my-config.zip" pattern=".+\.zip" />
|
||||
<small class="muted"><%= t('editor.configPathHint') %></small>
|
||||
</label>
|
||||
<label>
|
||||
<span><%= t('editor.serverPath') %></span>
|
||||
<input name="serverPath" value="<%= pack.serverPath %>" placeholder="my-server.zip" pattern=".+\.zip" />
|
||||
|
||||
Reference in New Issue
Block a user