From 695bc79ca43f9d2594d489b16b518f68fba2555e Mon Sep 17 00:00:00 2001 From: Caadiq Date: Fri, 26 Dec 2025 19:27:29 +0900 Subject: [PATCH] =?UTF-8?q?feat(IconExporter):=20ZIP=20=EA=B5=AC=EC=A1=B0?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20-=20items=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 이미지 파일을 icons/items/.png에 저장 - ZIP 구조: metadata.json + items/.png - 압축 후 items 폴더 삭제 --- .../iconexporter/export/IconExportManager.kt | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/IconExporter/src/main/kotlin/com/beemer/iconexporter/export/IconExportManager.kt b/IconExporter/src/main/kotlin/com/beemer/iconexporter/export/IconExportManager.kt index 6f618b2..2ac0331 100644 --- a/IconExporter/src/main/kotlin/com/beemer/iconexporter/export/IconExportManager.kt +++ b/IconExporter/src/main/kotlin/com/beemer/iconexporter/export/IconExportManager.kt @@ -167,13 +167,13 @@ object IconExportManager { } } - /** 아이템 ID로 출력 경로 생성 형식: icons/.png 예: icons/brass_casing.png */ + /** 아이템 ID로 출력 경로 생성 형식: icons/items/.png 예: icons/items/brass_casing.png */ private fun getOutputPath(namespace: String, path: String): Path { val mc = Minecraft.getInstance() val gameDir = mc.gameDirectory.toPath() - // icons/.png (단일 폴더) - return gameDir.resolve("icons").resolve("$path.png") + // icons/items/.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/.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) } } }