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