From 0cd02cf471ebd52a1afc967134374595cd3b7b62 Mon Sep 17 00:00:00 2001 From: Griefed Date: Sat, 2 Sep 2023 19:01:37 +0200 Subject: [PATCH 1/2] fix: Correctly check ZIP-entries --- .../serverpackcreator/api/ConfigurationHandler.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/serverpackcreator-api/src/jvmMain/kotlin/de/griefed/serverpackcreator/api/ConfigurationHandler.kt b/serverpackcreator-api/src/jvmMain/kotlin/de/griefed/serverpackcreator/api/ConfigurationHandler.kt index 076ad3ebe..70a0e2a7b 100644 --- a/serverpackcreator-api/src/jvmMain/kotlin/de/griefed/serverpackcreator/api/ConfigurationHandler.kt +++ b/serverpackcreator-api/src/jvmMain/kotlin/de/griefed/serverpackcreator/api/ConfigurationHandler.kt @@ -830,16 +830,23 @@ actual class ConfigurationHandler( SecurityException::class ) actual override fun getDirectoriesInModpackZipBaseDirectory(zipFile: File): List { - val baseDirectories: MutableList = ArrayList(100) + val baseDirectories: TreeSet = TreeSet() + var headerBeginning: String ZipFile(zipFile).use { val headers = it.fileHeaders for (header in headers) { - if (header.fileName.matches(zipCheck)) { - baseDirectories.add(header.fileName) + try { + headerBeginning = header.fileName.substring(0,header.fileName.indexOfFirst { char -> char == '/' } + 1) + log.debug("Header beginning $headerBeginning") + if (headerBeginning.matches(zipCheck)) { + baseDirectories.add(headerBeginning) + } + } catch (ex: StringIndexOutOfBoundsException) { + log.debug("Could not parse ${header.fileName}") } } } - return baseDirectories + return baseDirectories.toList() } @Throws(IOException::class) From e2107d20b23694411e4768459130993938b663a6 Mon Sep 17 00:00:00 2001 From: Griefed Date: Sat, 2 Sep 2023 19:01:54 +0200 Subject: [PATCH 2/2] improv: Hint about server pack contents generated from ZIP-archives --- serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties | 2 ++ .../serverpackcreator/gui/window/control/ControlPanel.kt | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties b/serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties index aad68668e..abb4c647b 100644 --- a/serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties +++ b/serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties @@ -162,6 +162,8 @@ createserverpack.gui.inclusions.editor.tip.default=Select an entry on the left t createserverpack.gui.inclusions.editor.tip.global.inclusions=Global inclusion filters do not have any effect on the server pack generation. createserverpack.gui.inclusions.editor.tip.global.exclusions=This global exclusion filter would exclude anything matching: {0} createserverpack.gui.inclusions.editor.tip.prefix=The following files would be included with this Inclusion-Specification:\n +createserverpack.gui.config.zip.info.title=Generating from ZIP-archive +createserverpack.gui.config.zip.info.message=Server packs from ZIP-archives always contain your specified files, plus automatically determined ones based on the ZIP-archive contents. migration.message.title=Things Have Been Migrated! menubar.gui.migration=Migration Info menubar.gui.filetoolarge=Size exceeds 10MB or 400.000 characters in length.\nMust be smaller than 10MB and 400.000 characters\nfor HasteBin upload. diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/control/ControlPanel.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/control/ControlPanel.kt index aed47707b..dab3eef6a 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/control/ControlPanel.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/control/ControlPanel.kt @@ -146,6 +146,14 @@ class ControlPanel( } if (!apiWrapper.configurationHandler!!.checkConfiguration(packConfig, encounteredErrors, true)) { + if (activeTab.getModpackDirectory().endsWith(".zip",ignoreCase = true)) { + JOptionPane.showMessageDialog( + panel.parent, + Gui.createserverpack_gui_config_zip_info_message.toString(), + Gui.createserverpack_gui_config_zip_info_title.toString(), + JOptionPane.INFORMATION_MESSAGE + ) + } log.info("Config check passed.") statusPanel.updateStatus(Gui.createserverpack_log_info_buttoncreateserverpack_checked.toString()) generateServerPack(packConfig)