feat(IconExporter): ZIP 구조 변경 - items 폴더 추가

- 이미지 파일을 icons/items/<name>.png에 저장
- ZIP 구조: metadata.json + items/<name>.png
- 압축 후 items 폴더 삭제
This commit is contained in:
Caadiq 2025-12-26 19:27:29 +09:00
parent 215baf9361
commit 695bc79ca4

View file

@ -167,13 +167,13 @@ object IconExportManager {
}
}
/** 아이템 ID로 출력 경로 생성 형식: icons/<path>.png 예: icons/brass_casing.png */
/** 아이템 ID로 출력 경로 생성 형식: icons/items/<path>.png 예: icons/items/brass_casing.png */
private fun getOutputPath(namespace: String, path: String): Path {
val mc = Minecraft.getInstance()
val gameDir = mc.gameDirectory.toPath()
// icons/<path>.png (단일 폴더)
return gameDir.resolve("icons").resolve("$path.png")
// icons/items/<path>.png
return gameDir.resolve("icons").resolve("items").resolve("$path.png")
}
/** 진행률 로그 출력 */
@ -289,17 +289,20 @@ object IconExportManager {
zos.write(metadata.toByteArray(Charsets.UTF_8))
zos.closeEntry()
// PNG 파일 추가 (모든 파일을 단순히 파일명만으로 압축)
Files.walk(iconsDir).use { paths ->
paths.filter { Files.isRegularFile(it) && it.name.endsWith(".png") }.forEach { file
->
try {
// ZIP 내 경로: 파일명만 사용 (예: brass_casing.png)
zos.putNextEntry(ZipEntry(file.name))
Files.copy(file, zos)
zos.closeEntry()
} catch (e: Exception) {
IconExporter.LOGGER.error("ZIP에 파일 추가 실패: {} - {}", file, e.message)
// PNG 파일 추가 (items/ 폴더 구조 유지)
val itemsDir = iconsDir.resolve("items")
if (itemsDir.exists()) {
Files.walk(itemsDir).use { paths ->
paths.filter { Files.isRegularFile(it) && it.name.endsWith(".png") }.forEach {
file ->
try {
// ZIP 내 경로: items/<name>.png
zos.putNextEntry(ZipEntry("items/${file.name}"))
Files.copy(file, zos)
zos.closeEntry()
} catch (e: Exception) {
IconExporter.LOGGER.error("ZIP에 파일 추가 실패: {} - {}", file, e.message)
}
}
}
}
@ -307,15 +310,15 @@ object IconExportManager {
IconExporter.LOGGER.info("ZIP 압축 완료: {}", zipPath)
// 압축 완료 후 원본 PNG 파일 삭제 (ZIP 파일 제외)
// 압축 완료 후 items 폴더 삭제
try {
Files.list(iconsDir).use { files ->
files.filter { Files.isRegularFile(it) && it.name.endsWith(".png") }.forEach { file
->
val itemsDir = iconsDir.resolve("items")
if (itemsDir.exists()) {
Files.walk(itemsDir).sorted(Comparator.reverseOrder()).forEach { path ->
try {
Files.delete(file)
Files.delete(path)
} catch (e: Exception) {
IconExporter.LOGGER.error("파일 삭제 실패: {} - {}", file, e.message)
IconExporter.LOGGER.error("파일 삭제 실패: {} - {}", path, e.message)
}
}
}