Skip to content

Commit

Permalink
fix: Allow and improve inclusion-specs entering correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Griefed committed Dec 10, 2023
1 parent 613a43c commit 80e6f05
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ class ListUtilities {
while (true) {
stringArray = readln()
if (stringArray.isEmpty()) {
return result
break
} else {
result.add(stringArray)
}
}
return result
}

/**
Expand Down
11 changes: 9 additions & 2 deletions serverpackcreator-cli/src/main/i18n/Cli_en_GB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ cli.copyfiles.entries=You have entries in your list of files/folder to include i
cli.copyfiles.over=Would you like to edit (1) that list, start over (2), or list the files in your modpack directory (3) again?
cli.copyfiles.modpack.list=The modpack directory you specified contains the following directories:
cli.copyfiles.modpack.empty=No files or directories found in {0}
cli.copyfiles.entries.custom.intro=Enter new inclusion-specifications, one per line.
cli.copyfiles.entries.custom.intro2=An inclusion-specification consists of source, destination, inclusion-regex, exclusion-regex.
cli.copyfiles.entries.custom.intro3=Only the source is mandatory, the rest can be left empty. An example would be: mods,,,
cli.copyfiles.entries.prefix.source=Source
cli.copyfiles.entries.prefix.destination=Destination
cli.copyfiles.entries.prefix.inclusion=Inclusion-Regex
cli.copyfiles.entries.prefix.exclusion=Exclusion-Regex
cli.setting.satisfied=Are you satisfied with this setting?
cli.icon.include.intro=Do you want ServerPackCreator to include a server-icon in your server pack? Must be true or false.
cli.icon.include.input=Include server-icon.png:
Expand Down Expand Up @@ -89,8 +96,8 @@ cli.config.load.edit.success=Configuration successfully loaded.
cli.config.check.error=Encountered the following errors:
cli.config.check.success=No errors encountered.
cli.config.save.intro=Would you like to save this configuration as an additional, separate, configuration file?
cli.config.save.name=Enter the name under which you want to additionally store the above configuration:
cli.config.save.saved=Your configuration has been saved as {0}.
cli.config.save.name=Enter the path under which you want to additionally store the above configuration, example "C:\\Users\\YourUser\\Documents\\myconfig.conf":
cli.config.save.saved=Your configuration has been saved to {0}.
cli.config.save.info=Please note that running ServerPackCreator in CLI mode requires a valid 'serverpackcreator.conf'-file to be present.
cli.config.save.load=You may load the previous configuration, saved as {0} and save it as 'serverpackcreator.conf'
cli.config.save.saved.default=Your configuration has been saved as 'serverpackcreator.conf'.
Original file line number Diff line number Diff line change
Expand Up @@ -452,19 +452,17 @@ class ConfigurationEditor(
*/
private fun newCustomInclusionsList(): List<InclusionSpecification> {
val inclusions = mutableListOf<InclusionSpecification>()
cliLog(Cli.cli_copyfiles_entries_custom_intro.toString())
cliLog(Cli.cli_copyfiles_entries_custom_intro2.toString())
cliLog(Cli.cli_copyfiles_entries_custom_intro3.toString())
val custom: List<String> = utilities.listUtilities.readStringList()
var split: List<String>
cliLog(Cli.cli_answer_input_newline.toString())
for (i in custom.indices) {
split = custom[i].split(",")
inclusions.add(InclusionSpecification(split[0],split[1],split[2],split[3]))
}
for (i in inclusions.indices) {
cliLog(" ${i + 1}. ${inclusions[i].source}")
cliLog(" ${i + 1}. ${inclusions[i].destination}")
cliLog(" ${i + 1}. ${inclusions[i].inclusionFilter}")
cliLog(" ${i + 1}. ${inclusions[i].exclusionFilter}")
}
logInclusionSpecs(inclusions)
return inclusions
}

Expand All @@ -486,12 +484,7 @@ class ConfigurationEditor(
if (inclusions.isNotEmpty()) {
cliLog(Cli.cli_copyfiles_entries.toString())
cliLog()
for (inclusion in inclusions) {
cliLog(inclusion.source)
cliLog(inclusion.destination ?: "null")
cliLog(inclusion.inclusionFilter ?: "null")
cliLog(inclusion.exclusionFilter ?: "null")
}
logInclusionSpecs(inclusions)
cliLog()
cliLog(Cli.cli_copyfiles_over.toString())
selection = getDecision(scanner, 1, 3)
Expand All @@ -509,20 +502,23 @@ class ConfigurationEditor(
cliLog(Cli.cli_answer.toString(), false)
} while (!utilities.booleanUtilities.readBoolean())
cliLog(Cli.cli_list_yours.toString())
logInclusionSpecs(inclusions)
cliLog()
}

private fun logInclusionSpecs(inclusions: List<InclusionSpecification>) {
for (i in inclusions.indices) {
cliLog(" ${i + 1}. ${inclusions[i]}")
cliLog("${i + 1}. ${Cli.cli_copyfiles_entries_prefix_source}: ${inclusions[i].source}")
cliLog("${i + 1}. ${Cli.cli_copyfiles_entries_prefix_destination}: ${inclusions[i].destination}")
cliLog("${i + 1}. ${Cli.cli_copyfiles_entries_prefix_inclusion}: ${inclusions[i].inclusionFilter}")
cliLog("${i + 1}. ${Cli.cli_copyfiles_entries_prefix_exclusion}: ${inclusions[i].exclusionFilter}")
cliLog("")
}
cliLog()
}

private fun editInclusions(scanner: Scanner, inclusions: MutableList<InclusionSpecification>) {
cliLog(Cli.cli_list_entries.toString())
for (i in inclusions.indices) {
cliLog("($i) Source : ${inclusions[i].source}")
cliLog("($i) Destination : ${inclusions[i].source}")
cliLog("($i) Inclusion-Filter : ${inclusions[i].source}")
cliLog("($i) Exclusion-Filter : ${inclusions[i].source}")
}
logInclusionSpecs(inclusions)
val max = inclusions.size - 1
do {
cliLog(Cli.cli_list_which.toString())
Expand All @@ -547,12 +543,7 @@ class ConfigurationEditor(
cliLog(Cli.cli_list_satisfied.toString())
cliLog(Cli.cli_answer.toString(), false)
} while (!utilities.booleanUtilities.readBoolean())
for (inclusion in inclusions) {
cliLog(inclusion.source)
cliLog(inclusion.destination ?: "null")
cliLog(inclusion.inclusionFilter ?: "null")
cliLog(inclusion.exclusionFilter ?: "null")
}
logInclusionSpecs(inclusions)
cliLog(Cli.cli_list_success.toString())
}

Expand Down Expand Up @@ -627,20 +618,6 @@ class ConfigurationEditor(
return serverPropertiesPath
}

/**
* Get the users decision on whether they want to include the modloader server installation.
*
* @return `true` if the user wants the modloader server to be installed.
* @author Griefed
*/
private fun installModloaderServer(): Boolean {
cliLog(Cli.cli_server_intro.toString())
cliLog(Cli.cli_server_input.toString(), false)
val includeServerInstallation: Boolean = utilities.booleanUtilities.readBoolean()
cliLog(Cli.cli_answer_input(includeServerInstallation))
return includeServerInstallation
}

/**
* Get the users modpacks Minecraft version.
*
Expand Down Expand Up @@ -800,9 +777,9 @@ class ConfigurationEditor(
cliLog(Cli.cli_config_save_intro.toString())
if (utilities.booleanUtilities.readBoolean()) {
cliLog(Cli.cli_config_save_name.toString())
val customFileName = File(utilities.stringUtilities.pathSecureText(getNextLine(scanner)))
val customFileName = File(utilities.stringUtilities.pathSecureText(getNextLine(scanner))).absoluteFile
packConfig.save(customFileName, apiProperties)
cliLog(Cli.cli_config_save_saved(customFileName))
cliLog(Cli.cli_config_save_saved(customFileName.absolutePath))
cliLog(Cli.cli_config_save_info.toString())
cliLog(Cli.cli_config_save_load(customFileName))
} else {
Expand Down

0 comments on commit 80e6f05

Please sign in to comment.