diff --git a/.runConfigurations/Main Web Dev.run.xml b/.runConfigurations/Main Web Dev.run.xml index 32d3e65b49e615db194987e244ada48385ff3e8c..1caa5eac8aa1afac12983b79773f9e3c3fcb742a 100644 --- a/.runConfigurations/Main Web Dev.run.xml +++ b/.runConfigurations/Main Web Dev.run.xml @@ -1,6 +1,6 @@ <component name="ProjectRunConfigurationManager"> <configuration default="false" name="Run as dev-webservice" type="Application" factoryName="Application"> - <option name="ALTERNATIVE_JRE_PATH" value="1.8" /> + <option name="ALTERNATIVE_JRE_PATH" value="BUNDLED" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" /> <envs> <env name="spring.profiles.active" value="dev" /> diff --git a/.runConfigurations/Main.run.xml b/.runConfigurations/Main.run.xml index 347f25350e0ff351dec24f6036d765406d6d882e..97ad2f9b8a228b6b3fa7850ef8beb6dab80ff315 100644 --- a/.runConfigurations/Main.run.xml +++ b/.runConfigurations/Main.run.xml @@ -1,6 +1,6 @@ <component name="ProjectRunConfigurationManager"> <configuration default="false" name="Run" type="Application" factoryName="Application"> - <option name="ALTERNATIVE_JRE_PATH" value="1.8" /> + <option name="ALTERNATIVE_JRE_PATH" value="BUNDLED" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" /> <option name="MAIN_CLASS_NAME" value="de.griefed.serverpackcreator.ServerPackCreator" /> <module name="ServerPackCreator.main" /> diff --git a/.runConfigurations/Run as webservice.run.xml b/.runConfigurations/Run as webservice.run.xml index 2b19ea3972ed8c25c95d5ca2b5784a53f29fc574..e89323e44da73a08f972e8ac4cd5ea68d1324144 100644 --- a/.runConfigurations/Run as webservice.run.xml +++ b/.runConfigurations/Run as webservice.run.xml @@ -1,6 +1,6 @@ <component name="ProjectRunConfigurationManager"> <configuration default="false" name="Run as webservice" type="Application" factoryName="Application"> - <option name="ALTERNATIVE_JRE_PATH" value="1.8" /> + <option name="ALTERNATIVE_JRE_PATH" value="BUNDLED" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" /> <option name="MAIN_CLASS_NAME" value="de.griefed.serverpackcreator.ServerPackCreator" /> <module name="ServerPackCreator.main" /> diff --git a/backend/main/java/de/griefed/serverpackcreator/ApplicationProperties.java b/backend/main/java/de/griefed/serverpackcreator/ApplicationProperties.java index 786ef86e988c281c2ff423418c42c2ff4046d74b..9df5c04d6395bb1c6f9e1a935b6c652242be5b72 100644 --- a/backend/main/java/de/griefed/serverpackcreator/ApplicationProperties.java +++ b/backend/main/java/de/griefed/serverpackcreator/ApplicationProperties.java @@ -51,9 +51,6 @@ public class ApplicationProperties extends Properties { // ServerPackHandler related private final File SERVERPACKCREATOR_PROPERTIES = new File("serverpackcreator.properties"); - private final File START_SCRIPT_WINDOWS = new File("start.bat"); - private final File START_SCRIPT_LINUX = new File("start.sh"); - private final File USER_JVM_ARGS = new File("user_jvm_args.txt"); private final String FALLBACK_MODS_DEFAULT_ASSTRING = "3dSkinLayers-," @@ -212,25 +209,29 @@ public class ApplicationProperties extends Properties { + "WindowedFullscreen-," + "WorldNameRandomizer-," + "yisthereautojump-"; - private final String SERVERPACKCREATOR_VERSION; - private final String[] SUPPORTED_MODLOADERS = new String[] {"Fabric", "Forge", "Quilt"}; - private final List<String> FALLBACK_CLIENTSIDE_MODS = new ArrayList<>(Arrays.asList(FALLBACK_MODS_DEFAULT_ASSTRING.split(","))); - + private final String SERVERPACKCREATOR_VERSION; + private final String[] SUPPORTED_MODLOADERS = new String[] {"Fabric", "Forge", "Quilt"}; private final String FALLBACK_DIRECTORIES_INCLUDE_ASSTRING = "mods,config,defaultconfigs,scripts"; private final List<String> FALLBACK_DIRECTORIES_INCLUDE = new ArrayList<>(Arrays.asList(FALLBACK_DIRECTORIES_INCLUDE_ASSTRING.split(","))); - private final String FALLBACK_DIRECTORIES_EXCLUDE_ASSTRING = "overrides,packmenu,resourcepacks,server_pack,fancymenu,libraries"; private final List<String> FALLBACK_DIRECTORIES_EXCLUDE = new ArrayList<>(Arrays.asList(FALLBACK_DIRECTORIES_EXCLUDE_ASSTRING.split(","))); - private final String FALLBACK_FILES_EXCLUDE_ZIP_ASSTRING = "minecraft_server.MINECRAFT_VERSION.jar,server.jar,libraries/net/minecraft/server/MINECRAFT_VERSION/server-MINECRAFT_VERSION.jar"; private final List<String> FALLBACK_FILES_EXCLUDE_ZIP = new ArrayList<>(Arrays.asList(FALLBACK_FILES_EXCLUDE_ZIP_ASSTRING.split(","))); + private final String DEFAULT_SHELL_TEMPALTE = "default_template.sh"; + private final String DEFAULT_POWERSHELL_TEMPLATE = "default_template.ps1"; + + private final List<File> FALLBACK_SCRIPT_TEMPLATES = + new ArrayList<>( + Arrays.asList( + new File("server_files/" + DEFAULT_SHELL_TEMPALTE), + new File("server_files/" + DEFAULT_POWERSHELL_TEMPLATE))); // DefaultFiles related private final File DEFAULT_CONFIG = new File("serverpackcreator.conf"); @@ -309,6 +310,9 @@ public class ApplicationProperties extends Properties { /** Whether the exclusion of files from the server pack is enabled. */ private boolean isZipFileExclusionEnabled; + /** List of templates used for start-script creation. */ + private List<File> scriptTemplates; + /** * Constructor for our properties. Sets a couple of default values for use in ServerPackCreator. * @@ -532,47 +536,77 @@ public class ApplicationProperties extends Properties { this.isZipFileExclusionEnabled = Boolean.parseBoolean( getProperty("de.griefed.serverpackcreator.serverpack.zip.exclude.enabled", "true")); + + // Setup our start script template list + if (this.getProperty("de.griefed.serverpackcreator.serverpack.script.template") == null) { + + this.scriptTemplates = this.FALLBACK_SCRIPT_TEMPLATES; + LOG.debug("Script template property null. Using fallback."); + + } else if (this.getProperty("de.griefed.serverpackcreator.serverpack.script.template") + .contains(",")) { + + this.scriptTemplates = new ArrayList<>(10); + + for (String template : + this.getProperty("de.griefed.serverpackcreator.serverpack.script.template").split(",")) { + scriptTemplates.add(new File("server_files/" + template)); + } + + } else { + + this.scriptTemplates = + Collections.singletonList( + (new File( + "server_files/" + + this.getProperty( + "de.griefed.serverpackcreator.configuration.fallbackmodslist")))); + } + LOG.debug("Script templates set to: " + this.scriptTemplates); } /** - * Properties file used by ServerPackCreator, containing the configuration for this instance of - * it. + * Default list of script templates, used in case not a single one was configured. * - * @return {@link File} serverpackcreator.properties-file. + * <ul> + * <li>default_template.sh + * <li>default_template.ps1 + * </ul> + * + * @return {@link List} {@link File} Default script templates. * @author Griefed */ - public File SERVERPACKCREATOR_PROPERTIES() { - return SERVERPACKCREATOR_PROPERTIES; + public List<File> FALLBACK_SCRIPT_TEMPLATES() { + return FALLBACK_SCRIPT_TEMPLATES; } - /** - * Start script for server packs, used by Windows. - * - * @return {@link File} start.bat-file. - * @author Griefed - */ - public File START_SCRIPT_WINDOWS() { - return START_SCRIPT_WINDOWS; + public File DEFAULT_SHELL_TEMPLATE() { + return new File(DEFAULT_SHELL_TEMPALTE); + } + + public File DEFAULT_POWERSHELL_TEMPLATE() { + return new File(DEFAULT_POWERSHELL_TEMPLATE); } /** - * Start script for server packs, used by UNIX/Linux. + * Configured list of script templates. * - * @return {@link File} start.sh-file. + * @return {@link List} {@link File} Configured script templates. * @author Griefed */ - public File START_SCRIPT_LINUX() { - return START_SCRIPT_LINUX; + public List<File> scriptTemplates() { + return scriptTemplates; } /** - * JVM args file used by Forge MC 1.17+ + * Properties file used by ServerPackCreator, containing the configuration for this instance of + * it. * - * @return {@link File} user_jvm_args.txt-file. + * @return {@link File} serverpackcreator.properties-file. * @author Griefed */ - public File USER_JVM_ARGS() { - return USER_JVM_ARGS; + public File SERVERPACKCREATOR_PROPERTIES() { + return SERVERPACKCREATOR_PROPERTIES; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/ConfigurationHandler.java b/backend/main/java/de/griefed/serverpackcreator/ConfigurationHandler.java index 6bd0da65c2dddec92a324df5122fba947a3ed80e..214580e09c680863e743e49e46da051c6ff0837f 100644 --- a/backend/main/java/de/griefed/serverpackcreator/ConfigurationHandler.java +++ b/backend/main/java/de/griefed/serverpackcreator/ConfigurationHandler.java @@ -21,7 +21,7 @@ package de.griefed.serverpackcreator; import com.electronwill.nightconfig.core.file.FileConfig; import com.typesafe.config.ConfigException; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.utilities.ConfigUtilities; import de.griefed.serverpackcreator.utilities.common.FileUtilities; import de.griefed.serverpackcreator.utilities.common.InvalidFileTypeException; @@ -36,6 +36,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Properties; import org.apache.commons.io.FileUtils; @@ -56,7 +57,7 @@ public class ConfigurationHandler { private static final Logger LOG = LogManager.getLogger(ConfigurationHandler.class); - private final LocalizationManager LOCALIZATIONMANAGER; + private final I18n I18N; private final VersionMeta VERSIONMETA; private final ApplicationProperties APPLICATIONPROPERTIES; private final Utilities UTILITIES; @@ -67,11 +68,10 @@ public class ConfigurationHandler { * * <p>Used for Dependency Injection. * - * <p>Receives an instance of {@link LocalizationManager} or creates one if the received one is - * null. Required for use of localization. + * <p>Receives an instance of {@link I18n} or creates one if the received one is null. Required + * for use of localization. * - * @param injectedLocalizationManager Instance of {@link LocalizationManager} required for - * localized log messages. + * @param injectedI18n Instance of {@link I18n} required for localized log messages. * @param injectedApplicationProperties Instance of {@link Properties} required for various * different things. * @param injectedVersionMeta Instance of {@link VersionMeta} required for everything @@ -83,7 +83,7 @@ public class ConfigurationHandler { */ @Autowired public ConfigurationHandler( - LocalizationManager injectedLocalizationManager, + I18n injectedI18n, VersionMeta injectedVersionMeta, ApplicationProperties injectedApplicationProperties, Utilities injectedUtilities, @@ -96,10 +96,10 @@ public class ConfigurationHandler { this.APPLICATIONPROPERTIES = injectedApplicationProperties; } - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + if (injectedI18n == null) { + this.I18N = new I18n(APPLICATIONPROPERTIES); } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; + this.I18N = injectedI18n; } if (injectedVersionMeta == null) { @@ -116,14 +116,14 @@ public class ConfigurationHandler { } if (injectedUtilities == null) { - this.UTILITIES = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + this.UTILITIES = new Utilities(I18N, APPLICATIONPROPERTIES); } else { this.UTILITIES = injectedUtilities; } if (injectedConfigUtilities == null) { this.CONFIGUTILITIES = - new ConfigUtilities(LOCALIZATIONMANAGER, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); + new ConfigUtilities(I18N, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); } else { this.CONFIGUTILITIES = injectedConfigUtilities; } @@ -253,9 +253,12 @@ public class ConfigurationHandler { try { config = FileConfig.of(configFile); } catch (ConfigException ex) { - /* This log is meant to be read by the user, therefore we allow translation. */ + LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkconfig.start")); + "Couldn't parse config file. Consider checking your config file and fixing empty values. If the value needs to be an empty string, leave its value to \"\"."); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.checkconfig.start")); } if (config != null) { @@ -263,11 +266,12 @@ public class ConfigurationHandler { try { config.load(); } catch (ConfigException ex) { - /* This log is meant to be read by the user, therefore we allow translation. */ + LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkconfig.start")); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkconfig.start")); + "Couldn't parse config file. Consider checking your config file and fixing empty values. If the value needs to be an empty string, leave its value to \"\"."); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.checkconfig.start")); } configurationModel.setClientMods( @@ -305,8 +309,11 @@ public class ConfigurationHandler { } else { - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkconfig.start")); + LOG.error( + "Couldn't parse config file. Consider checking your config file and fixing empty values. If the value needs to be an empty string, leave its value to \"\"."); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.checkconfig.start")); } return checkConfiguration(configurationModel, encounteredErrors, quietCheck); @@ -342,13 +349,11 @@ public class ConfigurationHandler { sanitizeLinks(configurationModel); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkconfig.start")); + LOG.info("Checking configuration..."); if (configurationModel.getClientMods().isEmpty()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.warn.checkconfig.clientmods")); + + LOG.warn("No clientside-only mods specified. Using fallback list."); configurationModel.setClientMods(APPLICATIONPROPERTIES.getListFallbackMods()); } else { configurationModel.setClientMods(configurationModel.getClientMods()); @@ -362,9 +367,13 @@ public class ConfigurationHandler { //noinspection UnusedAssignment configHasError = true; + LOG.error( + "The specified server-icon does not exist: " + configurationModel.getServerIconPath()); + + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.servericon"), + I18N.getMessage("configuration.log.error.servericon"), configurationModel.getServerIconPath())); } else if (configurationModel.getServerIconPath().length() > 0 @@ -374,10 +383,12 @@ public class ConfigurationHandler { //noinspection UnusedAssignment configHasError = true; + LOG.error("No read-permission for " + configurationModel.getServerIconPath()); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkcopydirs.read"), + I18N.getMessage("configuration.log.error.checkcopydirs.read"), configurationModel.getServerIconPath())); } @@ -386,9 +397,14 @@ public class ConfigurationHandler { //noinspection UnusedAssignment configHasError = true; + LOG.error( + "The specified server.properties does not exist: " + + configurationModel.getServerPropertiesPath()); + + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.serverproperties"), + I18N.getMessage("configuration.log.error.serverproperties"), configurationModel.getServerPropertiesPath())); } else if (configurationModel.getServerPropertiesPath().length() > 0 @@ -399,10 +415,12 @@ public class ConfigurationHandler { //noinspection UnusedAssignment configHasError = true; + LOG.error("No read-permission for " + configurationModel.getServerPropertiesPath()); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkcopydirs.read"), + I18N.getMessage("configuration.log.error.checkcopydirs.read"), configurationModel.getServerPropertiesPath())); } @@ -433,66 +451,53 @@ public class ConfigurationHandler { } else { configHasError = true; - LOG.error(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkmodpackdir")); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkmodpackdir")); + LOG.error("Modpack directory not specified. Please specify an existing directory."); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.checkmodpackdir")); } if (checkModloader(configurationModel.getModLoader())) { if (VERSIONMETA.minecraft().checkMinecraftVersion(configurationModel.getMinecraftVersion())) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.debug( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.debug.isdir.minecraftversion")); - - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.debug( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.debug.isdir.modloader")); + LOG.debug("minecraftVersion setting check passed."); + LOG.debug("modLoader setting check passed."); if (checkModloaderVersion( configurationModel.getModLoader(), configurationModel.getModLoaderVersion(), configurationModel.getMinecraftVersion())) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.debug( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.debug.isdir.modloaderversion")); + LOG.debug("modLoaderVersion setting check passed."); } else { configHasError = true; + LOG.error("There's something wrong with your Modloader version setting."); + /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.isdir.modloaderversion")); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkmodloaderversion")); + encounteredErrors.add(I18N.getMessage("configuration.log.error.checkmodloaderversion")); } } else { configHasError = true; + LOG.error("There's something wrong with your Minecraft version setting."); + /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.isdir.minecraftversion")); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.minecraft")); + encounteredErrors.add(I18N.getMessage("configuration.log.error.minecraft")); } } else { configHasError = true; + LOG.error("There's something wrong with your Modloader or Modloader version setting."); + /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.isdir.modloader")); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkmodloader")); + encounteredErrors.add(I18N.getMessage("configuration.log.error.checkmodloader")); } if (quietCheck) { @@ -501,19 +506,16 @@ public class ConfigurationHandler { if (!configHasError) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkconfig.success")); + LOG.info("Config check successful. No errors encountered."); } else { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkconfig.failure")); - + LOG.error("Config check not successful. Check your config for errors."); printEncounteredErrors(encounteredErrors); } + ensureScriptSettingsDefaults(configurationModel); + return configHasError; } @@ -535,16 +537,16 @@ public class ConfigurationHandler { if (checkCopyDirs( configurationModel.getCopyDirs(), configurationModel.getModpackDir(), encounteredErrors)) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.debug(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.debug.isdir.copydirs")); + LOG.debug("copyDirs setting check passed."); } else { configHasError = true; + LOG.error( + "There's something wrong with your setting of directories to include in your server pack."); + /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.isdir.copydir")); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.isdir.copydir")); + encounteredErrors.add(I18N.getMessage("configuration.log.error.isdir.copydir")); } return configHasError; @@ -650,8 +652,9 @@ public class ConfigurationHandler { } catch (IOException ex) { LOG.error("Error parsing CurseForge manifest.json from ZIP-file.", ex); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.manifest")); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.zip.manifest")); configHasError = true; } @@ -670,6 +673,7 @@ public class ConfigurationHandler { packName = String.format( "./work/modpacks/%s", configurationModel.getCurseModpack().get("name").asText()); + } catch (NullPointerException npe) { //noinspection ConstantConditions @@ -679,8 +683,9 @@ public class ConfigurationHandler { } catch (IOException ex) { LOG.error("Error parsing minecraftinstance.json from ZIP-file.", ex); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.instance")); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.zip.instance")); configHasError = true; } @@ -710,8 +715,9 @@ public class ConfigurationHandler { } catch (IOException ex) { LOG.error("Error parsing config.json from ZIP-file.", ex); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.config")); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.zip.config")); configHasError = true; } @@ -726,8 +732,9 @@ public class ConfigurationHandler { } catch (IOException ex) { LOG.error("Error parsing mmc-pack.json from ZIP-file.", ex); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.mmcpack")); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.zip.mmcpack")); configHasError = true; } @@ -864,12 +871,14 @@ public class ConfigurationHandler { if (foldersInModpackZip.size() == 1) { LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.overrides"), - foldersInModpackZip.get(0))); + "The ZIP-file you specified only contains one directory: " + + foldersInModpackZip.get(0) + + ". ZIP-files for ServerPackCreator must be full modpacks, with all their contents being in the root of the ZIP-file."); + + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.overrides"), + I18N.getMessage("configuration.log.error.zip.overrides"), foldersInModpackZip.get(0))); return true; @@ -878,9 +887,10 @@ public class ConfigurationHandler { } else if (!foldersInModpackZip.contains("mods") || !foldersInModpackZip.contains("config")) { LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.modsorconfig")); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.modsorconfig")); + "The ZIP-file you specified does not contain the mods or config directories. What use is a modded server without mods and their configurations?"); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.zip.modsorconfig")); return true; } @@ -888,8 +898,9 @@ public class ConfigurationHandler { } catch (IOException ex) { LOG.error("Couldn't acquire directories in ZIP-file.", ex); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.zip.directories")); + + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.zip.directories")); return true; } @@ -897,6 +908,78 @@ public class ConfigurationHandler { return false; } + /** + * Update the script settings and ensure the default keys, with values gathered from the passed + * {@link ConfigurationModel}, are present: + * + * <ol> + * <li><code>SPC_SERVERPACKCREATOR_VERSION_SPC</code> : <code> + * ServerPackCreator version with which the scripts were created</code> + * <li><code>SPC_MINECRAFT_VERSION_SPC</code> : <code>Minecraft version of the modpack</code> + * <li><code>SPC_MINECRAFT_SERVER_URL_SPC</code> : <code>Download-URL to the Minecraft server + * </code> + * <li><code>SPC_MODLOADER_SPC</code> : <code>The modloader of the modpack</code> + * <li><code>SPC_MODLOADER_VERSION_SPC</code> : <code>The modloader version of the modpack + * </code> + * <li><code>SPC_JAVA_ARGS_SPC</code> : <code>The JVM args to be used to run the server</code> + * <li><code>SPC_JAVA_SPC</code> : <code> + * Path to the java installation to be used to run the server</code> + * <li><code>SPC_FABRIC_INSTALLER_VERSION_SPC</code> : <code> + * Most recent version of the Fabric installer at the time of creating the scripts</code> + * <li><code>SPC_QUILT_INSTALLER_VERSION_SPC</code> : <code> + * Most recent version of the Quilt installer at the time of creating the scripts</code> + * </ol> + * + * @param configurationModel {@link ConfigurationModel} in which to ensure the default key-value + * pairs are present. + * @author Griefed + */ + private void ensureScriptSettingsDefaults(ConfigurationModel configurationModel) { + + HashMap<String, String> scriptSettings = configurationModel.getScriptSettings(); + + if (!VERSIONMETA.minecraft().getServer(configurationModel.getMinecraftVersion()).isPresent() + || !VERSIONMETA + .minecraft() + .getServer(configurationModel.getMinecraftVersion()) + .get() + .url() + .isPresent()) { + + scriptSettings.put( + "SPC_MINECRAFT_SERVER_URL_SPC",""); + + } else { + scriptSettings.put( + "SPC_MINECRAFT_SERVER_URL_SPC", + VERSIONMETA + .minecraft() + .getServer(configurationModel.getMinecraftVersion()) + .get() + .url() + .get() + .toString()); + } + + scriptSettings.put( + "SPC_SERVERPACKCREATOR_VERSION_SPC", APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION()); + scriptSettings.put("SPC_MINECRAFT_VERSION_SPC", configurationModel.getMinecraftVersion()); + + scriptSettings.put("SPC_MODLOADER_SPC", configurationModel.getModLoader()); + scriptSettings.put("SPC_MODLOADER_VERSION_SPC", configurationModel.getModLoaderVersion()); + scriptSettings.put("SPC_JAVA_ARGS_SPC", configurationModel.getJavaArgs()); + + // To be enhanced in a later milestone + scriptSettings.put("SPC_JAVA_SPC", "java"); + + scriptSettings.put( + "SPC_FABRIC_INSTALLER_VERSION_SPC", VERSIONMETA.fabric().releaseInstallerVersion()); + scriptSettings.put( + "SPC_QUILT_INSTALLER_VERSION_SPC", VERSIONMETA.quilt().releaseInstallerVersion()); + + configurationModel.setScriptSettings(scriptSettings); + } + /** * Sanitize any and all links in a given instance of {@link ConfigurationModel} modpack-directory, * server-icon path, server-properties path, Java path and copy-directories entries. @@ -1085,9 +1168,7 @@ public class ConfigurationHandler { private void printEncounteredErrors(List<String> encounteredErrors) { LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.encountered"), - encounteredErrors.size())); + "Encountered " + encounteredErrors.size() + " errors during the configuration check."); //noinspection UnusedAssignment int encounteredErrorNumber = 0; @@ -1096,12 +1177,7 @@ public class ConfigurationHandler { encounteredErrorNumber = i + 1; - LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.encountered.specific"), - encounteredErrorNumber, - encounteredErrors.get(i))); + LOG.error("Error " + encounteredErrorNumber + ": " + encounteredErrors.get(i)); } } @@ -1133,23 +1209,18 @@ public class ConfigurationHandler { if (modpackDir.isEmpty()) { + LOG.error("Modpack directory not specified. Please specify an existing directory."); + /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkmodpackdir")); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkmodpackdir")); + encounteredErrors.add(I18N.getMessage("configuration.log.error.checkmodpackdir")); } else if (!(new File(modpackDir).isDirectory())) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.warn( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.warn.checkmodpackdir"), - modpackDir)); + LOG.warn("Couldn't find directory " + modpackDir + "."); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.modpackdirectory"), - modpackDir)); + String.format(I18N.getMessage("configuration.log.error.modpackdirectory"), modpackDir)); } else { @@ -1205,37 +1276,29 @@ public class ConfigurationHandler { configCorrect = false; - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkcopydirs.empty")); + "No directories or files specified for copying. This would result in an empty serverpack."); - encounteredErrors.add( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkcopydirs.empty")); + /* This log is meant to be read by the user, therefore we allow translation. */ + encounteredErrors.add(I18N.getMessage("configuration.log.error.checkcopydirs.empty")); } else if (directoriesToCopy.size() == 1 && directoriesToCopy.get(0).equals("lazy_mode")) { LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode0")); + "!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!"); LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode1")); + "Lazy mode specified. This will copy the WHOLE modpack to the server pack. No exceptions."); + LOG.warn("You will not receive support from me for a server pack generated this way."); LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode2")); + "Do not open an issue on GitHub if this configuration errors or results in a broken server pack."); LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode3")); - LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode0")); + "!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!"); } else { if (directoriesToCopy.size() > 1 && directoriesToCopy.contains("lazy_mode")) LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode.ignore")); + "You specified lazy mode in your configuration, but your copyDirs configuration contains other entries. To use the lazy mode, only specify \"lazy_mode\" and nothing else. Ignoring lazy mode."); directoriesToCopy.removeIf(entry -> entry.equals("lazy_mode")); @@ -1259,17 +1322,15 @@ public class ConfigurationHandler { configCorrect = false; - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.filenotfound"), - sourceFileToCheck)); + "Copy-file " + + sourceFileToCheck + + " does not exist. Please specify existing files."); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.filenotfound"), + I18N.getMessage("configuration.log.error.checkcopydirs.filenotfound"), sourceFileToCheck)); } else { @@ -1284,11 +1345,15 @@ public class ConfigurationHandler { configCorrect = false; + LOG.error( + "No read-permission for " + + String.format( + "%s/%s", modpackDir, sourceFileDestinationFileCombination[0])); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), + I18N.getMessage("configuration.log.error.checkcopydirs.read"), String.format("%s/%s", modpackDir, sourceFileDestinationFileCombination[0]))); } else if (new File( @@ -1301,11 +1366,15 @@ public class ConfigurationHandler { configCorrect = false; + LOG.error( + "No read-permission for " + + String.format( + "%s/%s", modpackDir, sourceFileDestinationFileCombination[0])); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), + I18N.getMessage("configuration.log.error.checkcopydirs.read"), String.format("%s/%s", modpackDir, sourceFileDestinationFileCombination[0]))); } else if (new File(sourceFileDestinationFileCombination[0]).exists() @@ -1314,11 +1383,12 @@ public class ConfigurationHandler { configCorrect = false; + LOG.error("No read-permission for " + sourceFileDestinationFileCombination[0]); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), + I18N.getMessage("configuration.log.error.checkcopydirs.read"), sourceFileDestinationFileCombination[0])); } @@ -1335,12 +1405,12 @@ public class ConfigurationHandler { if (!UTILITIES.FileUtils().checkReadPermission(file)) { configCorrect = false; + LOG.error("No read-permission for " + file); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), - file)); + I18N.getMessage("configuration.log.error.checkcopydirs.read"), file)); } } @@ -1351,12 +1421,12 @@ public class ConfigurationHandler { if (!UTILITIES.FileUtils().checkReadPermission(file)) { configCorrect = false; + LOG.error("No read-permission for " + file); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), - file)); + I18N.getMessage("configuration.log.error.checkcopydirs.read"), file)); } } } @@ -1393,18 +1463,15 @@ public class ConfigurationHandler { configCorrect = false; - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.notfound"), - directory)); + "Copy-file or copy-directory " + + directory + + " does not exist. Please specify existing directories or files."); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.notfound"), - directory)); + I18N.getMessage("configuration.log.error.checkcopydirs.notfound"), directory)); } else { @@ -1412,24 +1479,24 @@ public class ConfigurationHandler { configCorrect = false; + LOG.error("No read-permission for " + dirToCheck); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), - dirToCheck)); + I18N.getMessage("configuration.log.error.checkcopydirs.read"), dirToCheck)); } else if (new File(directory).exists() && !UTILITIES.FileUtils().checkReadPermission(directory)) { configCorrect = false; + LOG.error("No read-permission for " + directory); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), - directory)); + I18N.getMessage("configuration.log.error.checkcopydirs.read"), directory)); } if (dirToCheck.isDirectory()) { @@ -1439,12 +1506,12 @@ public class ConfigurationHandler { if (!UTILITIES.FileUtils().checkReadPermission(file)) { configCorrect = false; + LOG.error("No read-permission for " + file); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), - file)); + I18N.getMessage("configuration.log.error.checkcopydirs.read"), file)); } } @@ -1455,12 +1522,12 @@ public class ConfigurationHandler { if (!UTILITIES.FileUtils().checkReadPermission(file)) { configCorrect = false; + LOG.error("No read-permission for " + file); + /* This log is meant to be read by the user, therefore we allow translation. */ encounteredErrors.add( String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkcopydirs.read"), - file)); + I18N.getMessage("configuration.log.error.checkcopydirs.read"), file)); } } } @@ -1642,8 +1709,7 @@ public class ConfigurationHandler { } else { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkmodloader")); + LOG.error("Invalid modloader specified. Modloader must be either Forge, Fabric or Quilt."); return false; } @@ -1677,11 +1743,8 @@ public class ConfigurationHandler { return VERSIONMETA.quilt().checkQuiltVersion(modloaderVersion); default: - - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.error( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.error.checkmodloaderversion")); + "Specified incorrect modloader version. Please check your modpack for the correct version and enter again."); return false; } diff --git a/backend/main/java/de/griefed/serverpackcreator/ConfigurationModel.java b/backend/main/java/de/griefed/serverpackcreator/ConfigurationModel.java index 04a8800c3f92956e4c2980e1e704661e0033c9bb..c7aab4703d0562f967d0a8c2e6feb28176e5862a 100644 --- a/backend/main/java/de/griefed/serverpackcreator/ConfigurationModel.java +++ b/backend/main/java/de/griefed/serverpackcreator/ConfigurationModel.java @@ -22,12 +22,12 @@ package de.griefed.serverpackcreator; import com.electronwill.nightconfig.core.file.FileConfig; import com.electronwill.nightconfig.core.file.NoFormatFoundException; import com.fasterxml.jackson.databind.JsonNode; -import com.typesafe.config.ConfigException; import de.griefed.serverpackcreator.utilities.common.Utilities; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; /** @@ -40,6 +40,7 @@ public class ConfigurationModel { private List<String> clientMods = new ArrayList<>(); private List<String> copyDirs = new ArrayList<>(); + private HashMap<String, String> scriptSettings = new HashMap<>(); private String modpackDir = ""; private String javaPath = ""; private String minecraftVersion = ""; @@ -71,18 +72,25 @@ public class ConfigurationModel { * @param clientMods String-{@link List} of clientside mods to exclude from the server pack. * @param copyDirs String-{@link List} of directories and/or files to include in the server pack. * @param modpackDir {@link String} The path to the modpack. - * @param javaPath {@link String} The path to the java installation used for modloader server installation. + * @param javaPath {@link String} The path to the java installation used for modloader server + * installation. * @param minecraftVersion {@link String} The Minecraft version the modpack uses. - * @param modLoader {@link String} The modloader the modpack uses. Either <code>Forge</code>, <code>Fabric</code> or <code>Quilt</code>. + * @param modLoader {@link String} The modloader the modpack uses. Either <code>Forge</code>, + * <code>Fabric</code> or <code>Quilt</code>. * @param modLoaderVersion {@link String} The modloader version the modpack uses. * @param javaArgs {@link String} JVM flags to create the start scripts with. * @param serverPackSuffix {@link String} Suffix to create the server pack with. * @param serverIconPath {@link String} Path to the icon to use in the server pack. - * @param serverPropertiesPath {@link String} Path to the server.properties to create the server pack with. - * @param includeServerInstallation {@link Boolean} Whether to install the modloader server in the server pack. - * @param includeServerIcon {@link Boolean} Whether to include the server-icon.png in the server pack. - * @param includeServerProperties {@link Boolean} Whether to include the server.properties in the server pack. + * @param serverPropertiesPath {@link String} Path to the server.properties to create the server + * pack with. + * @param includeServerInstallation {@link Boolean} Whether to install the modloader server in the + * server pack. + * @param includeServerIcon {@link Boolean} Whether to include the server-icon.png in the server + * pack. + * @param includeServerProperties {@link Boolean} Whether to include the server.properties in the + * server pack. * @param includeZipCreation {@link Boolean} Whether to create a ZIP-archive of the server pack. + * @param scriptSettings {@link HashMap} {@link String} {@link String} Map containing key-value pairs to be used in start script creation. * @author Griefed */ public ConfigurationModel( @@ -100,7 +108,8 @@ public class ConfigurationModel { boolean includeServerInstallation, boolean includeServerIcon, boolean includeServerProperties, - boolean includeZipCreation) { + boolean includeZipCreation, + HashMap<String, String> scriptSettings) { this.clientMods = clientMods; this.copyDirs = copyDirs; @@ -117,6 +126,7 @@ public class ConfigurationModel { this.includeServerIcon = includeServerIcon; this.includeServerProperties = includeServerProperties; this.includeZipCreation = includeZipCreation; + this.scriptSettings.putAll(scriptSettings); } /** @@ -127,7 +137,8 @@ public class ConfigurationModel { * @throws FileNotFoundException if the specified file can not be found. * @author Griefed */ - public ConfigurationModel(Utilities utilities, File configFile) throws FileNotFoundException, NoFormatFoundException { + public ConfigurationModel(Utilities utilities, File configFile) + throws FileNotFoundException, NoFormatFoundException { if (!configFile.exists()) { throw new FileNotFoundException("Couldn't find file: " + configFile); } @@ -136,8 +147,7 @@ public class ConfigurationModel { config.load(); - setClientMods( - config.getOrElse("clientMods", Collections.singletonList(""))); + setClientMods(config.getOrElse("clientMods", Collections.singletonList(""))); setCopyDirs(config.getOrElse("copyDirs", Collections.singletonList(""))); setModpackDir(config.getOrElse("modpackDir", "").replace("\\", "/")); setJavaPath(config.getOrElse("javaPath", "").replace("\\", "/")); @@ -149,10 +159,8 @@ public class ConfigurationModel { setServerPackSuffix( utilities.StringUtils().pathSecureText(config.getOrElse("serverPackSuffix", ""))); - setServerIconPath( - config.getOrElse("serverIconPath", "").replace("\\", "/")); - setServerPropertiesPath( - config.getOrElse("serverPropertiesPath", "").replace("\\", "/")); + setServerIconPath(config.getOrElse("serverIconPath", "").replace("\\", "/")); + setServerPropertiesPath(config.getOrElse("serverPropertiesPath", "").replace("\\", "/")); setIncludeServerInstallation( utilities.BooleanUtils() @@ -568,6 +576,28 @@ public class ConfigurationModel { this.serverPropertiesPath = serverPropertiesPath.replace("\\", "/"); } + /** + * Getter for the script settings used during script creation. + * + * @return {@link HashMap} {@link String}-{@link String} + * @author Griefed + */ + public HashMap<String, String> getScriptSettings() { + return scriptSettings; + } + + /** + * Putter for the script settings used during script creation. All key-value pairs from the passed + * hashmap are put into this models hashmap. + * + * @param scriptSettings {@link HashMap} {@link String}-{@link String} containing key-value pairs + * to be used in script creation. + * @author Griefed + */ + public void setScriptSettings(HashMap<String, String> scriptSettings) { + this.scriptSettings.putAll(scriptSettings); + } + @Override public String toString() { return "ConfigurationModel{" diff --git a/backend/main/java/de/griefed/serverpackcreator/ServerPackCreator.java b/backend/main/java/de/griefed/serverpackcreator/ServerPackCreator.java index bdd8f399e342556620bef4951396c2bcb5a88d38..0869fc5861ba0d607508758a79aebba30dcb7909 100644 --- a/backend/main/java/de/griefed/serverpackcreator/ServerPackCreator.java +++ b/backend/main/java/de/griefed/serverpackcreator/ServerPackCreator.java @@ -19,8 +19,8 @@ */ package de.griefed.serverpackcreator; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.i18n.IncorrectLanguageException; -import de.griefed.serverpackcreator.i18n.LocalizationManager; import de.griefed.serverpackcreator.plugins.ApplicationPlugins; import de.griefed.serverpackcreator.swing.ServerPackCreatorGui; import de.griefed.serverpackcreator.swing.ServerPackCreatorSplash; @@ -73,15 +73,15 @@ import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableScheduling @PropertySources({ - @PropertySource("classpath:application.properties"), - @PropertySource("classpath:serverpackcreator.properties") + @PropertySource("classpath:application.properties"), + @PropertySource("classpath:serverpackcreator.properties") }) public class ServerPackCreator { private static final Logger LOG = LogManager.getLogger(ServerPackCreator.class); private final CommandlineParser COMMANDLINE_PARSER; private final ApplicationProperties APPLICATIONPROPERTIES; - private final LocalizationManager LOCALIZATIONMANAGER; + private final I18n I18N; private final String[] ARGS; private final File LOG4J2XML = new File("log4j2.xml"); private final File SERVERPACKCREATOR_PROPERTIES = new File("serverpackcreator.properties"); @@ -93,7 +93,6 @@ public class ServerPackCreator { private ServerPackHandler serverPackHandler = null; private ServerPackCreatorSplash serverPackCreatorSplash = null; private UpdateChecker updateChecker = null; - private HashMap<String, String> systemInformation; /** * Initialize ServerPackCreator and determine the {@link CommandlineParser.Mode} to run in. @@ -108,11 +107,9 @@ public class ServerPackCreator { this.APPLICATIONPROPERTIES = new ApplicationProperties(); if (COMMANDLINE_PARSER.getLanguageToUse().isPresent()) { - this.LOCALIZATIONMANAGER = - new LocalizationManager( - APPLICATIONPROPERTIES, COMMANDLINE_PARSER.getLanguageToUse().get()); + this.I18N = new I18n(APPLICATIONPROPERTIES, COMMANDLINE_PARSER.getLanguageToUse().get()); } else { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + this.I18N = new I18n(APPLICATIONPROPERTIES); } } @@ -178,7 +175,7 @@ public class ServerPackCreator { stageOne(); stageFour(); checkDatabase(); - runWebservice(); + web(ARGS); break; case CGEN: @@ -228,12 +225,11 @@ public class ServerPackCreator { System.setProperty("log4j2.formatMsgNoLookups", "true"); System.setProperty("file.encoding", StandardCharsets.UTF_8.name()); - this.utilities = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + this.utilities = new Utilities(I18N, APPLICATIONPROPERTIES); - this.systemInformation = - utilities.JarUtils() - .systemInformation( - utilities.JarUtils().getApplicationHomeForClass(ServerPackCreator.class)); + HashMap<String, String> systemInformation = utilities.JarUtils() + .systemInformation( + utilities.JarUtils().getApplicationHomeForClass(ServerPackCreator.class)); LOG.debug("System information jarPath: " + systemInformation.get("jarPath")); LOG.debug("System information jarName: " + systemInformation.get("jarName")); @@ -317,8 +313,8 @@ public class ServerPackCreator { + "/disabled.txt"))) { writer.write("########################################\n"); - writer.write("# - Load all plugins except these. - #\n"); - writer.write("# - Add one plugin-id per line. - #\n"); + writer.write("#...Load all plugins except these......#\n"); + writer.write("#...Add one plugin-id per line.........#\n"); writer.write("########################################\n"); writer.write("#example-plugin\n"); @@ -331,18 +327,20 @@ public class ServerPackCreator { boolean serverProperties = checkServerFilesFile(APPLICATIONPROPERTIES.DEFAULT_SERVER_PROPERTIES()); boolean serverIcon = checkServerFilesFile(APPLICATIONPROPERTIES.DEFAULT_SERVER_ICON()); + boolean shellTemplate = checkServerFilesFile(APPLICATIONPROPERTIES.DEFAULT_SHELL_TEMPLATE()); + boolean powershellTemplate = + checkServerFilesFile(APPLICATIONPROPERTIES.DEFAULT_POWERSHELL_TEMPLATE()); - if (config || serverProperties || serverIcon) { + if (config || serverProperties || serverIcon || shellTemplate || powershellTemplate) { - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.warn.filessetup.warning0")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.warn.filessetup.warning1")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.warn.filessetup.warning2")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.warn.filessetup.warning3")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.warn.filessetup.warning0")); + LOG.warn("#################################################################"); + LOG.warn("#.............ONE OR MORE DEFAULT FILE(S) GENERATED.............#"); + LOG.warn("#..CHECK THE LOGS TO FIND OUT WHICH FILE(S) WAS/WERE GENERATED..#"); + LOG.warn("#...............CUSTOMIZE THEM BEFORE CONTINUING!...............#"); + LOG.warn("#################################################################"); } else { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.info.filessetup.finish")); + LOG.info("Setup completed."); } // Print system information to console and logs. @@ -358,44 +356,25 @@ public class ServerPackCreator { || APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION().contains("alpha") || APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION().contains("beta")) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.debug(LOCALIZATIONMANAGER.getLocalizedString("main.log.debug.warning")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.wip0")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.wip1")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.wip2")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.wip3")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.wip4")); - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.wip0")); + LOG.debug("Warning user about possible data loss."); + LOG.warn("################################################################"); + LOG.warn("#.............ALPHA | BETA | DEV VERSION DETECTED..............#"); + LOG.warn("#.............THESE VERSIONS ARE WORK IN PROGRESS!.............#"); + LOG.warn("#..USE AT YOUR OWN RISK! BE AWARE THAT DATA LOSS IS POSSIBLE!..#"); + LOG.warn("#........I WILL NOT BE HELD RESPONSIBLE FOR DATA LOSS!.........#"); + LOG.warn("#....................YOU HAVE BEEN WARNED!.....................#"); + LOG.warn("################################################################"); } - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("main.log.info.system.enter")); + LOG.info("SYSTEM INFORMATION:"); LOG.info("ServerPackCreator version: " + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION()); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("main.log.info.system.jarpath"), - systemInformation.get("jarPath"))); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("main.log.info.system.jarname"), - systemInformation.get("jarName"))); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("main.log.info.system.java"), - systemInformation.get("javaVersion"))); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("main.log.info.system.osarchitecture"), - systemInformation.get("osArch"))); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("main.log.info.system.osname"), - systemInformation.get("osName"))); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("main.log.info.system.osversion"), - systemInformation.get("osVersion"))); - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("main.log.info.system.include")); + LOG.info("JAR Path: " + systemInformation.get("jarPath")); + LOG.info("JAR Name: " + systemInformation.get("jarName")); + LOG.info("Java version: " + systemInformation.get("javaVersion")); + LOG.info("OS architecture: " + systemInformation.get("osArch")); + LOG.info("OS name: " + systemInformation.get("osName")); + LOG.info("OS version: " + systemInformation.get("osVersion")); + LOG.info("Include this information when reporting an issue on GitHub."); } /** @@ -414,12 +393,11 @@ public class ServerPackCreator { APPLICATIONPROPERTIES.QUILT_VERSION_MANIFEST_LOCATION(), APPLICATIONPROPERTIES.QUILT_INSTALLER_VERSION_MANIFEST_LOCATION()); - this.configUtilities = - new ConfigUtilities(LOCALIZATIONMANAGER, utilities, APPLICATIONPROPERTIES, versionMeta); + this.configUtilities = new ConfigUtilities(I18N, utilities, APPLICATIONPROPERTIES, versionMeta); this.configurationHandler = new ConfigurationHandler( - LOCALIZATIONMANAGER, versionMeta, APPLICATIONPROPERTIES, utilities, configUtilities); + I18N, versionMeta, APPLICATIONPROPERTIES, utilities, configUtilities); } /** @@ -434,7 +412,7 @@ public class ServerPackCreator { this.serverPackHandler = new ServerPackHandler( - LOCALIZATIONMANAGER, APPLICATIONPROPERTIES, versionMeta, utilities, applicationPlugins); + I18N, APPLICATIONPROPERTIES, versionMeta, utilities, applicationPlugins); if (this.updateChecker == null) { this.updateChecker = new UpdateChecker(); @@ -491,6 +469,16 @@ public class ServerPackCreator { checkServerFilesFile(APPLICATIONPROPERTIES.DEFAULT_SERVER_ICON()); LOG.info("Restored default server-icon.png."); + + } else if (check(file, APPLICATIONPROPERTIES.DEFAULT_SHELL_TEMPLATE())) { + + checkServerFilesFile(APPLICATIONPROPERTIES.DEFAULT_SHELL_TEMPLATE()); + LOG.info("Restored default_template.sh."); + + } else if (check(file, APPLICATIONPROPERTIES.DEFAULT_POWERSHELL_TEMPLATE())) { + + checkServerFilesFile(APPLICATIONPROPERTIES.DEFAULT_POWERSHELL_TEMPLATE()); + LOG.info("Restored default_template.ps1."); } } } @@ -509,7 +497,8 @@ public class ServerPackCreator { private void createFile(File toCreate) { try { FileUtils.copyInputStreamToFile( - Objects.requireNonNull(ServerPackCreator.class.getResourceAsStream("/" + toCreate.getName())), + Objects.requireNonNull( + ServerPackCreator.class.getResourceAsStream("/" + toCreate.getName())), toCreate); } catch (IOException ex) { @@ -553,7 +542,7 @@ public class ServerPackCreator { } new ServerPackCreatorGui( - LOCALIZATIONMANAGER, + I18N, configurationHandler, serverPackHandler, APPLICATIONPROPERTIES, @@ -588,7 +577,7 @@ public class ServerPackCreator { selection = scanner.nextInt(); if (selection == 7 && GraphicsEnvironment.isHeadless()) { - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("run.menu.error.gui")); + System.out.println("You environment does not support a GUI."); selection = 100; } @@ -619,14 +608,13 @@ public class ServerPackCreator { default: if (selection > 7) { - System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("run.menu.error.selection")); + System.out.println("Not a valid number. Please pick a number from 0 to 7."); printMenu(); } } } catch (InputMismatchException ex) { - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("run.menu.error.selection")); + System.out.println("Not a valid number. Please pick a number from 0 to 7."); selection = 100; } @@ -649,14 +637,15 @@ public class ServerPackCreator { case 0: default: - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("run.menu.exit")); + System.out.println("Exiting..."); System.exit(0); } } private void changeLocale() { - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("run.menu.change.locale")); - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("run.menu.change.locale.format")); + System.out.println("What locale would you like to use?"); + System.out.println("(Locale format is en_us, de_de, uk_ua etc.)"); + System.out.println("Note: Changing the locale only affects the GUI. CLI always uses en_US."); Scanner scanner = new Scanner(System.in); String regex = "^[a-zA-Z]+_[a-zA-Z]+$"; @@ -670,17 +659,18 @@ public class ServerPackCreator { if (!userLocale.matches(regex)) { - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("run.menu.change.locale.error")); + System.out.println( + "Incorrect format. ServerPackCreator currently only supports locales in the format of en_us (Language, Country)."); } else { try { - LOCALIZATIONMANAGER.initialize(userLocale); + I18N.initialize(userLocale); } catch (IncorrectLanguageException e) { System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("run.menu.change.locale.error")); + "Incorrect format. ServerPackCreator currently only supports locales in the format of en_us (Language, Country)."); userLocale = ""; } } @@ -688,10 +678,7 @@ public class ServerPackCreator { } while (!userLocale.matches(regex)); scanner.close(); - System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("cli.usingLanguage") - + " " - + LOCALIZATIONMANAGER.getLocalizedString("localeName")); + System.out.println("Using language: " + I18N.getMessage("localeName")); } /** @@ -701,31 +688,17 @@ public class ServerPackCreator { */ private void printMenu() { System.out.println(); - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("run.menu.options")); - System.out.println("(1) : " + LOCALIZATIONMANAGER.getLocalizedString("run.menu.options1")); - System.out.println("(2) : " + LOCALIZATIONMANAGER.getLocalizedString("run.menu.options2")); - System.out.println("(3) : " + LOCALIZATIONMANAGER.getLocalizedString("run.menu.options3")); - System.out.println("(4) : " + LOCALIZATIONMANAGER.getLocalizedString("run.menu.options4")); - System.out.println("(5) : " + LOCALIZATIONMANAGER.getLocalizedString("run.menu.options5")); - System.out.println("(6) : " + LOCALIZATIONMANAGER.getLocalizedString("run.menu.options6")); - System.out.println("(7) : " + LOCALIZATIONMANAGER.getLocalizedString("run.menu.options7")); - System.out.println("(0) : " + LOCALIZATIONMANAGER.getLocalizedString("run.menu.options0")); - - // Determine the length of the longest menu entry. - int lengthOfText = 0; - for (int i = 0; i < 8; i++) { - if (LOCALIZATIONMANAGER.getLocalizedString("run.menu.options" + i).length() + 6 - > lengthOfText) { - lengthOfText = LOCALIZATIONMANAGER.getLocalizedString("run.menu.options" + i).length() + 6; - } - } - - // Print "-" n-times. Where n is the length of the longest menu entry. - for (int i = 0; i < lengthOfText; i++) { - System.out.print("-"); - } - System.out.println(); - System.out.print(LOCALIZATIONMANAGER.getLocalizedString("run.menu.options.select") + ": "); + System.out.println("What would you like to do next?"); + System.out.println("(1) : Print help"); + System.out.println("(2) : Check for updates"); + System.out.println("(3) : Change locale"); + System.out.println("(4) : Generate a new configuration"); + System.out.println("(5) : Run ServerPackCreator in CLI-mode"); + System.out.println("(6) : Run ServerPackCreator as a webservice"); + System.out.println("(7) : Run ServerPackCraator with a GUI"); + System.out.println("(0) : Exit"); + System.out.println("-------------------------------------------"); + System.out.print("Enter the number of your selection: "); } /** @@ -761,7 +734,7 @@ public class ServerPackCreator { private void createConfig() throws IOException { new ConfigurationCreator( - LOCALIZATIONMANAGER, + I18N, configurationHandler, APPLICATIONPROPERTIES, utilities, @@ -770,48 +743,6 @@ public class ServerPackCreator { .createConfigurationFile(); } - /** - * Run ServerPackCreator as a webservice. - * - * @author Griefed - */ - private void runWebservice() { - - if (systemInformation.get("osName").contains("windows") - || systemInformation.get("osName").contains("Windows")) { - - Scanner reader = new Scanner(System.in); - - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.windows")); - System.out.print(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.windows.input") + " "); - - //noinspection UnusedAssignment - String answer = "foobar"; - - do { - answer = reader.nextLine(); - - if (answer.equals("No")) { - - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.windows.no")); - reader.close(); - System.exit(0); - - } else if (answer.equals("Yes")) { - - LOG.warn(LOCALIZATIONMANAGER.getLocalizedString("main.log.warn.windows.yes")); - reader.close(); - web(ARGS); - } - - } while (!answer.matches("^(Yes|No)$")); - - } else { - - web(ARGS); - } - } - /** * Check for old config file, if found rename to new name. If neither old nor new config file can * be found, a new config file is generated. @@ -829,9 +760,8 @@ public class ServerPackCreator { APPLICATIONPROPERTIES.DEFAULT_CONFIG().getAbsoluteFile().toPath()); if (APPLICATIONPROPERTIES.OLD_CONFIG().delete()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.info.checkforconfig.old")); + + LOG.info("creator.conf migrated to serverpackcreator.conf."); } } catch (IOException ex) { @@ -850,9 +780,7 @@ public class ServerPackCreator { APPLICATIONPROPERTIES.DEFAULT_CONFIG().getName()))), APPLICATIONPROPERTIES.DEFAULT_CONFIG()); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.info.checkforconfig.config")); + LOG.info("serverpackcreator.conf generated. Please customize."); firstRun = true; } catch (IOException ex) { @@ -886,11 +814,7 @@ public class ServerPackCreator { String.format("/de/griefed/resources/server_files/%s", fileToCheckFor))), new File(String.format("./server_files/%s", fileToCheckFor))); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.info.checkforfile"), - fileToCheckFor)); + LOG.info(fileToCheckFor + " generated. Please customize if you intend on using it."); firstRun = true; @@ -898,7 +822,7 @@ public class ServerPackCreator { if (!ex.toString().startsWith("java.nio.file.FileAlreadyExistsException")) { - LOG.error(String.format("Could not extract default %s file.", fileToCheckFor), ex); + LOG.error("Could not extract default " + fileToCheckFor + " file.", ex); firstRun = true; } } @@ -957,11 +881,11 @@ public class ServerPackCreator { System.out.println(); if (update.isPresent()) { - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("update.dialog.available")); + System.out.println("Update available!"); System.out.println(" " + update.get().version()); System.out.println(" " + update.get().url()); } else { - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("updates.log.info.none")); + System.out.println("No updates available."); } } @@ -971,35 +895,92 @@ public class ServerPackCreator { * @author Griefed */ private void printHelp() { - System.out.println(LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.intro")); - System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.intro")); + // TODO move to file in resources. Read and print text from file System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.lang")); + "# How to use ServerPackCreator:\n" + + "# java -jar ServerPackCreator.jar\n" + + "# Simply running the JAR without extra arguments runs ServerPackCreator in GUI mode unless\n" + + "# you are running in a headless environment. In the case of a headless environment, the CLI\n" + + "# mode will automatically be used.\n" + + "#"); + System.out.println("# Extra arguments to use ServerPackCreator with:\n" + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.help")); + "# -lang : Allows you to use one of the available languages for ServerPackCreator. I can not\n" + + "# guarantee that each of the following available languages is 100% translated.\n" + + "# You best choice is en_us, or not specifying any as that is the default, because\n" + + "# I write ServerPackCreator with english in mind. Available usages:\n" + + "# -lang en_us\n" + + "# -lang uk_ua\n" + + "# -lang de_de\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.update")); + "# -cgen : Only available for the commandline interface. This will start the generation of\n" + + "# a new configuration file. You will be asked to enter information about your modpack\n" + + "# step-by-step. Each setting you enter will be checked for errors before it is saved.\n" + + "# If everything you enter is valid and without errors, it will be written to a new\n" + + "# serverpackcreator.conf and ServerPackCreator will immediately start a run with said\n" + + "# configuration file, generating a server pack for you.\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.cgen")); + "# -update : Check whether a new version of ServerPackCreator is available for download.\n" + + "# If an update is available, the version and link to the release of said update are\n" + + "# written to the console so you can from work with it from there.\n" + + "# Note: Automatic updates are currently not planned nor supported, and neither are\n" + + "# downloads of any available updates to your system. You need to update manually.\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.cli")); + "# -cgen : Only available for the commandline interface. This will start the generation of\n" + + "# a new configuration file. You will be asked to enter information about your modpack\n" + + "# step-by-step. Each setting you enter will be checked for errors before it is saved.\n" + + "# If everything you enter is valid and without errors, it will be written to a new\n" + + "# serverpackcreator.conf and ServerPackCreator will immediately start a run with said\n" + + "# configuration file, generating a server pack for you.\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.web")); + "# -cli : Run ServerPackCreator in Command-line interface mode. Checks the serverpackcreator.conf\n" + + "# for errors and if none are found, starts the generation of a server pack with the configuration\n" + + "# provided by your serverpackcreator.conf.\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.gui")); + "# -web : Run ServerPackCreator as a webservice available at http://localhost:8080. The webservice\n" + + "# provides the same functionality as running ServerPackCreator in GUI mode (so no Commandline\n" + + "# arguments and a non-headless environment) as well as a REST API which can be used in different ways.\n" + + "# For more information about the REST API, please see the Java documentation:\n" + + "# - GitHub Pages: https://griefed.github.io/ServerPackCreator/\n" + + "# - GitLab Pages: https://griefed.pages.griefed.de/ServerPackCreator/\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.arguments.setup")); + "# -gui : Run ServerPackCreator using the graphical user interface. If your environment supports\n" + + "# graphics, i.e. is not headless, then this is the default mode in which ServerPackCreator\n" + + "# started as when no arguments are used.\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.support.intro")); + "# --setup : Set up and prepare the environment for subsequent runs of ServerPackCreator.\n" + + "# This will create/copy all files needed for ServerPackCreator to function\n" + + "# properly from inside its JAR-file and setup everything else, too.\n" + + "#"); + System.out.println("# Support:\n" + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.support.issues")); + "# Issues: Encountered a bug, or want some part of the documentation to be improved on? Got a suggestion?\n" + + "# Open an issue on GitHub at: https://github.com/Griefed/ServerPackCreator/issues\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.support.discord")); + "# Discord: If you would like to chat with me, ask me questions, or see when there's something new\n" + + "# regarding ServerPackCreator coming up, you can join my Discord server to stay up-to-date.\n" + + "# - Discord link: https://discord.griefed.de\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.support.wiki")); + "# Help/Wiki: If you want additional help on how to use ServerPackCreator, take a look at my wiki articles\n" + + "# regarding ServerPackCreator and some of the more advanced things it can do.\n" + + "# - Help: https://wiki.griefed.de/en/Documentation/ServerPackCreator/ServerPackCreator-Help\n" + + "# - HowTo: https://wiki.griefed.de/en/Documentation/ServerPackCreator/ServerPackCreator-HowTo\n" + + "#"); System.out.println( - LOCALIZATIONMANAGER.getLocalizedString("serverpackcreator.help.support.someluv")); + "# Buy Me A Coffee:\n" + + "# You like ServerPackCreator and would like to support me? By all means, every bit is very much\n" + + "# appreciated and helps me pay for servers and food. Food is most important. And coffee. Food and Coffee.\n" + + "# Those two get converted into code. Thank you very much!\n" + + "# - Github Sponsors: https://github.com/sponsors/Griefed"); } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/ServerPackHandler.java b/backend/main/java/de/griefed/serverpackcreator/ServerPackHandler.java index ca20861bf034c544d4ea70ff123eade8cf893958..bc9be36beaffef252762c30521e24e56851dfeb6 100644 --- a/backend/main/java/de/griefed/serverpackcreator/ServerPackHandler.java +++ b/backend/main/java/de/griefed/serverpackcreator/ServerPackHandler.java @@ -27,7 +27,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.moandjiezana.toml.Toml; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.plugins.ApplicationPlugins; import de.griefed.serverpackcreator.spring.serverpack.ServerPackModel; import de.griefed.serverpackcreator.utilities.common.Utilities; @@ -42,6 +42,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.nio.file.CopyOption; import java.nio.file.DirectoryNotEmptyException; import java.nio.file.Files; @@ -52,7 +53,9 @@ import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Properties; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -84,7 +87,6 @@ public class ServerPackHandler { private static final Logger LOG_ADDONS = LogManager.getLogger("AddonsLogger"); private static final Logger LOG_INSTALLER = LogManager.getLogger("InstallerLogger"); - private final LocalizationManager LOCALIZATIONMANAGER; private final VersionMeta VERSIONMETA; private final ApplicationProperties APPLICATIONPROPERTIES; private final Utilities UTILITIES; @@ -96,13 +98,12 @@ public class ServerPackHandler { * * <p>Used for Dependency Injection. * - * <p>Receives an instance of {@link LocalizationManager} or creates one if the received one is - * null. Required for use of localization. + * <p>Receives an instance of {@link I18n} or creates one if the received one is null. Required + * for use of localization. * * <p> * - * @param injectedLocalizationManager Instance of {@link LocalizationManager} required for - * localized log messages. + * @param injectedI18n Instance of {@link I18n} required for localized log messages. * @param injectedApplicationProperties Instance of {@link Properties} required for various * different things. * @param injectedVersionMeta Instance of {@link VersionMeta} required for everything version @@ -114,7 +115,7 @@ public class ServerPackHandler { */ @Autowired public ServerPackHandler( - LocalizationManager injectedLocalizationManager, + I18n injectedI18n, ApplicationProperties injectedApplicationProperties, VersionMeta injectedVersionMeta, Utilities injectedUtilities, @@ -127,10 +128,11 @@ public class ServerPackHandler { this.APPLICATIONPROPERTIES = injectedApplicationProperties; } - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + I18n i18N; + if (injectedI18n == null) { + i18N = new I18n(APPLICATIONPROPERTIES); } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; + i18N = injectedI18n; } if (injectedVersionMeta == null) { @@ -147,7 +149,7 @@ public class ServerPackHandler { } if (injectedUtilities == null) { - this.UTILITIES = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + this.UTILITIES = new Utilities(i18N, APPLICATIONPROPERTIES); } else { this.UTILITIES = injectedUtilities; } @@ -183,14 +185,7 @@ public class ServerPackHandler { */ public ServerPackModel run(@NotNull ServerPackModel serverPackModel) { - String destination = - String.format( - "%s/%s", - APPLICATIONPROPERTIES.getDirectoryServerPacks(), - serverPackModel - .getModpackDir() - .substring(serverPackModel.getModpackDir().lastIndexOf("/") + 1) - + serverPackModel.getServerPackSuffix()); + String destination = getServerPackDestination(serverPackModel); run((ConfigurationModel) serverPackModel); @@ -207,6 +202,35 @@ public class ServerPackHandler { return serverPackModel; } + /** + * Acquire the destination directory in which the server pack will be generated. The directory in + * which the server pack will be created has all its spaces replaces with underscores, so <code> + * Survive Create Prosper 4 - 5.0.1</code> would become <code>Survive_Create_Prosper_4_-_5.0.1 + * </code> Even though it is the year 2022, spaces in paths can and do still cause trouble. Such + * as for Powershell scripts. Powershell throws a complete fit if the path contains spaces.... + * + * @param configurationModel {@link ConfigurationModel} or {@link ServerPackModel} containing the + * modpack directory of the modpack from which the server pack will be generated. + * @return {@link String} The complete path to the directory in which the server pack will be + * generated. + * @author Griefed + */ + public String getServerPackDestination(ConfigurationModel configurationModel) { + + String serverPackToBe = + configurationModel + .getModpackDir() + .substring(configurationModel.getModpackDir().lastIndexOf("/") + 1) + + configurationModel.getServerPackSuffix(); + + serverPackToBe = serverPackToBe.replace(" ", "_"); + + return new File( + String.format("%s/%s", APPLICATIONPROPERTIES.getDirectoryServerPacks(), serverPackToBe)) + .getAbsolutePath() + .replace("\\", "/"); + } + /** * Create a server pack from a given instance of {@link ConfigurationModel}. * @@ -217,17 +241,7 @@ public class ServerPackHandler { */ public boolean run(@NotNull ConfigurationModel configurationModel) { - String destination = - new File( - String.format( - "%s/%s", - APPLICATIONPROPERTIES.getDirectoryServerPacks(), - configurationModel - .getModpackDir() - .substring(configurationModel.getModpackDir().lastIndexOf("/") + 1) - + configurationModel.getServerPackSuffix())) - .getAbsolutePath() - .replace("\\", "/"); + String destination = getServerPackDestination(configurationModel); /* * Check whether the server pack for the specified modpack already exists and whether overwrite is disabled. @@ -238,7 +252,7 @@ public class ServerPackHandler { .equals("false") && new File(destination).exists()) { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.overwrite")); + LOG.info("Server pack already exists and overwrite disabled."); } else { @@ -252,28 +266,21 @@ public class ServerPackHandler { } if (!APPLICATIONPLUGINS.pluginsPreGenExtension().isEmpty()) { - LOG_ADDONS.info(LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.pregen")); + LOG_ADDONS.info("Executing PreGenExtension addons."); APPLICATIONPLUGINS .pluginsPreGenExtension() .forEach( plugin -> { - LOG_ADDONS.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.addon"), - plugin.getName())); + LOG_ADDONS.info("Executing addon " + plugin.getName()); try { plugin.run(APPLICATIONPROPERTIES, configurationModel, destination); } catch (Exception ex) { - LOG_ADDONS.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("addons.log.error"), - plugin.getName()), - ex); + LOG_ADDONS.error("Addon " + plugin.getName() + " encountered an error.", ex); } }); } else { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.pregen.none")); + LOG.info("No PreGenExtension addons to execute."); } // Recursively copy all specified directories and files, excluding clientside-only mods, to @@ -287,12 +294,7 @@ public class ServerPackHandler { configurationModel.getModLoader()); // Create the start scripts for this server pack. - createStartScripts( - configurationModel.getModLoader(), - configurationModel.getJavaArgs(), - configurationModel.getMinecraftVersion(), - configurationModel.getModLoaderVersion(), - destination); + createStartScripts(configurationModel, destination); // If modloader is fabric, try and replace the old server-launch.jar with the new and improved // one which also downloads the Minecraft server. @@ -307,41 +309,34 @@ public class ServerPackHandler { if (configurationModel.getIncludeServerIcon()) { copyIcon(destination, configurationModel.getServerIconPath()); } else { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("main.log.info.runincli.icon")); + + LOG.info("Not including servericon."); } // If true, copy the server.properties from server_files to the server pack. if (configurationModel.getIncludeServerProperties()) { copyProperties(destination, configurationModel.getServerPropertiesPath()); } else { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("main.log.info.runincli.properties")); + + LOG.info("Not including server.properties."); } if (!APPLICATIONPLUGINS.pluginsPreZipExtension().isEmpty()) { - LOG_ADDONS.info(LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.prezip")); + LOG_ADDONS.info("Executing PreZipExtension addons."); APPLICATIONPLUGINS .pluginsPreZipExtension() .forEach( plugin -> { - LOG_ADDONS.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.addon"), - plugin.getName())); + LOG_ADDONS.info("Executing addon " + plugin.getName()); try { plugin.run(APPLICATIONPROPERTIES, configurationModel, destination); } catch (Exception ex) { - LOG_ADDONS.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("addons.log.error"), - plugin.getName()), - ex); + LOG_ADDONS.error("Addon " + plugin.getName() + " encountered an error.", ex); } }); } else { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.prezip.none")); + LOG.info("No PreZipExtension addons to execute."); } // If true, create a ZIP-archive excluding the Minecraft server JAR of the server pack. @@ -353,8 +348,8 @@ public class ServerPackHandler { configurationModel.getModLoader(), configurationModel.getModLoaderVersion()); } else { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("main.log.info.runincli.zip")); + + LOG.info("Not creating zip archive of serverpack."); } // If true, Install the modloader software for the specified Minecraft version, modloader, @@ -367,45 +362,31 @@ public class ServerPackHandler { configurationModel.getJavaPath(), destination); } else { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("main.log.info.runincli.server")); + + LOG.info("Not installing modded server."); } // Inform user about location of newly generated server pack. - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("main.log.info.runincli.serverpack"), - destination)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("main.log.info.runincli.archive"), - destination)); - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("main.log.info.runincli.finish")); + LOG.info("Server pack available at: " + destination); + LOG.info("Server pack archive available at: " + destination + "_server_pack.zip"); + LOG.info("Done!"); if (!APPLICATIONPLUGINS.pluginsPostGenExtension().isEmpty()) { - LOG_ADDONS.info(LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.postgen")); + LOG_ADDONS.info("Executing PostGenExtension addons."); APPLICATIONPLUGINS .pluginsPostGenExtension() .forEach( plugin -> { - LOG_ADDONS.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.addon"), - plugin.getName())); + LOG_ADDONS.info("Executing addon " + plugin.getName()); try { plugin.run(APPLICATIONPROPERTIES, configurationModel, destination); } catch (Exception ex) { - LOG_ADDONS.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("addons.log.error"), - plugin.getName()), - ex); + LOG_ADDONS.error("Addon " + plugin.getName() + " encountered an error.", ex); } }); } else { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("addons.log.info.execute.postgen.none")); + LOG.info("No PostGenExtension addons to execute."); } } return true; @@ -432,7 +413,7 @@ public class ServerPackHandler { fileDestination, VERSIONMETA.fabric().improvedLauncherUrl(minecraftVersion, fabricVersion).get())) { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.fabric.improved")); + LOG.info("Successfully provided improved Fabric Server Launcher."); try (BufferedWriter writer = new BufferedWriter( @@ -474,18 +455,13 @@ public class ServerPackHandler { */ private void cleanupEnvironment(boolean deleteZip, String destination) { - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.cleanupenvironment.folder.enter")); + LOG.info("Found old server_pack. Cleaning up..."); FileUtils.deleteQuietly(new File(destination)); if (deleteZip) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.cleanupenvironment.zip.enter")); + LOG.info("Found old server_pack.zip. Cleaning up..."); FileUtils.deleteQuietly(new File(String.format("%s_server_pack.zip", destination))); } @@ -494,1414 +470,31 @@ public class ServerPackHandler { /** * Create start-scripts for the generated server pack. * - * @param modLoader String. Whether to copy the Forge or Fabric scripts into the server pack. - * @param javaArguments String. Java arguments to write the start-scripts with. - * @param minecraftVersion String. The Minecraft version the modpack uses. - * @param modloaderVersion String. The modloader version the modpack uses. + * @param configurationModel {@link ConfigurationModel} Configuration model containing modpack + * specific values. keys to be replaced with their respective values in the start scripts. * @param destination String. The destination where the scripts should be created in. * @author Griefed */ - private void createStartScripts( - String modLoader, - String javaArguments, - String minecraftVersion, - String modloaderVersion, - String destination) { - - if (javaArguments.equals("empty")) { - javaArguments = ""; - } - - switch (modLoader) { - case "Forge": - String[] minecraft = minecraftVersion.split("\\."); + private void createStartScripts(ConfigurationModel configurationModel, String destination) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.copystartscripts.forge")); + HashMap<String, String> scriptSettings = configurationModel.getScriptSettings(); - if (Integer.parseInt(minecraft[1]) < 17) { + for (File template : APPLICATIONPROPERTIES.scriptTemplates()) { - forgeBatchScript(javaArguments, minecraftVersion, modloaderVersion, destination); - forgeShellScript(javaArguments, minecraftVersion, modloaderVersion, destination); + try { + String fileEnding = template.toString().substring(template.toString().lastIndexOf(".") + 1); + File destinationScript = new File(destination + "/start." + fileEnding); - } else { + String scriptContent = FileUtils.readFileToString(template, StandardCharsets.UTF_8); - forgeBatchScriptNewMC(minecraftVersion, modloaderVersion, destination); - forgeShellScriptNewMC(javaArguments, minecraftVersion, modloaderVersion, destination); - forgeJvmArgsTxt(javaArguments, destination); + for (Map.Entry<String, String> entry : scriptSettings.entrySet()) { + scriptContent = scriptContent.replace(entry.getKey(), entry.getValue()); } - break; - case "Fabric": - - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.copystartscripts.fabric")); - - fabricBatchScript(javaArguments, minecraftVersion, modloaderVersion, destination); - fabricShellScript(javaArguments, minecraftVersion, modloaderVersion, destination); - - break; - case "Quilt": - - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.copystartscripts.quilt")); - - quiltBatchScript(javaArguments, minecraftVersion, modloaderVersion, destination); - quiltShellScript(javaArguments, minecraftVersion, modloaderVersion, destination); - - break; - default: - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkmodloader")); - } - } - - /** - * Create a Fabric shell start script - * - * @param javaArguments String. Java arguments with which the server should be started - * @param minecraftVersion String. Minecraft version of this server pack. - * @param modloaderVersion String. Modloader version of this server pack. - * @param destination String. Where the script should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX)</code> - * @author Griefed - */ - private void fabricShellScript( - String javaArguments, String minecraftVersion, String modloaderVersion, String destination) { - - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX())))))) { - - if (!VERSIONMETA.minecraft().getServer(minecraftVersion).isPresent() - || !VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().isPresent()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.minecraft.server")); - return; - } - - // Fabric Bash file - writer.write("#!/usr/bin/env bash\n"); - writer.write( - "# Start script generated by ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + ".\n"); - writer.write( - "# This script checks for the Minecraft and Fabric JAR-Files, and if they are not found, they are downloaded and installed.\n"); - writer.write( - "# Should this server pack come with the improved Fabric Server Launcher, then it is used instead of the old one.\n"); - writer.write("# If everything is in order, the server is started.\n"); - writer.write("\n"); - writer.write("if [ \"$(id -u)\" = \"0\" ]; then\n"); - writer.write( - " echo \"Warning! Running with administrator-privileges is not recommended.\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("JAVA=\"java\"\n"); - writer.write("MINECRAFT=\"" + minecraftVersion + "\"\n"); - writer.write("FABRIC=\"" + modloaderVersion + "\"\n"); - writer.write("INSTALLER=\"" + VERSIONMETA.fabric().releaseInstallerVersion() + "\"\n"); - writer.write("ARGS=\"" + javaArguments + "\"\n"); - writer.write("OTHERARGS=\"-Dlog4j2.formatMsgNoLookups=true\"\n"); - writer.write("LAUNCHER=\"fabric-server-launch.jar\""); - writer.write("\n"); - writer.write("if [[ -s \"fabric-server-launcher.jar\" ]];then\n"); - writer.write("\n"); - writer.write(" echo \"Improved Fabric Server Launcher found...\";\n"); - writer.write(" echo \"The improved launcher will be used to run this Fabric server.\";\n"); - writer.write(" LAUNCHER=\"fabric-server-launcher.jar\";\n"); - writer.write("\n"); - writer.write("elif [[ ! -s \"fabric-server-launch.jar\" ]];then\n"); - writer.write("\n"); - writer.write(" echo \"Fabric Server JAR-file not found. Downloading installer...\";\n"); - writer.write( - " wget -O fabric-installer.jar https://maven.fabricmc.net/net/fabricmc/fabric-installer/$INSTALLER/fabric-installer-$INSTALLER.jar;\n"); - writer.write("\n"); - writer.write(" if [[ -s \"fabric-installer.jar\" ]];then\n"); - writer.write("\n"); - writer.write(" echo \"Installer downloaded. Installing...\";\n"); - writer.write( - " \"$JAVA\" -jar fabric-installer.jar server -mcversion $MINECRAFT -loader $FABRIC -downloadMinecraft;\n"); - writer.write("\n"); - writer.write(" if [[ -s \"fabric-server-launch.jar\" ]];then\n"); - writer.write(" rm -rf .fabric-installer;\n"); - writer.write(" rm -f fabric-installer.jar;\n"); - writer.write(" echo \"Installation complete. fabric-installer.jar deleted.\";\n"); - writer.write(" else\n"); - writer.write(" rm -f fabric-installer.jar\n"); - writer.write( - " echo \"fabric-server-launch.jar not found. Maybe the Fabric servers are having trouble.\";\n"); - writer.write( - " echo \"Please try again in a couple of minutes and check your internet connection.\";\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("\n"); - writer.write(" else\n"); - writer.write( - " echo \"fabric-installer.jar not found. Maybe the Fabric servers are having trouble.\";\n"); - writer.write(" echo \"Please try again in a couple of minutes.\";\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"fabric-server-launch.jar present. Moving on...\";\n"); - writer.write("\n"); - writer.write(" if [[ ! -s \"server.jar\" ]];then\n"); - writer.write(" echo \"Minecraft Server JAR-file not found. Downloading...\";\n"); - writer.write( - " wget -O server.jar " - + VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().get() - + ";\n"); - writer.write(" if [[ -s \"server.jar\" ]];then\n"); - writer.write(" echo \"Download complete.\"\n"); - writer.write(" else\n"); - writer.write( - " echo \"Something went wrong during the server download. Please try again in a couple of minutes and check your internet connection.\"\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write(" else\n"); - writer.write(" echo \"server.jar present. Moving on...\";\n"); - writer.write(" fi\n"); - writer.write("\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("if [[ ! -s \"eula.txt\" ]];then\n"); - writer.write("\n"); - writer.write( - " echo \"Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA.\"\n"); - writer.write( - " echo \"Mojang's EULA is available to read at https://account.mojang.com/documents/minecraft_eula\"\n"); - writer.write(" echo \"If you agree to Mojang's EULA then type 'I agree'\"\n"); - writer.write("\n"); - writer.write(" echo -n \"Response: \"\n"); - writer.write(" read ANSWER\n"); - writer.write("\n"); - writer.write(" if [[ \"$ANSWER\" = \"I agree\" ]]; then\n"); - writer.write("\n"); - writer.write(" echo \"User agreed to Mojang's EULA.\"\n"); - writer.write( - " echo \"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\" > eula.txt;\n"); - writer.write(" echo \"eula=true\" >> eula.txt;\n"); - writer.write("\n"); - writer.write(" else\n"); - writer.write(" echo \"User did not agree to Mojang's EULA.\"\n"); - writer.write(" echo \"Entered: $ANSWER\"\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("\n"); - writer.write("else\n"); - writer.write(" echo \"eula.txt present. Moving on...\";\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("echo \"Starting server...\";\n"); - writer.write("echo \"Minecraft version: $MINECRAFT\";\n"); - writer.write("echo \"Fabric version: $FABRIC\";\n"); - writer.write("echo \"Java version:\"\n"); - writer.write("\"$JAVA\"-version\n"); - writer.write("echo \"Java args: $ARGS\";\n"); - writer.write("\n"); - writer.write("\"$JAVA\" $OTHERARGS $ARGS -jar $LAUNCHER nogui"); - - } catch (IOException ex) { - LOG.error("Error generating shell-script for Fabric.", ex); - } - } - - /** - * Create a Fabric batch start script. - * - * @param javaArguments String. Java arguments wich which the server should be started. - * @param minecraftVersion String. The Minecraft version of this server pack. - * @param modloaderVersion String. The modloader version of this server pack. - * @param destination String. Where the script should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX)</code> - * @author Griefed - */ - private void fabricBatchScript( - String javaArguments, String minecraftVersion, String modloaderVersion, String destination) { - - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", - destination, APPLICATIONPROPERTIES.START_SCRIPT_WINDOWS())))))) { - - if (!VERSIONMETA.minecraft().getServer(minecraftVersion).isPresent() - || !VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().isPresent()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.minecraft.server")); - return; - } - - // Fabric Batch file - writer.write( - ":: Start script generated by ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + ".\n"); - writer.write( - ":: This script checks for the Minecraft and Fabric JAR-Files, and if they are not found, they are downloaded and installed.\n"); - writer.write( - ":: Should this server pack come with the improved Fabric Server Launcher, then it is used instead of the old one.\n"); - writer.write(":: If everything is in order, the server is started.\n"); - writer.write("@ECHO off\n"); - writer.write("SetLocal EnableDelayedExpansion\n"); - writer.write("\n"); - writer.write("net session >nul 2>&1\n"); - writer.write("if %errorLevel% == 0 (\n"); - writer.write( - " echo Warning! Running with administrator/root-privileges is not recommended.\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("PUSHD \"%~dp0\""); - writer.write("\n"); - writer.write("SET JAVA=\"java\"\n"); - writer.write("SET MINECRAFT=" + minecraftVersion + "\n"); - writer.write("SET FABRIC=" + modloaderVersion + "\n"); - writer.write("SET INSTALLER=" + VERSIONMETA.fabric().releaseInstallerVersion() + "\n"); - writer.write("SET ARGS=" + javaArguments + "\n"); - writer.write("SET OTHERARGS=-Dlog4j2.formatMsgNoLookups=true\n"); - writer.write("SET LAUNCHER=fabric-server-launch.jar\n"); - writer.write("\n"); - writer.write("IF EXIST fabric-server-launcher.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Improved Fabric Server Launcher found...\n"); - writer.write(" ECHO The improved launcher will be used to run this Fabric server.\n"); - writer.write(" SET LAUNCHER=fabric-server-launcher.jar\n"); - writer.write("\n"); - writer.write(") ELSE (\n"); - writer.write("\n"); - writer.write(" IF NOT EXIST fabric-server-launch.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Fabric Server JAR-file not found. Downloading installer...\n"); - writer.write( - " powershell -Command \"(New-Object Net.WebClient).DownloadFile('https://maven.fabricmc.net/net/fabricmc/fabric-installer/%INSTALLER%/fabric-installer-%INSTALLER%.jar', 'fabric-installer.jar')\"\n"); - writer.write("\n"); - writer.write(" IF EXIST fabric-installer.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Installer downloaded. Installing...\n"); - writer.write( - " %JAVA% -jar fabric-installer.jar server -mcversion %MINECRAFT% -loader %FABRIC% -downloadMinecraft\n"); - writer.write("\n"); - writer.write(" IF EXIST fabric-server-launch.jar (\n"); - writer.write(" IF EXIST .fabric-installer RMDIR /S /Q .fabric-installer\n"); - writer.write(" IF EXIST fabric-installer.jar DEL fabric-installer.jar\n"); - writer.write( - " ECHO Installation complete. fabric-installer.jar and installation files deleted.\n"); - writer.write(" ) ELSE (\n"); - writer.write(" IF EXIST fabric-installer.jar DEL fabric-installer.jar\n"); - writer.write( - " ECHO Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write("\n"); - writer.write(" ) ELSE (\n"); - writer.write( - " ECHO fabric-installer.jar not found. Maybe the Fabric servers are having trouble.\n"); - writer.write(" ECHO Please try again in a couple of minutes.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write("\n"); - writer.write(" ) ELSE (\n"); - writer.write(" ECHO fabric-server-launch.jar present. Moving on...\n"); - writer.write(" IF NOT EXIST server.jar (\n"); - writer.write(" ECHO Minecraft Server JAR-file not found. Downloading...\n"); - writer.write( - " powershell -Command \"(New-Object Net.WebClient).DownloadFile('" - + VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().get() - + "', 'server.jar')\"\n"); - writer.write(" IF EXIST server.jar (\n"); - writer.write(" ECHO Download complete.\n"); - writer.write(" ) ELSE (\n"); - writer.write( - " ECHO Something went wrong during the server download. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write(" ) ELSE (\n"); - writer.write(" ECHO server.jar present. Moving on...\n"); - writer.write(" )\n"); - writer.write(" )\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("IF NOT EXIST eula.txt (\n"); - writer.write( - " ECHO Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA.\n"); - writer.write( - " ECHO Mojang's EULA is available to read at https://account.mojang.com/documents/minecraft_eula\n"); - writer.write(" ECHO If you agree to Mojang's EULA then type \"I agree\"\n"); - writer.write("\n"); - writer.write(" SET /p UserInput=Response: \n"); - writer.write(" GOTO check\n"); - writer.write(" \n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO eula.txt present. Moving on...\n"); - writer.write(" GOTO start\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write(":check\n"); - writer.write("IF \"%UserInput%\" == \"I agree\" (\n"); - writer.write(" ECHO User agreed to Mojang's EULA.\n"); - writer.write( - " ECHO #By changing the setting below to TRUE you are indicating your agreement to our EULA ^(https://account.mojang.com/documents/minecraft_eula^).> eula.txt\n"); - writer.write(" ECHO eula=true>> eula.txt\n"); - writer.write(") else (\n"); - writer.write(" ECHO User did not agree to Mojang's EULA. \n"); - writer.write(" ECHO Entered: %UserInput%\n"); - writer.write(" GOTO crash\n"); - writer.write(")"); - writer.write("\n"); - writer.write(":start\n"); - writer.write("ECHO Starting server...\n"); - writer.write("ECHO Minecraft version: %MINECRAFT%\n"); - writer.write("ECHO Fabric version: %FABRIC%\n"); - writer.write("ECHO Java version:\n"); - writer.write("%JAVA% -version\n"); - writer.write("ECHO Java args: %ARGS%\n"); - writer.write("\n"); - writer.write("%JAVA% %OTHERARGS% %ARGS% -jar %LAUNCHER% nogui\n"); - writer.write("\n"); - writer.write(":quit\n"); - writer.write("ECHO Exiting...\n"); - writer.write("PAUSE\n"); - writer.write("EXIT 0\n"); - writer.write("\n"); - writer.write(":crash\n"); - writer.write("ECHO Exiting...\n"); - writer.write("PAUSE\n"); - writer.write("EXIT 1"); - - } catch (IOException ex) { - LOG.error("Error generating batch-script for Fabric.", ex); - } - } - - /** - * Create a Quilt shell start script - * - * @param javaArguments String. Java arguments with which the server should be started - * @param minecraftVersion String. Minecraft version of this server pack. - * @param modloaderVersion String. Modloader version of this server pack. - * @param destination String. Where the script should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX)</code> - * @author Griefed - */ - private void quiltShellScript( - String javaArguments, String minecraftVersion, String modloaderVersion, String destination) { - - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX())))))) { - - if (!VERSIONMETA.minecraft().getServer(minecraftVersion).isPresent() - || !VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().isPresent()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.minecraft.server")); - return; - } - - // Quilt Bash file - writer.write("#!/usr/bin/env bash\n"); - writer.write( - "# Start script generated by ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + ".\n"); - writer.write( - "# This script checks for the Minecraft and Quilt JAR-Files, and if they are not found, they are downloaded and installed.\n"); - writer.write("# If everything is in order, the server is started.\n"); - writer.write("\n"); - writer.write("if [ \"$(id -u)\" = \"0\" ]; then\n"); - writer.write( - " echo \"Warning! Running with administrator-privileges is not recommended.\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("JAVA=\"java\"\n"); - writer.write("MINECRAFT=\"" + minecraftVersion + "\"\n"); - writer.write("QUILT=\"" + modloaderVersion + "\"\n"); - writer.write("INSTALLER=\"" + VERSIONMETA.quilt().releaseInstallerVersion() + "\"\n"); - writer.write("ARGS=\"" + javaArguments + "\"\n"); - writer.write("OTHERARGS=\"-Dlog4j2.formatMsgNoLookups=true\"\n"); - writer.write("\n"); - writer.write("if [[ ! -s \"quilt-server-launch.jar\" ]];then\n"); - writer.write("\n"); - writer.write(" echo \"Quilt Server JAR-file not found. Downloading installer...\";\n"); - writer.write( - " wget -O quilt-installer.jar https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/$INSTALLER/quilt-installer-$INSTALLER.jar;\n"); - writer.write("\n"); - writer.write(" if [[ -s \"quilt-installer.jar\" ]];then\n"); - writer.write("\n"); - writer.write(" echo \"Installer downloaded. Installing...\";\n"); - writer.write( - " \"$JAVA\" -jar quilt-installer.jar install server $MINECRAFT --download-server --install-dir=.;\n"); - writer.write("\n"); - writer.write(" if [[ -s \"quilt-server-launch.jar\" ]];then\n"); - writer.write(" rm quilt-installer.jar;\n"); - writer.write(" echo \"Installation complete. quilt-installer.jar deleted.\";\n"); - writer.write(" else\n"); - writer.write(" rm -f quilt-installer.jar\n"); - writer.write( - " echo \"quilt-server-launch.jar not found. Maybe the Quilt servers are having trouble.\";\n"); - writer.write( - " echo \"Please try again in a couple of minutes and check your internet connection.\";\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("\n"); - writer.write(" else\n"); - writer.write( - " echo \"quilt-installer.jar not found. Maybe the Quilt servers are having trouble.\";\n"); - writer.write( - " echo \"Please try again in a couple of minutes and check your internet connection.\";\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"quilt-server-launch.jar present. Moving on...\";\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("if [[ ! -s \"server.jar\" ]];then\n"); - writer.write(" echo \"Minecraft Server JAR-file not found. Downloading...\";\n"); - writer.write( - " wget -O server.jar " - + VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().get() - + ";\n"); - writer.write(" if [[ -s \"server.jar\" ]];then\n"); - writer.write(" echo Download complete.\n"); - writer.write(" else\n"); - writer.write( - " echo Something went wrong during the server download. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"server.jar present. Moving on...\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("if [[ ! -s \"eula.txt\" ]];then\n"); - writer.write( - " echo \"Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA.\"\n"); - writer.write( - " echo \"Mojang's EULA is available to read at https://account.mojang.com/documents/minecraft_eula\"\n"); - writer.write(" echo \"If you agree to Mojang's EULA then type 'I agree'\"\n"); - writer.write("\n"); - writer.write(" echo -n \"Response: \"\n"); - writer.write(" read ANSWER\n"); - writer.write("\n"); - writer.write(" if [[ \"$ANSWER\" = \"I agree\" ]]; then\n"); - writer.write(" echo \"User agreed to Mojang's EULA.\"\n"); - writer.write( - " echo \"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\" > eula.txt;\n"); - writer.write(" echo \"eula=true\" >> eula.txt;\n"); - writer.write(" else\n"); - writer.write(" echo \"User did not agree to Mojang's EULA.\"\n"); - writer.write(" echo \"Entered: $ANSWER\"\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"eula.txt present. Moving on...\";\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("echo \"Starting server...\";\n"); - writer.write("echo \"Minecraft version: $MINECRAFT\";\n"); - writer.write("echo \"Quilt version: $QUILT\";\n"); - writer.write("echo \"Java version:\"\n"); - writer.write("\"$JAVA\" -version\n"); - writer.write("echo \"Java args: $ARGS\";\n"); - writer.write("\n"); - writer.write("\"$JAVA\" $OTHERARGS $ARGS -jar quilt-server-launch.jar nogui"); - - } catch (IOException ex) { - LOG.error("Error generating shell-script for Quilt.", ex); - } - } - - /** - * Create a Quilt batch start script. - * - * @param javaArguments String. Java arguments wich which the server should be started. - * @param minecraftVersion String. The Minecraft version of this server pack. - * @param modloaderVersion String. The modloader version of this server pack. - * @param destination String. Where the script should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX)</code> - * @author Griefed - */ - private void quiltBatchScript( - String javaArguments, String minecraftVersion, String modloaderVersion, String destination) { - - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", - destination, APPLICATIONPROPERTIES.START_SCRIPT_WINDOWS())))))) { - - if (!VERSIONMETA.minecraft().getServer(minecraftVersion).isPresent() - || !VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().isPresent()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.minecraft.server")); - return; - } - - // Quilt Batch file - writer.write( - ":: Start script generated by ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + ".\n"); - writer.write( - ":: This script checks for the Minecraft and Quilt JAR-Files, and if they are not found, they are downloaded and installed.\n"); - writer.write(":: If everything is in order, the server is started.\n"); - writer.write("@ECHO off\n"); - writer.write("SetLocal EnableDelayedExpansion\n"); - writer.write("\n"); - writer.write("net session >nul 2>&1\n"); - writer.write("if %errorLevel% == 0 (\n"); - writer.write( - " echo Warning! Running with administrator/root-privileges is not recommended.\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("PUSHD \"%~dp0\""); - writer.write("\n"); - writer.write("SET JAVA=\"java\"\n"); - writer.write("SET MINECRAFT=" + minecraftVersion + "\n"); - writer.write("SET QUILT=" + modloaderVersion + "\n"); - writer.write("SET INSTALLER=" + VERSIONMETA.quilt().releaseInstallerVersion() + "\n"); - writer.write("SET ARGS=" + javaArguments + "\n"); - writer.write("SET OTHERARGS=-Dlog4j2.formatMsgNoLookups=true\n"); - writer.write("\n"); - writer.write("IF NOT EXIST quilt-server-launch.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Quilt Server JAR-file not found. Downloading installer...\n"); - writer.write( - " powershell -Command \"(New-Object Net.WebClient).DownloadFile('https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/%INSTALLER%/quilt-installer-%INSTALLER%.jar', 'quilt-installer.jar')\"\n"); - writer.write("\n"); - writer.write(" IF EXIST quilt-installer.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Installer downloaded. Installing...\n"); - writer.write( - " %JAVA% -jar quilt-installer.jar install server %MINECRAFT% --download-server --install-dir=.\n"); - writer.write("\n"); - writer.write(" IF EXIST quilt-server-launch.jar (\n"); - writer.write(" IF EXIST quilt-installer.jar DEL quilt-installer.jar\n"); - writer.write(" ECHO Installation complete. quilt-installer.jar deleted.\n"); - writer.write(" ) ELSE (\n"); - writer.write(" IF EXIST quilt-installer.jar DEL quilt-installer.jar\n"); - writer.write( - " ECHO Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write("\n"); - writer.write(" ) ELSE (\n"); - writer.write( - " ECHO quilt-installer.jar not found. Maybe the Quilt servers are having trouble.\n"); - writer.write( - " ECHO Please try again in a couple of minutes. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO quilt-server-launch.jar present. Moving on...\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("IF NOT EXIST server.jar (\n"); - writer.write(" ECHO Minecraft Server JAR-file not found. Downloading...\n"); - writer.write( - " powershell -Command \"(New-Object Net.WebClient).DownloadFile('" - + VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().get() - + "', 'server.jar')\"\n"); - writer.write(" IF EXIST server.jar (\n"); - writer.write(" ECHO Download complete.\n"); - writer.write(" ) ELSE (\n"); - writer.write( - " ECHO Something went wrong during the server download. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO server.jar present. Moving on...\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("IF NOT EXIST eula.txt (\n"); - writer.write( - " ECHO Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA.\n"); - writer.write( - " ECHO Mojang's EULA is available to read at https://account.mojang.com/documents/minecraft_eula\n"); - writer.write(" ECHO If you agree to Mojang's EULA then type \"I agree\"\n"); - writer.write("\n"); - writer.write(" SET /p UserInput=Response: \n"); - writer.write(" GOTO check\n"); - writer.write(" \n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO eula.txt present. Moving on...\n"); - writer.write(" GOTO start\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write(":check\n"); - writer.write("IF \"%UserInput%\" == \"I agree\" (\n"); - writer.write(" ECHO User agreed to Mojang's EULA.\n"); - writer.write( - " ECHO #By changing the setting below to TRUE you are indicating your agreement to our EULA ^(https://account.mojang.com/documents/minecraft_eula^).> eula.txt\n"); - writer.write(" ECHO eula=true>> eula.txt\n"); - writer.write(") else (\n"); - writer.write(" ECHO User did not agree to Mojang's EULA. \n"); - writer.write(" ECHO Entered: %UserInput%\n"); - writer.write(" GOTO crash\n"); - writer.write(")"); - writer.write("\n"); - writer.write(":start\n"); - writer.write("ECHO Starting server...\n"); - writer.write("ECHO Minecraft version: %MINECRAFT%\n"); - writer.write("ECHO Quilt version: %QUILT%\n"); - writer.write("ECHO Java version:\n"); - writer.write("%JAVA% -version\n"); - writer.write("ECHO Java args: %ARGS%\n"); - writer.write("\n"); - writer.write("%JAVA% %OTHERARGS% %ARGS% -jar quilt-server-launch.jar nogui\n"); - writer.write("\n"); - writer.write(":quit\n"); - writer.write("ECHO Exiting...\n"); - writer.write("PAUSE\n"); - writer.write("EXIT 0\n"); - writer.write("\n"); - writer.write(":crash\n"); - writer.write("ECHO Exiting...\n"); - writer.write("PAUSE\n"); - writer.write("EXIT 1"); - - } catch (IOException ex) { - LOG.error("Error generating batch-script for Quilt.", ex); - } - } - - /** - * Create a Forge JVM args file used by Forge Minecraft 1.17 and newer. - * - * @param javaArguments String. Java arguments with which the server should be started. - * @param destination String. Where the file should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.USER_JVM_ARGS)</code> - * @author Griefed - */ - private void forgeJvmArgsTxt(String javaArguments, String destination) { - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", destination, APPLICATIONPROPERTIES.USER_JVM_ARGS())))))) { - - // User Java Args file for Minecraft 1.17+ Forge servers - writer.write("# Xmx and Xms set the maximum and minimum RAM usage, respectively.\n"); - writer.write("# They can take any number, followed by an M or a G.\n"); - writer.write("# M means Megabyte, G means Gigabyte.\n"); - writer.write("# For example, to set the maximum to 3GB: -Xmx3G\n"); - writer.write("# To set the minimum to 2.5GB: -Xms2500M\n"); - writer.write("\n"); - writer.write("# A good default for a modded server is 4GB.\n"); - writer.write("# Uncomment the next line to set it.\n"); - writer.write("# -Xmx4G\n"); - writer.write(javaArguments); - - } catch (IOException ex) { - LOG.error("Error generating user_jvm_args.txt for Forge.", ex); - } - } - - /** - * Create a Forge shell start script for Minecraft 1.17 and newer. - * - * @param javaArguments String. Java arguments with which the server should be started. - * @param minecraftVersion String. The Minecraft version of this server pack. - * @param modloaderVersion String. The modloader version of this server pack. - * @param destination String. Where the script should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX)</code> - * @author Griefed - */ - private void forgeShellScriptNewMC( - String javaArguments, String minecraftVersion, String modloaderVersion, String destination) { - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX())))))) { - - if (!VERSIONMETA.minecraft().getServer(minecraftVersion).isPresent() - || !VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().isPresent()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.minecraft.server")); - return; - } - - /* - * FORGE 1.17 AND NEWER! - * If the specified Minecraft version is newer than or equal to 1.17.1, then we need to generate scripts which run - * Forge the new way, by running @user_jvm_args.txt and @libraries[...] etc. - * - * Forge Bash - */ - writer.write("#!/usr/bin/env bash\n"); - writer.write( - "# Start script generated by ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + ".\n"); - writer.write( - "# This script checks for the Minecraft and Forge JAR-files, and if they are not found, they are downloaded and installed.\n"); - writer.write("# If everything is in order, the server is started.\n"); - writer.write("\n"); - writer.write("if [ \"$(id -u)\" = \"0\" ]; then\n"); - writer.write( - " echo \"Warning! Running with administrator-privileges is not recommended.\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("JAVA=\"java\"\n"); - writer.write("MINECRAFT=\"" + minecraftVersion + "\"\n"); - writer.write("FORGE=\"" + modloaderVersion + "\"\n"); - writer.write("ARGS=\"" + javaArguments + "\"\n"); - writer.write("OTHERARGS=\"-Dlog4j2.formatMsgNoLookups=true\"\n"); - writer.write("\n"); - writer.write( - "if [[ ! -s \"libraries/net/minecraftforge/forge/$MINECRAFT-$FORGE/forge-$MINECRAFT-$FORGE-server.jar\" ]];then\n"); - writer.write("\n"); - writer.write(" echo \"Forge Server JAR-file not found. Downloading installer...\";\n"); - writer.write( - " wget -O forge-installer.jar https://files.minecraftforge.net/maven/net/minecraftforge/forge/$MINECRAFT-$FORGE/forge-$MINECRAFT-$FORGE-installer.jar;\n"); - writer.write("\n"); - writer.write(" if [[ -s \"forge-installer.jar\" ]]; then\n"); - writer.write("\n"); - writer.write(" echo \"Installer downloaded. Installing...\";\n"); - writer.write(" \"$JAVA\" -jar forge-installer.jar --installServer;\n"); - writer.write("\n"); - writer.write( - " if [[ -s \"libraries/net/minecraftforge/forge/$MINECRAFT-$FORGE/forge-$MINECRAFT-$FORGE-server.jar\" ]];then\n"); - writer.write(" rm -f forge-installer.jar;\n"); - writer.write(" echo \"Installation complete. forge-installer.jar deleted.\";\n"); - writer.write(" else\n"); - writer.write(" rm -f forge-installer.jar\n"); - writer.write( - " echo \"Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("\n"); - writer.write(" else\n"); - writer.write( - " echo \"forge-installer.jar not found. Maybe the Forge servers are having trouble.\";\n"); - writer.write( - " echo \"Please try again in a couple of minutes and check your internet connection.\";\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"Forge server present. Moving on...\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write( - "if [[ ! -s \"libraries/net/minecraft/server/$MINECRAFT/server-$MINECRAFT.jar\" ]];then\n"); - writer.write(" echo \"Minecraft Server JAR-file not found. Downloading...\";\n"); - writer.write( - " wget -O libraries/net/minecraft/server/$MINECRAFT/server-$MINECRAFT.jar " - + VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().get() - + ";\n"); - writer.write( - " if [[ -s \"libraries/net/minecraft/server/$MINECRAFT/server-$MINECRAFT.jar\" ]];then\n"); - writer.write(" echo Download complete.\n"); - writer.write(" else\n"); - writer.write( - " echo Something went wrong during the server download. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"Minecraft server present. Moving on...\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("if [[ -s \"run.bat\" ]];then\n"); - writer.write(" rm -f run.bat;\n"); - writer.write("fi\n"); - writer.write("if [[ -s \"run.sh\" ]];then\n"); - writer.write(" rm -f run.sh;\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("if [[ ! -s \"eula.txt\" ]];then\n"); - writer.write( - " echo \"Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA.\"\n"); - writer.write( - " echo \"Mojang's EULA is available to read at https://account.mojang.com/documents/minecraft_eula\"\n"); - writer.write(" echo \"If you agree to Mojang's EULA then type 'I agree'\"\n"); - writer.write("\n"); - writer.write(" echo -n \"Response: \"\n"); - writer.write(" read ANSWER\n"); - writer.write("\n"); - writer.write(" if [[ \"$ANSWER\" = \"I agree\" ]]; then\n"); - writer.write(" echo \"User agreed to Mojang's EULA.\"\n"); - writer.write( - " echo \"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\" > eula.txt;\n"); - writer.write(" echo \"eula=true\" >> eula.txt;\n"); - writer.write(" else\n"); - writer.write(" echo \"User did not agree to Mojang's EULA.\"\n"); - writer.write(" echo \"Entered: $ANSWER\"\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"eula.txt present. Moving on...\";\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("echo \"Starting server...\";\n"); - writer.write("echo \"Minecraft version: $MINECRAFT\";\n"); - writer.write("echo \"Forge version: $FORGE\";\n"); - writer.write("echo \"Java version:\"\n"); - writer.write("$JAVA -version\n"); - writer.write("echo \"Java args in user_jvm_args.txt: $ARGS\";\n"); - writer.write("\n"); - writer.write("# Forge requires a configured set of both JVM and program arguments.\n"); - writer.write("# Add custom JVM arguments to the user_jvm_args.txt\n"); - writer.write( - "# Add custom program arguments {such as nogui} to this file in the next line before the \"$@\" or\n"); - writer.write("# pass them to this script directly\n"); - writer.write( - "echo \"If you receive the error message 'Error: Could not find or load main class @user_jvm_args.txt' you may be using the wrong Java-version for this modded Minecraft server. Contact the modpack-developer or, if you made the server pack yourself, do a quick google-search for the used Minecraft version to find out which Java-version is required in order to run this server.\"\n"); - writer.write("\n"); - writer.write( - "$JAVA $OTHERARGS @user_jvm_args.txt @libraries/net/minecraftforge/forge/$MINECRAFT-$FORGE/unix_args.txt nogui \"$@\""); - - } catch (IOException ex) { - LOG.error("Error generating shell-script for Forge.", ex); - } - } - - /** - * Create a Forge batch script for Minecraft 1.17 and newer. - * - * @param minecraftVersion String. The Minecraft version of this server pack. - * @param modloaderVersion String. The modloader version of this server pack. - * @param destination String. Where the script should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_WINDOWS) - * </code> - * @author Griefed - */ - private void forgeBatchScriptNewMC( - String minecraftVersion, String modloaderVersion, String destination) { - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", - destination, APPLICATIONPROPERTIES.START_SCRIPT_WINDOWS())))))) { - - if (!VERSIONMETA.minecraft().getServer(minecraftVersion).isPresent() - || !VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().isPresent()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.minecraft.server")); - return; - } - - /* - * FORGE 1.17 AND NEWER! - * If the specified Minecraft version is newer than or equal to 1.17.1, then we need to generate scripts which run - * Forge the new way, by running @user_jvm_args.txt and @libraries[...] etc. - * - * Forge Batch - */ - writer.write( - ":: Start script generated by ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + "\n"); - writer.write( - ":: This script checks for the Minecraft and Forge JAR-files, and if they are not found, they are downloaded and installed.\n"); - writer.write(":: If everything is in order, the server is started.\n"); - writer.write("@ECHO off\n"); - writer.write("SetLocal EnableDelayedExpansion\n"); - writer.write("\n"); - writer.write("net session >nul 2>&1\n"); - writer.write("if %errorLevel% == 0 (\n"); - writer.write( - " echo Warning! Running with administrator/root-privileges is not recommended.\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("PUSHD \"%~dp0\""); - writer.write("\n"); - writer.write("SET JAVA=\"java\"\n"); - writer.write("SET MINECRAFT=" + minecraftVersion + "\n"); - writer.write("SET FORGE=" + modloaderVersion + "\n"); - writer.write("SET OTHERARGS=-Dlog4j2.formatMsgNoLookups=true\n"); - writer.write("\n"); - writer.write( - "IF NOT EXIST libraries/net/minecraftforge/forge/%MINECRAFT%-%FORGE%/forge-%MINECRAFT%-%FORGE%-server.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Forge Server JAR-file not found. Downloading installer...\n"); - writer.write( - " powershell -Command \"(New-Object Net.WebClient).DownloadFile('https://files.minecraftforge.net/maven/net/minecraftforge/forge/%MINECRAFT%-%FORGE%/forge-%MINECRAFT%-%FORGE%-installer.jar', 'forge-installer.jar')\"\n"); - writer.write("\n"); - writer.write(" IF EXIST forge-installer.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Installer downloaded. Installing...\n"); - writer.write(" %JAVA% -jar forge-installer.jar --installServer\n"); - writer.write("\n"); - writer.write( - " IF EXIST libraries/net/minecraftforge/forge/%MINECRAFT%-%FORGE%/forge-%MINECRAFT%-%FORGE%-server.jar (\n"); - writer.write(" IF EXIST forge-installer.jar DEL forge-installer.jar\n"); - writer.write(" ECHO Installation complete. forge-installer.jar deleted.\n"); - writer.write(" ) ELSE (\n"); - writer.write(" IF EXIST forge-installer.jar DEL forge-installer.jar\n"); - writer.write( - " ECHO Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO quit\n"); - writer.write(" )\n"); - writer.write("\n"); - writer.write(" ) ELSE (\n"); - writer.write( - " ECHO forge-installer.jar not found. Maybe the Forge servers are having trouble.\n"); - writer.write( - " ECHO Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO quit\n"); - writer.write(" )\n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO Forge server present. Moving on...\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write( - "IF NOT EXIST libraries/net/minecraft/server/%MINECRAFT%/server-%MINECRAFT%.jar (\n"); - writer.write(" ECHO Minecraft Server JAR-file not found. Downloading...\n"); - writer.write(" IF NOT EXIST libraries/net/minecraft/server/%MINECRAFT%/NUL (\n"); - writer.write(" MKDIR \"libraries/net/minecraft/server/%MINECRAFT%\"\n"); - writer.write(" )\n"); - writer.write( - " powershell -Command \"(New-Object Net.WebClient).DownloadFile('" - + VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().get() - + "', 'libraries/net/minecraft/server/%MINECRAFT%/server-%MINECRAFT%.jar')\"\n"); - writer.write( - " IF EXIST libraries/net/minecraft/server/%MINECRAFT%/server-%MINECRAFT%.jar (\n"); - writer.write(" ECHO Download complete.\n"); - writer.write(" ) ELSE (\n"); - writer.write( - " ECHO Something went wrong during the server download. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO quit\n"); - writer.write(" )\n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO Minecraft server present. Moving on...\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("IF EXIST run.bat (\n"); - writer.write(" DEL run.bat\n"); - writer.write(")\n"); - writer.write("IF EXIST run.sh (\n"); - writer.write(" DEL run.sh\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("IF NOT EXIST eula.txt (\n"); - writer.write( - " ECHO Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA.\n"); - writer.write( - " ECHO Mojang's EULA is available to read at https://account.mojang.com/documents/minecraft_eula\n"); - writer.write(" ECHO If you agree to Mojang's EULA then type \"I agree\"\n"); - writer.write("\n"); - writer.write(" SET /p UserInput=Response: \n"); - writer.write(" GOTO check\n"); - writer.write(" \n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO eula.txt present. Moving on...\n"); - writer.write(" GOTO start\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write(":check\n"); - writer.write("IF \"%UserInput%\" == \"I agree\" (\n"); - writer.write(" ECHO User agreed to Mojang's EULA.\n"); - writer.write( - " ECHO #By changing the setting below to TRUE you are indicating your agreement to our EULA ^(https://account.mojang.com/documents/minecraft_eula^).> eula.txt\n"); - writer.write(" ECHO eula=true>> eula.txt\n"); - writer.write(") else (\n"); - writer.write(" ECHO User did not agree to Mojang's EULA. \n"); - writer.write(" ECHO Entered: %UserInput%\n"); - writer.write(" GOTO quit\n"); - writer.write(")"); - writer.write("\n"); - writer.write(":start\n"); - writer.write("ECHO Starting server...\n"); - writer.write("ECHO Minecraft version: %MINECRAFT%\n"); - writer.write("ECHO Forge version: %FORGE%\n"); - writer.write("ECHO Java version:\n"); - writer.write("\"%JAVA%\" -version\n"); - writer.write("ECHO See user_jvm_args.txt if you want to inspect the used JVM args\n"); - writer.write("\n"); - writer.write("ECHO Forge requires a configured set of both JVM and program arguments.\n"); - writer.write("ECHO Add custom JVM arguments to the user_jvm_args.txt\n"); - writer.write( - "ECHO Add custom program arguments, such as nogui, to this file in the next line before the %* or pass them to this script directly.\n"); - writer.write( - "ECHO If you receive the error message \"Error: Could not find or load main class @user_jvm_args.txt\" you may be using the wrong Java-version for this modded Minecraft server. Contact the modpack-developer or, if you made the server pack yourself, do a quick google-search for the used Minecraft version to find out which Java-version is required in order to run this server.\n"); - writer.write("\n"); - writer.write( - "%JAVA% %OTHERARGS% @user_jvm_args.txt @libraries/net/minecraftforge/forge/%MINECRAFT%-%FORGE%/win_args.txt nogui %*\n"); - writer.write("\n"); - writer.write(":quit\n"); - writer.write("ECHO Exiting...\n"); - writer.write("PAUSE\n"); - writer.write("EXIT 0\n"); - writer.write("\n"); - writer.write(":crash\n"); - writer.write("ECHO Exiting...\n"); - writer.write("PAUSE\n"); - writer.write("EXIT 1"); - - } catch (IOException ex) { - LOG.error("Error generating batch-script for Forge.", ex); - } - } - - /** - * Create a Forge shell script for Minecraft 1.16 and older. - * - * @param javaArguments String. The Java arguments with which to start the server. - * @param minecraftVersion String. The Minecraft version of this server pack. - * @param modloaderVersion String. The modloader version of this server pack. - * @param destination String. Where the script should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX)</code> - * @author Griefed - */ - private void forgeShellScript( - String javaArguments, String minecraftVersion, String modloaderVersion, String destination) { - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_LINUX())))))) { - - if (!VERSIONMETA.minecraft().getServer(minecraftVersion).isPresent() - || !VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().isPresent()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.minecraft.server")); - return; - } - - /* - * FORGE 1.16 AND OLDER! - * If the specified Minecraft version is older than 1.17.1, then we need to generate scripts which run - * Forge the old way, with the Minecraft server-jar and the Forge server-jar, executing the Forge server-jar - * with the given Java args. - * - * Forge Bash file - */ - writer.write("#!/usr/bin/env bash\n"); - writer.write( - "# Start script generated by ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + ".\n"); - writer.write( - "# This script checks for the Minecraft and Forge JAR-files, and if they are not found, they are downloaded and installed.\n"); - writer.write("# If everything is in order, the server is started.\n"); - writer.write("\n"); - writer.write("if [ \"$(id -u)\" = \"0\" ]; then\n"); - writer.write( - " echo \"Warning! Running with administrator-privileges is not recommended.\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("JAVA=\"java\"\n"); - writer.write("MINECRAFT=\"" + minecraftVersion + "\"\n"); - writer.write("FORGE=\"" + modloaderVersion + "\"\n"); - writer.write("ARGS=\"" + javaArguments + "\"\n"); - writer.write("OTHERARGS=\"-Dlog4j2.formatMsgNoLookups=true\"\n"); - writer.write("\n"); - writer.write("if [[ ! -s \"forge.jar\" ]];then\n"); - writer.write("\n"); - writer.write(" echo \"Forge Server JAR-file not found. Downloading installer...\";\n"); - writer.write( - " wget -O forge-installer.jar https://files.minecraftforge.net/maven/net/minecraftforge/forge/$MINECRAFT-$FORGE/forge-$MINECRAFT-$FORGE-installer.jar;\n"); - writer.write("\n"); - writer.write(" if [[ -s \"forge-installer.jar\" ]]; then\n"); - writer.write("\n"); - writer.write(" echo \"Installer downloaded. Installing...\";\n"); - writer.write(" \"$JAVA\" -jar forge-installer.jar --installServer;\n"); - writer.write(" mv forge-$MINECRAFT-$FORGE.jar forge.jar;\n"); - writer.write("\n"); - writer.write(" if [[ -s \"forge.jar\" ]];then\n"); - writer.write(" rm -f forge-installer.jar;\n"); - writer.write(" echo \"Installation complete. forge-installer.jar deleted.\";\n"); - writer.write(" else\n"); - writer.write(" rm -f forge-installer.jar;\n"); - writer.write( - " echo \"Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection.\"\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("\n"); - writer.write(" else\n"); - writer.write( - " echo \"forge-installer.jar not found. Maybe the Forge servers are having trouble.\";\n"); - writer.write( - " echo \"Please try again in a couple of minutes and check your internet connection.\";\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"forge.jar present. Moving on...\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("if [[ ! -s \"minecraft_server.$MINECRAFT.jar\" ]];then\n"); - writer.write(" echo \"Minecraft Server JAR-file not found. Downloading...\";\n"); - writer.write( - " wget -O minecraft_server.$MINECRAFT.jar " - + VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().get() - + ";\n"); - writer.write(" if [[ -s \"minecraft_server.$MINECRAFT.jar\" ]];then\n"); - writer.write(" echo Download complete.\n"); - writer.write(" else\n"); - writer.write( - " echo Something went wrong during the server download. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"minecraft_server.$MINECRAFT.jar present. Moving on...\"\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("if [[ ! -s \"eula.txt\" ]];then\n"); - writer.write( - " echo \"Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA.\"\n"); - writer.write( - " echo \"Mojang's EULA is available to read at https://account.mojang.com/documents/minecraft_eula\"\n"); - writer.write(" echo \"If you agree to Mojang's EULA then type 'I agree'\"\n"); - writer.write("\n"); - writer.write(" echo -n \"Response: \"\n"); - writer.write(" read ANSWER\n"); - writer.write("\n"); - writer.write(" if [[ \"$ANSWER\" = \"I agree\" ]]; then\n"); - writer.write(" echo \"User agreed to Mojang's EULA.\"\n"); - writer.write( - " echo \"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\" > eula.txt;\n"); - writer.write(" echo \"eula=true\" >> eula.txt;\n"); - writer.write(" else\n"); - writer.write(" echo \"User did not agree to Mojang's EULA.\"\n"); - writer.write(" echo \"Entered: $ANSWER\"\n"); - writer.write(" echo \"Exiting...\"\n"); - writer.write(" read -n 1 -s -r -p \"Press any key to continue\"\n"); - writer.write(" exit 1\n"); - writer.write(" fi\n"); - writer.write("else\n"); - writer.write(" echo \"eula.txt present. Moving on...\";\n"); - writer.write("fi\n"); - writer.write("\n"); - writer.write("echo \"Starting server...\";\n"); - writer.write("echo \"Minecraft version: $MINECRAFT\";\n"); - writer.write("echo \"Forge version: $FORGE\";\n"); - writer.write("echo \"Java version:\"\n"); - writer.write("\"$JAVA\" -version\n"); - writer.write("echo \"Java args: $ARGS\";\n"); - writer.write("\n"); - writer.write("\"$JAVA\" $OTHERARGS $ARGS -jar forge.jar nogui"); - - } catch (IOException ex) { - LOG.error("Error generating shell-script for Forge.", ex); - } - } - - /** - * Create a forge batch script for Minecraft 1.16 and older. - * - * @param javaArguments String. The Java arguments with which to start the server. - * @param minecraftVersion String. The Minecraft version of this server pack. - * @param modloaderVersion String. The modloader version of this server pack. - * @param destination String. Where the script should be written to. Result is a combination of - * <code>String.format("%s/%s", destination, APPLICATIONPROPERTIES.START_SCRIPT_WINDOWS) - * </code> - * @author Griefed - */ - private void forgeBatchScript( - String javaArguments, String minecraftVersion, String modloaderVersion, String destination) { - try (BufferedWriter writer = - new BufferedWriter( - new FileWriter( - String.valueOf( - Paths.get( - String.format( - "%s/%s", - destination, APPLICATIONPROPERTIES.START_SCRIPT_WINDOWS())))))) { - - if (!VERSIONMETA.minecraft().getServer(minecraftVersion).isPresent() - || !VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().isPresent()) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.minecraft.server")); - return; + FileUtils.writeStringToFile(destinationScript, scriptContent, StandardCharsets.UTF_8); + } catch (Exception ex) { + LOG.error("File not accessible: " + template + ".", ex); } - - /* - * FORGE 1.16 AND OLDER! - * If the specified Minecraft version is older than 1.17.1, then we need to generate scripts which run - * Forge the old way, with the Minecraft server-jar and the Forge server-jar, executing the Forge server-jar - * with the given Java args. - * - * Forge Batch - */ - writer.write( - ":: Start script generated by ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + ".\n"); - writer.write( - ":: This script checks for the Minecraft and Forge JAR-files, and if they are not found, they are downloaded and installed.\n"); - writer.write(":: If everything is in order, the server is started.\n"); - writer.write("@ECHO off\n"); - writer.write("SetLocal EnableDelayedExpansion\n"); - writer.write("\n"); - writer.write("net session >nul 2>&1\n"); - writer.write("if %errorLevel% == 0 (\n"); - writer.write( - " ECHO Warning! Running with administrator/root-privileges is not recommended.\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("PUSHD \"%~dp0\""); - writer.write("\n"); - writer.write("SET JAVA=\"java\"\n"); - writer.write("SET MINECRAFT=" + minecraftVersion + "\n"); - writer.write("SET FORGE=" + modloaderVersion + "\n"); - writer.write("SET ARGS=" + javaArguments + "\n"); - writer.write("SET OTHERARGS=-Dlog4j2.formatMsgNoLookups=true\n"); - writer.write("\n"); - writer.write("IF NOT EXIST forge.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Forge Server JAR-file not found. Downloading installer...\n"); - writer.write( - " powershell -Command \"(New-Object Net.WebClient).DownloadFile('https://files.minecraftforge.net/maven/net/minecraftforge/forge/%MINECRAFT%-%FORGE%/forge-%MINECRAFT%-%FORGE%-installer.jar', 'forge-installer.jar')\"\n"); - writer.write("\n"); - writer.write(" IF EXIST forge-installer.jar (\n"); - writer.write("\n"); - writer.write(" ECHO Installer downloaded. Installing...\n"); - writer.write(" %JAVA% -jar forge-installer.jar --installServer\n"); - writer.write(" MOVE forge-%MINECRAFT%-%FORGE%.jar forge.jar\n"); - writer.write("\n"); - writer.write(" IF EXIST forge.jar (\n"); - writer.write(" IF EXIST forge-installer.jar DEL forge-installer.jar\n"); - writer.write(" ECHO Installation complete. forge-installer.jar deleted.\n"); - writer.write(" ) ELSE (\n"); - writer.write(" IF EXIST forge-installer.jar DEL forge-installer.jar\n"); - writer.write( - " ECHO Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write("\n"); - writer.write(" ) ELSE (\n"); - writer.write( - " ECHO forge-installer.jar not found. Maybe the Forge servers are having trouble.\n"); - writer.write( - " ECHO Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO forge.jar present. Moving on...\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("IF NOT EXIST minecraft_server.%MINECRAFT%.jar (\n"); - writer.write(" ECHO Minecraft Server JAR-file not found. Downloading...\n"); - writer.write( - " powershell -Command \"(New-Object Net.WebClient).DownloadFile('" - + VERSIONMETA.minecraft().getServer(minecraftVersion).get().url().get() - + "', 'minecraft_server.%MINECRAFT%.jar')\"\n"); - writer.write(" IF EXIST minecraft_server.%MINECRAFT%.jar (\n"); - writer.write(" ECHO Download complete.\n"); - writer.write(" ) ELSE (\n"); - writer.write( - " ECHO Something went wrong during the server download. Please try again in a couple of minutes and check your internet connection.\n"); - writer.write(" GOTO crash\n"); - writer.write(" )\n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO minecraft_server.%MINECRAFT%.jar present. Moving on...\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write("IF NOT EXIST eula.txt (\n"); - writer.write( - " ECHO Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA.\n"); - writer.write( - " ECHO Mojang's EULA is available to read at https://account.mojang.com/documents/minecraft_eula\n"); - writer.write(" ECHO If you agree to Mojang's EULA then type \"I agree\"\n"); - writer.write("\n"); - writer.write(" SET /p UserInput=Response: \n"); - writer.write(" GOTO check\n"); - writer.write(" \n"); - writer.write(") ELSE (\n"); - writer.write(" ECHO eula.txt present. Moving on...\n"); - writer.write(" GOTO start\n"); - writer.write(")\n"); - writer.write("\n"); - writer.write(":check\n"); - writer.write("IF \"%UserInput%\" == \"I agree\" (\n"); - writer.write(" ECHO User agreed to Mojang's EULA.\n"); - writer.write( - " ECHO #By changing the setting below to TRUE you are indicating your agreement to our EULA ^(https://account.mojang.com/documents/minecraft_eula^).> eula.txt\n"); - writer.write(" ECHO eula=true>> eula.txt\n"); - writer.write(") else (\n"); - writer.write(" ECHO User did not agree to Mojang's EULA. \n"); - writer.write(" ECHO Entered: %UserInput%\n"); - writer.write(" GOTO crash\n"); - writer.write(")"); - writer.write("\n"); - writer.write(":start\n"); - writer.write("ECHO Starting server...\n"); - writer.write("ECHO Minecraft version: %MINECRAFT%\n"); - writer.write("ECHO Forge version: %FORGE%\n"); - writer.write("ECHO Java version:\n"); - writer.write("%JAVA% -version\n"); - writer.write("ECHO Java args: %ARGS%\n"); - writer.write("\n"); - writer.write("%JAVA% %OTHERARGS% %ARGS% -jar forge.jar nogui\n"); - writer.write("\n"); - writer.write(":quit\n"); - writer.write("ECHO Exiting...\n"); - writer.write("PAUSE\n"); - writer.write("EXIT 0\n"); - writer.write("\n"); - writer.write(":crash\n"); - writer.write("ECHO Exiting...\n"); - writer.write("PAUSE\n"); - writer.write("EXIT 1"); - - } catch (IOException ex) { - LOG.error("Error generating batch-script for Forge.", ex); } } @@ -1940,21 +533,13 @@ public class ServerPackHandler { if (directoriesToCopy.size() == 1 && directoriesToCopy.get(0).equals("lazy_mode")) { + LOG.warn("!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!"); LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode0")); - LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode1")); - LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode2")); + "Lazy mode specified. This will copy the WHOLE modpack to the server pack. No exceptions."); + LOG.warn("You will not receive any support for a server pack generated this way."); LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode3")); - LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode0")); + "Do not open an issue on GitHub if this configuration errors or results in a broken server pack."); + LOG.warn("!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!"); try { @@ -1982,11 +567,7 @@ public class ServerPackHandler { String clientDir = String.format("%s/%s", modpackDir, directory).replace("\\", "/"); String serverDir = String.format("%s/%s", destination, directory).replace("\\", "/"); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.copyfiles.setup"), - directory)); + LOG.info("Gathering " + directory + " file(s) and folder(s)."); if (directory.contains(";")) { @@ -2050,7 +631,7 @@ public class ServerPackHandler { } } - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.copyfiles.copy")); + LOG.info("Copying files to the server pack. This may take a while..."); serverPackFiles.forEach( serverPackFile -> { @@ -2133,19 +714,13 @@ public class ServerPackHandler { .resolve(Paths.get(source).relativize(file)))); } catch (UnsupportedOperationException ex) { - LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.error.copy.directory"), - file, - source), - ex); + LOG.error("Couldn't gather file " + file + " from directory " + source + ".", ex); } }); } catch (IOException ex) { - LOG.error(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.error.copy"), ex); + LOG.error("An error occurred gathering files to copy to the server pack.", ex); } return serverPackFiles; @@ -2177,13 +752,7 @@ public class ServerPackHandler { Paths.get(String.format("%s/%s", destination, directory.substring(6))) .resolve(Paths.get(clientDir).relativize(file)))); } catch (UnsupportedOperationException ex) { - LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.error.copy.directory"), - file, - clientDir), - ex); + LOG.error("Couldn't gather file " + file + " from directory " + clientDir + ".", ex); } }); @@ -2213,8 +782,8 @@ public class ServerPackHandler { List<String> userSpecifiedClientMods, String minecraftVersion, String modloader) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.excludeclientmods")); + + LOG.info("Preparing a list of mods to include in server pack..."); Collection<File> filesInModsDir = FileUtils.listFiles(new File(modsDir), new String[] {"jar"}, true); @@ -2336,8 +905,7 @@ public class ServerPackHandler { */ private void copyIcon(String destination, String pathToServerIcon) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.copyicon")); + LOG.info("Copying server-icon.png..."); File iconFile = new File(String.format("%s/%s", destination, APPLICATIONPROPERTIES.DEFAULT_SERVER_ICON())); @@ -2389,8 +957,7 @@ public class ServerPackHandler { } else if (pathToServerIcon.length() == 0) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.icon")); + LOG.info("No custom icon specified or the file doesn't exist."); try { @@ -2404,10 +971,7 @@ public class ServerPackHandler { } else { - LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.servericon"), - pathToServerIcon)); + LOG.error("The specified server-icon does not exist: " + pathToServerIcon); } } @@ -2420,8 +984,7 @@ public class ServerPackHandler { */ private void copyProperties(String destination, String pathToServerProperties) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.copyproperties")); + LOG.info("Copying server.properties..."); File defaultProperties = new File( @@ -2438,8 +1001,7 @@ public class ServerPackHandler { } else if (pathToServerProperties.length() == 0) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.properties")); + LOG.info("No custom properties specified or the file doesn't exist."); try { @@ -2455,10 +1017,7 @@ public class ServerPackHandler { } else { - LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.serverproperties"), - pathToServerProperties)); + LOG.error("The specified server.properties does not exist: " + pathToServerProperties); } } @@ -2492,20 +1051,14 @@ public class ServerPackHandler { switch (modLoader) { case "Fabric": - - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG_INSTALLER.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.installserver.fabric.enter")); + LOG_INSTALLER.info("Starting Fabric installation."); fileDestination = String.format("%s/fabric-installer.jar", destination); if (UTILITIES.WebUtils() .downloadFile(fileDestination, VERSIONMETA.fabric().releaseInstallerUrl())) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.installserver.fabric.download")); + + LOG.info("Fabric installer successfully downloaded."); commandArguments.add(javaPath); commandArguments.add("-jar"); @@ -2525,11 +1078,7 @@ public class ServerPackHandler { break; case "Forge": - - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG_INSTALLER.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.installserver.forge.enter")); + LOG_INSTALLER.info("Starting Forge installation."); fileDestination = String.format("%s/forge-installer.jar", destination); @@ -2543,10 +1092,7 @@ public class ServerPackHandler { .get() .installerUrl())) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.installserver.forge.download")); + LOG.info("Forge installer successfully downloaded."); commandArguments.add(javaPath); commandArguments.add("-jar"); commandArguments.add("forge-installer.jar"); @@ -2560,20 +1106,14 @@ public class ServerPackHandler { break; case "Quilt": - - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG_INSTALLER.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.installserver.quilt.enter")); + LOG_INSTALLER.info("Starting Quilt installation."); fileDestination = String.format("%s/quilt-installer.jar", destination); if (UTILITIES.WebUtils() .downloadFile(fileDestination, VERSIONMETA.quilt().releaseInstallerUrl())) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.installserver.quilt.download")); + + LOG.info("Quilt installer successfully downloaded."); commandArguments.add(javaPath); commandArguments.add("-jar"); @@ -2592,21 +1132,20 @@ public class ServerPackHandler { break; default: - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.error( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.checkmodloader"), - modLoader)); + "Invalid modloader specified. Modloader must be either Forge, Fabric or Quilt. Specified: " + + modLoader); } try { LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.installserver.enter"), - minecraftVersion, - modLoader, - modLoaderVersion)); + "Starting server installation for Minecraft " + + minecraftVersion + + ", " + + modLoader + + " " + + modLoaderVersion + + "."); ProcessBuilder processBuilder = new ProcessBuilder(commandArguments).directory(new File(destination)); @@ -2627,24 +1166,26 @@ public class ServerPackHandler { LOG_INSTALLER.info(line); } - /* This log is meant to be read by the user, therefore we allow translation. */ LOG_INSTALLER.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.installserver"), - minecraftVersion, - modLoader, - modLoaderVersion)); + "Server for Minecraft " + + minecraftVersion + + ", " + + modLoader + + " " + + modLoaderVersion + + " installed."); - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.installserver"), - minecraftVersion, - modLoader, - modLoaderVersion)); + "Server for Minecraft " + + minecraftVersion + + ", " + + modLoader + + " " + + modLoaderVersion + + " installed."); + LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.installserver.details")); + "For details regarding the installation of this modloader server, see logs/modloader_installer.log."); } catch (IOException ex) { @@ -2676,7 +1217,7 @@ public class ServerPackHandler { .equalsIgnoreCase("true")) { cleanUpServerPack(minecraftVersion, modLoaderVersion, destination); } else { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.cleanup")); + LOG.info("Server pack cleanup disabled."); } } @@ -2702,13 +1243,13 @@ public class ServerPackHandler { String modloader, String modloaderVersion) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.zipbuilder.enter")); + LOG.info("Creating zip archive of serverpack..."); ZipParameters zipParameters = new ZipParameters(); List<File> filesToExclude = new ArrayList<>(100); if (APPLICATIONPROPERTIES.isZipFileExclusionEnabled()) { + APPLICATIONPROPERTIES .getFilesToExcludeFromZipArchive() .forEach( @@ -2726,21 +1267,21 @@ public class ServerPackHandler { zipParameters.setExcludeFileFilter(excludeFileFilter); } else { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.zipbuilder.exclusion.deactivated")); + + LOG.info("File exclusion from ZIP-archives deactivated."); } + String comment = "Server pack made with ServerPackCreator " + + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() + + " by Griefed."; + zipParameters.setIncludeRootFolder(false); - zipParameters.setFileComment( - "Server pack made with ServerPackCreator " - + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION() - + " by Griefed."); + zipParameters.setFileComment(comment); try (ZipFile zip = new ZipFile(String.format("%s_server_pack.zip", destination))) { zip.addFolder(new File(destination), zipParameters); + zip.setComment(comment); } catch (IOException ex) { @@ -2749,20 +1290,15 @@ public class ServerPackHandler { if (includeServerInstallation) { - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.warn.zipbuilder.minecraftjar1")); + "!!!-------NOTE: The minecraft_server.jar will not be included in the zip-archive.-------!!!"); LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.warn.zipbuilder.minecraftjar2")); + "!!!-Mojang strictly prohibits the distribution of their software through third parties.-!!!"); LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.warn.zipbuilder.minecraftjar3")); + "!!!---Tell your users to execute the download scripts to get the Minecraft server jar.--!!!"); } - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.zipbuilder.finish")); + LOG.info("Finished creation of zip archive."); } /** @@ -2779,36 +1315,33 @@ public class ServerPackHandler { private void cleanUpServerPack( String minecraftVersion, String modLoaderVersion, String destination) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.cleanupserverpack.enter")); - - FileUtils.deleteQuietly(new File(String.format("%s/fabric-installer.jar", destination))); - FileUtils.deleteQuietly(new File(String.format("%s/forge-installer.jar", destination))); - FileUtils.deleteQuietly(new File(String.format("%s/quilt-installer.jar", destination))); - FileUtils.deleteQuietly(new File(String.format("%s/installer.log", destination))); - FileUtils.deleteQuietly(new File(String.format("%s/forge-installer.jar.log", destination))); + LOG.info("Cleanup after modloader server installation."); - Path path = - Paths.get( - String.format("%s/forge-%s-%s.jar", destination, minecraftVersion, modLoaderVersion)); + FileUtils.deleteQuietly(new File(destination + "/fabric-installer.jar")); + FileUtils.deleteQuietly(new File(destination + "/forge-installer.jar")); + FileUtils.deleteQuietly(new File(destination + "/quilt-installer.jar")); + FileUtils.deleteQuietly(new File(destination + "/installer.log")); + FileUtils.deleteQuietly(new File(destination + "/forge-installer.jar.log")); + FileUtils.deleteQuietly(Paths.get(destination + "/run.bat").toFile()); + FileUtils.deleteQuietly(Paths.get(destination + "/run.sh").toFile()); + FileUtils.deleteQuietly(Paths.get(destination + "/user_jvm_args.txt").toFile()); try { + Path path = + Paths.get( + String.format(destination + "/forge-%s-%s.jar", minecraftVersion, modLoaderVersion)); if (new File( - String.format("%s/forge-%s-%s.jar", destination, minecraftVersion, modLoaderVersion)) + String.format(destination + "/forge-%s-%s.jar", minecraftVersion, modLoaderVersion)) .exists()) { - Files.copy(path, Paths.get(String.format("%s/forge.jar", destination)), REPLACE_EXISTING); + + Files.copy(path, Paths.get(destination + "/forge.jar"), REPLACE_EXISTING); + FileUtils.deleteQuietly(path.toFile()); } } catch (IOException ignored) { } - - FileUtils.deleteQuietly(path.toFile()); - FileUtils.deleteQuietly(Paths.get(String.format("%s/run.bat", destination)).toFile()); - FileUtils.deleteQuietly(Paths.get(String.format("%s/run.sh", destination)).toFile()); } /** @@ -2831,7 +1364,7 @@ public class ServerPackHandler { * Can I just say: * WHAT THE EVERLOVING FUCK IS THIS METHOD? try catch if try catch if else try catch what the actual fucking fuck? */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.scantoml")); + LOG.info("Scanning Minecraft 1.13.x and newer Forge mods for sideness..."); List<String> serverMods = new ArrayList<>(); List<String> modsDelta = new ArrayList<>(); @@ -3167,7 +1700,7 @@ public class ServerPackHandler { */ private List<String> scanAnnotations(Collection<File> filesInModsDir) { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.scanannotation")); + LOG.info("Scanning Minecraft 1.12.x and older mods for sideness..."); List<String> modDependencies = new ArrayList<>(); List<String> clientMods = new ArrayList<>(); @@ -3263,7 +1796,7 @@ public class ServerPackHandler { // ModIDs are different, possibly two mods in one JAR-file....... } else { - // Add additional modId to list so we can check those later + // Add additional modId to list, so we can check those later additionalMods.add( child.get("values").get("modid").get("value").asText()); } @@ -3644,7 +2177,7 @@ public class ServerPackHandler { * @author Griefed */ private List<String> scanFabricModJson(Collection<File> filesInModsDir) { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.scanfabricmodjson")); + LOG.info("Scanning Fabric mods for sideness..."); List<String> modDependencies = new ArrayList<>(); List<String> clientMods = new ArrayList<>(); @@ -3826,7 +2359,7 @@ public class ServerPackHandler { * @author Griefed */ private List<String> scanQuiltModJson(Collection<File> filesInModsDir) { - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.scanquiltmodjson")); + LOG.info("Scanning Quilt mods for sideness..."); List<String> modDependencies = new ArrayList<>(); List<String> clientMods = new ArrayList<>(); diff --git a/backend/main/java/de/griefed/serverpackcreator/i18n/LocalizationManager.java b/backend/main/java/de/griefed/serverpackcreator/i18n/I18n.java similarity index 85% rename from backend/main/java/de/griefed/serverpackcreator/i18n/LocalizationManager.java rename to backend/main/java/de/griefed/serverpackcreator/i18n/I18n.java index c3640ddb0118c50d4e365f917eca96816d96bb52..537a8d39ac90203afe4bd77e57bdc320552d5d1b 100644 --- a/backend/main/java/de/griefed/serverpackcreator/i18n/LocalizationManager.java +++ b/backend/main/java/de/griefed/serverpackcreator/i18n/I18n.java @@ -48,10 +48,9 @@ import org.springframework.stereotype.Component; /** * This is the localizationManager for ServerPackCreator.<br> - * To use it, initialize it by calling {@link #initialize()}. Then use {@link - * #getLocalizedString(String)} to use a language key from the resource bundle corresponding to the - * specified locale. If no locale is provided during the launch of ServerPackCreator, en_US is used - * by default.<br> + * To use it, initialize it by calling {@link #initialize()}. Then use {@link #getMessage(String)} + * to use a language key from the resource bundle corresponding to the specified locale. If no + * locale is provided during the launch of ServerPackCreator, en_US is used by default.<br> * All localization properties-files need to be stored in the <code>de/griefed/resources/lang/ * </code>-directory and be named using following pattern: lang_{language code in * lowercase}_{country code in lowercase}. For example: <code>lang_en_us.properties</code>.<br> @@ -59,20 +58,21 @@ import org.springframework.stereotype.Component; * By default, ServerPackCreator tries to load language definitions from the local filesystem, in * the <code>lang</code>-folder. If no file can be found for the specified locale, ServerPackCreator * tries to load language definitions from inside the JAR-file, from the resource bundles. If the - * specified key can not be retrieved when calling {@link #getLocalizedString(String)}, a default is + * specified key can not be retrieved when calling {@link #getMessage(String)}, a default is * retrieved from the lang_en_us-bundle inside the JAR-file by default. * * @author whitebear60 * @author Griefed */ @Component -public class LocalizationManager { +public class I18n { - private static final Logger LOG = LogManager.getLogger(LocalizationManager.class); + private static final Logger LOG = LogManager.getLogger(I18n.class); private final ApplicationProperties APPLICATIONPROPERTIES; private final ResourceBundle FALLBACKRESOURCES = - ResourceBundle.getBundle("de/griefed/resources/lang/lang_en_us", new Locale("en", "us")); + ResourceBundle.getBundle( + "de/griefed/resources/lang/lang_en_us", new Locale("en", "us"), new UTF8Control()); private final Map<String, String> CURRENT_LANGUAGE = new HashMap<>(); private final File PROPERTIESFILE = new File("serverpackcreator.properties"); private final String MAP_PATH_LANGUAGE = "language"; @@ -84,17 +84,17 @@ public class LocalizationManager { private ResourceBundle jarResources = null; /** - * Constructor for our LocalizationManager using the locale set in the {@link - * ApplicationProperties}-instance passed to this constructor. If initialization with the provided - * {@link ApplicationProperties}-instance fails, the LocalizationManager is initialized with the - * default locale <code>en_us</code>. + * Constructor for our I18n using the locale set in the {@link ApplicationProperties}-instance + * passed to this constructor. If initialization with the provided {@link + * ApplicationProperties}-instance fails, the I18n is initialized with the default locale <code> + * en_us</code>. * * @param injectedApplicationProperties Instance of {@link ApplicationProperties} required for * various different things. * @author Griefed */ @Autowired - public LocalizationManager(ApplicationProperties injectedApplicationProperties) { + public I18n(ApplicationProperties injectedApplicationProperties) { if (injectedApplicationProperties == null) { this.APPLICATIONPROPERTIES = new ApplicationProperties(); } else { @@ -109,9 +109,9 @@ public class LocalizationManager { } /** - * Constructor for our LocalizationManager with a given locale. If initialization with the - * provided locale fails, the LocalizationManager is initialized with the locale set in the - * instance of {@link ApplicationProperties}. If this also fails, the default locale <code>en_us + * Constructor for our I18n with a given locale. If initialization with the provided locale fails, + * the I18n is initialized with the locale set in the instance of {@link ApplicationProperties}. + * If this also fails, the default locale <code>en_us * </code> is used. * * @param injectedApplicationProperties Instance of {@link ApplicationProperties} required for @@ -119,7 +119,7 @@ public class LocalizationManager { * @param locale String. The locale to initialize with. * @author Griefed */ - public LocalizationManager(ApplicationProperties injectedApplicationProperties, String locale) { + public I18n(ApplicationProperties injectedApplicationProperties, String locale) { if (injectedApplicationProperties == null) { this.APPLICATIONPROPERTIES = new ApplicationProperties(); } else { @@ -140,18 +140,18 @@ public class LocalizationManager { } /** - * Constructor for our LocalizationManager using the default locale en_us. + * Constructor for our I18n using the default locale en_us. * * @author Griefed */ - public LocalizationManager() { + public I18n() { this.APPLICATIONPROPERTIES = new ApplicationProperties(); initialize(); } /** - * Initialize the LocalizationManager with en_us as the locale. + * Initialize the I18n with en_us as the locale. * * @author whitebear60 */ @@ -164,7 +164,7 @@ public class LocalizationManager { } /** - * Initializes the LocalizationManager with a provided localePropertiesFile. + * Initializes the I18n with a provided localePropertiesFile. * * @param propertiesFile Path to the locale properties file which specifies the language to use. * @throws IncorrectLanguageException Thrown if the language specified in the properties file is @@ -192,7 +192,7 @@ public class LocalizationManager { } /** - * Initializes the LocalizationManager with a provided localePropertiesFile. + * Initializes the I18n with a provided localePropertiesFile. * * @param applicationProperties Instance of {@link ApplicationProperties} containing the locale to * use. @@ -207,7 +207,7 @@ public class LocalizationManager { } /** - * Initializes the LocalizationManager with a provided locale. + * Initializes the I18n with a provided locale. * * @param locale Locale to be used by application in this run. * @throws IncorrectLanguageException Thrown if the language specified in the properties file is @@ -270,8 +270,8 @@ public class LocalizationManager { ResourceBundle.getBundle( String.format("de/griefed/resources/lang/lang_%s", locale), new Locale( - CURRENT_LANGUAGE.get(MAP_PATH_LANGUAGE), - CURRENT_LANGUAGE.get(MAP_PATH_COUNTRY)), + CURRENT_LANGUAGE.get(MAP_PATH_LANGUAGE).toLowerCase(), + CURRENT_LANGUAGE.get(MAP_PATH_COUNTRY).toUpperCase()), new UTF8Control()); } catch (Exception ex2) { @@ -296,8 +296,8 @@ public class LocalizationManager { ResourceBundle.getBundle( String.format("de/griefed/resources/lang/lang_%s", locale), new Locale( - CURRENT_LANGUAGE.get(MAP_PATH_LANGUAGE), - CURRENT_LANGUAGE.get(MAP_PATH_COUNTRY)), + CURRENT_LANGUAGE.get(MAP_PATH_LANGUAGE).toLowerCase(), + CURRENT_LANGUAGE.get(MAP_PATH_COUNTRY).toUpperCase()), new UTF8Control()); } catch (Exception ex) { @@ -307,9 +307,10 @@ public class LocalizationManager { } } - // Uncomment if you want to work on encodings.... - // Nightmare fuel... - // LOG.debug(getLocalizedString("encoding.check")); + if (APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION().equals("dev")) { + LOG.info(getMessage("encoding.check")); + System.out.println(getMessage("encoding.check")); + } } /** @@ -322,7 +323,7 @@ public class LocalizationManager { * @author whitebear60 * @author Griefed */ - public String getLocalizedString(String languageKey) { + public String getMessage(String languageKey) { //noinspection UnusedAssignment String text = null; @@ -392,8 +393,8 @@ public class LocalizationManager { /** * Writes the specified locale from -lang your_locale to a lang.properties file to ensure every * subsequent start of serverpackcreator is executed using said locale. This method should - * <strong>not</strong> call {@link #getLocalizedString(String)}, as the initialization of said - * manager is called from here. Therefore, localized strings are not yet available. + * <strong>not</strong> call {@link #getMessage(String)}, as the initialization of said manager is + * called from here. Therefore, localized strings are not yet available. * * @param locale The locale the user specified when they ran serverpackcreator with -lang * -your_locale. diff --git a/backend/main/java/de/griefed/serverpackcreator/i18n/IncorrectLanguageException.java b/backend/main/java/de/griefed/serverpackcreator/i18n/IncorrectLanguageException.java index 33ff1479e695744bd5b1b17924e691f8f9df2d10..f9ca032a338205f105f270c48dd2b61073fe12c8 100644 --- a/backend/main/java/de/griefed/serverpackcreator/i18n/IncorrectLanguageException.java +++ b/backend/main/java/de/griefed/serverpackcreator/i18n/IncorrectLanguageException.java @@ -26,7 +26,7 @@ package de.griefed.serverpackcreator.i18n; * {@link #IncorrectLanguageException(Throwable)}<br> * {@link #IncorrectLanguageException(String, Throwable)} * - * <p>Provides exceptions to {@link LocalizationManager} + * <p>Provides exceptions to {@link I18n} * * @author whitebear60 */ diff --git a/backend/main/java/de/griefed/serverpackcreator/plugins/ApplicationPlugins.java b/backend/main/java/de/griefed/serverpackcreator/plugins/ApplicationPlugins.java index 8ff80f815a17b5f5c4ca17eddd12498e16b490cf..53cacd868379a47e7136e3fbfcea8dce6f314f05 100644 --- a/backend/main/java/de/griefed/serverpackcreator/plugins/ApplicationPlugins.java +++ b/backend/main/java/de/griefed/serverpackcreator/plugins/ApplicationPlugins.java @@ -27,9 +27,7 @@ import java.io.File; import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.pf4j.ExtensionFactory; import org.pf4j.JarPluginManager; -import org.pf4j.SingletonExtensionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -74,11 +72,6 @@ public class ApplicationPlugins extends JarPluginManager { availablePluginsAndExtensions(); } - @Override - protected ExtensionFactory createExtensionFactory() { - return new SingletonExtensionFactory(); - } - /** * Print information about available plugins to our logs. * diff --git a/backend/main/java/de/griefed/serverpackcreator/spring/BeanConfiguration.java b/backend/main/java/de/griefed/serverpackcreator/spring/BeanConfiguration.java index 9d6107fe997df3bfaa0fc2ae847bea234e3688c2..949adc3138f5327e99661e9698a3877b1132f858 100644 --- a/backend/main/java/de/griefed/serverpackcreator/spring/BeanConfiguration.java +++ b/backend/main/java/de/griefed/serverpackcreator/spring/BeanConfiguration.java @@ -110,7 +110,8 @@ public class BeanConfiguration { /** * Bean for starting up our Spring Boot Application, serving as our...<br> * <code>starts chanting</code><br> - * <strong>public-static-void-main-string-args-public-static-void-main-string-args-public-static-void-main-string-args</strong><br> + * <strong>public-static-void-main-string-args-public-static-void-main-string-args-public-static-void-main-string-args</strong> + * <br> * <br> * ehem...<br> * Sorry 'bout that. diff --git a/backend/main/java/de/griefed/serverpackcreator/spring/NotificationResponse.java b/backend/main/java/de/griefed/serverpackcreator/spring/NotificationResponse.java index 140b28568aeefc9999676fa39bd0e05ba60efc65..fd72ac604ad943a1afc6c4304f5352ba01288e66 100644 --- a/backend/main/java/de/griefed/serverpackcreator/spring/NotificationResponse.java +++ b/backend/main/java/de/griefed/serverpackcreator/spring/NotificationResponse.java @@ -32,8 +32,6 @@ import org.springframework.stereotype.Component; @Component public class NotificationResponse { - private static final Logger LOG = LogManager.getLogger(NotificationResponse.class); - /** * Construct a zipResponse for replying to a file-upload and display in a quasar notification. * diff --git a/backend/main/java/de/griefed/serverpackcreator/spring/serverpack/ServerPackController.java b/backend/main/java/de/griefed/serverpackcreator/spring/serverpack/ServerPackController.java index 1e75500a7fcfd433b20f6d3ccd89b478b5fffd32..a08ac284d918cf9bd52e819e7142b1b623fdb9e6 100644 --- a/backend/main/java/de/griefed/serverpackcreator/spring/serverpack/ServerPackController.java +++ b/backend/main/java/de/griefed/serverpackcreator/spring/serverpack/ServerPackController.java @@ -42,8 +42,6 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/api/v1/packs") public class ServerPackController { - private static final Logger LOG = LogManager.getLogger(ServerPackController.class); - private final ServerPackService SERVERPACKSERVICE; /** @@ -99,7 +97,6 @@ public class ServerPackController { * @author Griefed */ @GetMapping("vote/{voting}") - // TODO: Secure with Captcha so vote spamming is somewhat prevented public ResponseEntity<Object> voteForServerPack(@PathVariable("voting") String voting) { return SERVERPACKSERVICE.voteForServerPack(voting); } diff --git a/backend/main/java/de/griefed/serverpackcreator/spring/task/TaskSubmitter.java b/backend/main/java/de/griefed/serverpackcreator/spring/task/TaskSubmitter.java index 9819d1e50a1a632b6d8d95e8cf5448db5bdcb141..3e1f11023b562fa62d571207f456f6d70ab7dc6c 100644 --- a/backend/main/java/de/griefed/serverpackcreator/spring/task/TaskSubmitter.java +++ b/backend/main/java/de/griefed/serverpackcreator/spring/task/TaskSubmitter.java @@ -19,7 +19,6 @@ */ package de.griefed.serverpackcreator.spring.task; -import de.griefed.serverpackcreator.ApplicationProperties; import de.griefed.serverpackcreator.spring.zip.GenerateZip; import de.griefed.serverpackcreator.spring.zip.ZipController; import org.apache.logging.log4j.LogManager; @@ -45,18 +44,17 @@ public class TaskSubmitter { private static final Logger LOG = LogManager.getLogger(TaskSubmitter.class); - private JmsTemplate jmsTemplate; + private final JmsTemplate jmsTemplate; /** * Constructor responsible for our DI. * * @param injectedJmsTemplate Instance of {@link JmsTemplate}. - * @param injectedApplicationProperties Instance of {@link ApplicationProperties}. * @author Griefed */ @Autowired public TaskSubmitter( - JmsTemplate injectedJmsTemplate, ApplicationProperties injectedApplicationProperties) { + JmsTemplate injectedJmsTemplate) { this.jmsTemplate = injectedJmsTemplate; } diff --git a/backend/main/java/de/griefed/serverpackcreator/spring/zip/ZipController.java b/backend/main/java/de/griefed/serverpackcreator/spring/zip/ZipController.java index bb676daea1b023260238f9993ab011d27d835109..29c404f174f7f602708eb3b8ca48e42389ab25ab 100644 --- a/backend/main/java/de/griefed/serverpackcreator/spring/zip/ZipController.java +++ b/backend/main/java/de/griefed/serverpackcreator/spring/zip/ZipController.java @@ -55,8 +55,6 @@ import org.springframework.web.multipart.MultipartFile; @RequestMapping("/api/v1/zip") public class ZipController { - private static final Logger LOG = LogManager.getLogger(ZipController.class); - private final ZipService ZIPSERVICE; private final ConfigurationHandler CONFIGURATIONHANDLER; private final NotificationResponse NOTIFICATIONRESPONSE; @@ -160,9 +158,7 @@ public class ZipController { @PathVariable("modLoaderVersion") String modLoaderVersion) { if (clientMods.length() == 0) { - clientMods = - UTILITIES.StringUtils() - .buildString(APPLICATIONPROPERTIES.getListFallbackMods()); + clientMods = UTILITIES.StringUtils().buildString(APPLICATIONPROPERTIES.getListFallbackMods()); } return ResponseEntity.ok() diff --git a/backend/main/java/de/griefed/serverpackcreator/spring/zip/ZipService.java b/backend/main/java/de/griefed/serverpackcreator/spring/zip/ZipService.java index 977f9230b5de99acf2cd450090e6f15f2539d380..cec437912cbaea73e2fcb18f382391b793c60ff5 100644 --- a/backend/main/java/de/griefed/serverpackcreator/spring/zip/ZipService.java +++ b/backend/main/java/de/griefed/serverpackcreator/spring/zip/ZipService.java @@ -23,7 +23,6 @@ import de.griefed.serverpackcreator.ConfigurationHandler; import de.griefed.serverpackcreator.spring.NotificationResponse; import de.griefed.serverpackcreator.spring.task.TaskSubmitter; import de.griefed.serverpackcreator.utilities.ConfigUtilities; -import de.griefed.serverpackcreator.utilities.common.Utilities; import de.griefed.serverpackcreator.versionmeta.VersionMeta; import java.io.File; import java.io.IOException; @@ -49,7 +48,6 @@ public class ZipService { private final TaskSubmitter TASKSUBMITTER; private final ConfigurationHandler CONFIGURATIONHANDLER; - private final Utilities UTILITIES; private final NotificationResponse NOTIFICATIONRESPONSE; private final VersionMeta VERSIONMETA; private final ConfigUtilities CONFIGUTILITIES; @@ -59,7 +57,6 @@ public class ZipService { * * @param injectedTaskSubmitter Instance of {@link TaskSubmitter}. * @param injectedConfigurationHandler Instance of {@link ConfigurationHandler}. - * @param injectedUtilities Instance of {@link Utilities}. * @param injectedNotificationResponse Instance of {@link NotificationResponse}. * @param injectedVersionMeta Instance of {@link VersionMeta}. * @param injectedConfigUtilities Instance of {@link ConfigUtilities}. @@ -69,14 +66,12 @@ public class ZipService { public ZipService( TaskSubmitter injectedTaskSubmitter, ConfigurationHandler injectedConfigurationHandler, - Utilities injectedUtilities, NotificationResponse injectedNotificationResponse, VersionMeta injectedVersionMeta, ConfigUtilities injectedConfigUtilities) { this.TASKSUBMITTER = injectedTaskSubmitter; this.CONFIGURATIONHANDLER = injectedConfigurationHandler; - this.UTILITIES = injectedUtilities; this.NOTIFICATIONRESPONSE = injectedNotificationResponse; this.VERSIONMETA = injectedVersionMeta; this.CONFIGUTILITIES = injectedConfigUtilities; diff --git a/backend/main/java/de/griefed/serverpackcreator/swing/MainMenuBar.java b/backend/main/java/de/griefed/serverpackcreator/swing/MainMenuBar.java index 81167e76a921b1ae961f46a2004726641d347cd8..09762022f3cdb57eb8c8071a94dc3c1a3248b521 100644 --- a/backend/main/java/de/griefed/serverpackcreator/swing/MainMenuBar.java +++ b/backend/main/java/de/griefed/serverpackcreator/swing/MainMenuBar.java @@ -20,7 +20,7 @@ package de.griefed.serverpackcreator.swing; import de.griefed.serverpackcreator.ApplicationProperties; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.swing.themes.DarkTheme; import de.griefed.serverpackcreator.swing.themes.LightTheme; import de.griefed.serverpackcreator.utilities.UpdateChecker; @@ -85,7 +85,7 @@ public class MainMenuBar extends Component { private final Clipboard CLIPBOARD = Toolkit.getDefaultToolkit().getSystemClipboard(); - private final LocalizationManager LOCALIZATIONMANAGER; + private final I18n I18N; private final ApplicationProperties APPLICATIONPROPERTIES; private final UpdateChecker UPDATECHECKER; private final de.griefed.serverpackcreator.utilities.common.Utilities UTILITIES; @@ -143,8 +143,7 @@ public class MainMenuBar extends Component { /** * Constructor for our MainMenuBar. Prepares various Strings, Arrays, Panels and windows. * - * @param injectedLocalizationManager Instance of {@link LocalizationManager} required for - * localized log messages. + * @param injectedI18n Instance of {@link I18n} required for localized log messages. * @param injectedLightTheme Instance of {@link LightTheme} required for theme switching. * @param injectedDarkTheme Instance of {@link DarkTheme} required for theme switching. * @param injectedJFrame The parent from in which everything ServerPackCreator is displayed in. @@ -160,7 +159,7 @@ public class MainMenuBar extends Component { * @author Griefed */ public MainMenuBar( - LocalizationManager injectedLocalizationManager, + I18n injectedI18n, LightTheme injectedLightTheme, DarkTheme injectedDarkTheme, JFrame injectedJFrame, @@ -178,10 +177,10 @@ public class MainMenuBar extends Component { this.APPLICATIONPROPERTIES = injectedApplicationProperties; } - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + if (injectedI18n == null) { + this.I18N = new I18n(APPLICATIONPROPERTIES); } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; + this.I18N = injectedI18n; } if (injectedUpdateChecker == null) { @@ -192,8 +191,7 @@ public class MainMenuBar extends Component { if (injectedUtilities == null) { this.UTILITIES = - new de.griefed.serverpackcreator.utilities.common.Utilities( - LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + new de.griefed.serverpackcreator.utilities.common.Utilities(I18N, APPLICATIONPROPERTIES); } else { this.UTILITIES = injectedUtilities; } @@ -218,8 +216,7 @@ public class MainMenuBar extends Component { CLOSEEVENT = new WindowEvent(FRAME_SERVERPACKCREATOR, WindowEvent.WINDOW_CLOSING); - String ABOUTWINDOWTEXT = - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.about.text"); + String ABOUTWINDOWTEXT = I18N.getMessage("createserverpack.gui.about.text"); ABOUT_WINDOW_TEXTPANE.setEditable(false); ABOUT_WINDOW_TEXTPANE.setOpaque(false); ABOUT_WINDOW_TEXTPANE.setMinimumSize(ABOUTDIMENSION); @@ -247,13 +244,9 @@ public class MainMenuBar extends Component { } }); - HASTEOPTIONS[0] = - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.about.hastebin.dialog.yes"); - HASTEOPTIONS[1] = - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.about.hastebin.dialog.clipboard"); - HASTEOPTIONS[2] = - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.about.hastebin.dialog.no"); + HASTEOPTIONS[0] = I18N.getMessage("createserverpack.gui.about.hastebin.dialog.yes"); + HASTEOPTIONS[1] = I18N.getMessage("createserverpack.gui.about.hastebin.dialog.clipboard"); + HASTEOPTIONS[2] = I18N.getMessage("createserverpack.gui.about.hastebin.dialog.no"); CONFIG_WINDOW_TEXTPANE.setOpaque(false); CONFIG_WINDOW_TEXTPANE.setEditable(false); @@ -304,75 +297,66 @@ public class MainMenuBar extends Component { public JMenuBar createMenuBar() { // create menus - JMenu fileMenu = new JMenu(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menu.file")); - JMenu editMenu = new JMenu(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menu.edit")); - JMenu viewMenu = new JMenu(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menu.view")); - JMenu aboutMenu = new JMenu(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menu.about")); + JMenu fileMenu = new JMenu(I18N.getMessage("menubar.gui.menu.file")); + JMenu editMenu = new JMenu(I18N.getMessage("menubar.gui.menu.edit")); + JMenu viewMenu = new JMenu(I18N.getMessage("menubar.gui.menu.view")); + JMenu aboutMenu = new JMenu(I18N.getMessage("menubar.gui.menu.about")); // create menu items JMenuItem file_NewConfigurationMenuItem = new JMenuItem("New configuration"); JMenuItem file_LoadConfigMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.loadconfig")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.loadconfig")); JMenuItem file_SaveConfigMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.saveconfig")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.saveconfig")); JMenuItem file_SaveAsConfigMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.saveas")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.saveas")); JMenuItem file_UploadConfigurationToHasteBin = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.uploadconfig")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.uploadconfig")); JMenuItem file_UploadServerPackCreatorLogToHasteBin = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.uploadlog")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.uploadlog")); JMenuItem file_UpdateFallbackModslist = - new JMenuItem( - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.updatefallback")); - JMenuItem file_ExitConfigMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.exit")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.updatefallback")); + JMenuItem file_ExitConfigMenuItem = new JMenuItem(I18N.getMessage("menubar.gui.menuitem.exit")); - JMenuItem edit_SwitchTheme = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.theme")); + JMenuItem edit_SwitchTheme = new JMenuItem(I18N.getMessage("menubar.gui.menuitem.theme")); JMenuItem edit_OpenInEditorServerProperties = - new JMenuItem( - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.serverproperties")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.serverproperties")); JMenuItem edit_OpenInEditorServerIcon = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.servericon")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.servericon")); JMenuItem view_OpenAddonsDirectoryMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.addonsdir")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.addonsdir")); JMenuItem view_ExampleAddonRepositoryMenuItem = - new JMenuItem( - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.exampleaddonrepo")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.exampleaddonrepo")); JMenuItem view_OpenServerPackCreatorDirectoryMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.spcdir")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.spcdir")); JMenuItem view_OpenServerPacksDirectoryMenuItem = - new JMenuItem( - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.serverpacksdir")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.serverpacksdir")); JMenuItem view_OpenServerFilesDirectoryMenuItem = - new JMenuItem( - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.serverfilesdir")); - JMenuItem view_OpenSPCLog = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.spclog")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.serverfilesdir")); + JMenuItem view_OpenSPCLog = new JMenuItem(I18N.getMessage("menubar.gui.menuitem.spclog")); JMenuItem view_OpenModloaderInstallerLog = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.modloaderlog")); - JMenuItem view_OpenAddonLog = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.addonlog")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.modloaderlog")); + JMenuItem view_OpenAddonLog = new JMenuItem(I18N.getMessage("menubar.gui.menuitem.addonlog")); JMenuItem about_OpenAboutWindowMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.about")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.about")); JMenuItem about_OpenGitHubPageMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.repository")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.repository")); JMenuItem about_OpenGitHubIssuesPageMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.issues")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.issues")); JMenuItem about_OpenReleasesPageMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.releases")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.releases")); JMenuItem about_OpenDiscordLinkMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.discord")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.discord")); JMenuItem about_OpenDonationsPageMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.donate")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.donate")); JMenuItem about_OpenWikiHelpMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.wiki.help")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.wiki.help")); JMenuItem about_OpenWikiHowToMenuItem = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.wiki.howto")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.wiki.howto")); JMenuItem about_CheckForUpdates = - new JMenuItem(LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.updates")); + new JMenuItem(I18N.getMessage("menubar.gui.menuitem.updates")); // create action listeners for items file_NewConfigurationMenuItem.addActionListener(this::newConfiguration); @@ -486,8 +470,8 @@ public class MainMenuBar extends Component { if (!displayUpdateDialog()) { JOptionPane.showMessageDialog( FRAME_SERVERPACKCREATOR, - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.updates.none"), - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.updates.none.title"), + I18N.getMessage("menubar.gui.menuitem.updates.none"), + I18N.getMessage("menubar.gui.menuitem.updates.none.title"), JOptionPane.INFORMATION_MESSAGE, UIManager.getIcon("OptionPane.informationIcon")); } @@ -507,9 +491,7 @@ public class MainMenuBar extends Component { APPLICATIONPROPERTIES.checkForAvailablePreReleases()); if (update.isPresent()) { - String textContent = - String.format( - LOCALIZATIONMANAGER.getLocalizedString("update.dialog.new"), update.get().url()); + String textContent = String.format(I18N.getMessage("update.dialog.new"), update.get().url()); StyledDocument styledDocument = new DefaultStyledDocument(); SimpleAttributeSet simpleAttributeSet = new SimpleAttributeSet(); @@ -536,9 +518,9 @@ public class MainMenuBar extends Component { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); String[] options = new String[3]; - options[0] = LOCALIZATIONMANAGER.getLocalizedString("update.dialog.yes"); - options[1] = LOCALIZATIONMANAGER.getLocalizedString("update.dialog.no"); - options[2] = LOCALIZATIONMANAGER.getLocalizedString("update.dialog.clipboard"); + options[0] = I18N.getMessage("update.dialog.yes"); + options[1] = I18N.getMessage("update.dialog.no"); + options[2] = I18N.getMessage("update.dialog.clipboard"); try { styledDocument.insertString(0, textContent, simpleAttributeSet); @@ -551,7 +533,7 @@ public class MainMenuBar extends Component { switch (JOptionPane.showOptionDialog( FRAME_SERVERPACKCREATOR, jTextPane, - LOCALIZATIONMANAGER.getLocalizedString("update.dialog.available"), + I18N.getMessage("update.dialog.available"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, UIManager.getIcon("OptionPane.informationIcon"), @@ -589,15 +571,15 @@ public class MainMenuBar extends Component { if (APPLICATIONPROPERTIES.updateFallback()) { JOptionPane.showMessageDialog( FRAME_SERVERPACKCREATOR, - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.updatefallback.updated"), - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.updatefallback.title"), + I18N.getMessage("menubar.gui.menuitem.updatefallback.updated"), + I18N.getMessage("menubar.gui.menuitem.updatefallback.title"), JOptionPane.INFORMATION_MESSAGE, UIManager.getIcon("OptionPane.informationIcon")); } else { JOptionPane.showMessageDialog( FRAME_SERVERPACKCREATOR, - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.updatefallback.nochange"), - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.menuitem.updatefallback.title"), + I18N.getMessage("menubar.gui.menuitem.updatefallback.nochange"), + I18N.getMessage("menubar.gui.menuitem.updatefallback.title"), JOptionPane.INFORMATION_MESSAGE, UIManager.getIcon("OptionPane.informationIcon")); } @@ -744,7 +726,7 @@ public class MainMenuBar extends Component { switch (JOptionPane.showOptionDialog( FRAME_SERVERPACKCREATOR, displayTextPane, - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.about.hastebin.dialog"), + I18N.getMessage("createserverpack.gui.about.hastebin.dialog"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, ICON_HASTEBIN, @@ -773,8 +755,8 @@ public class MainMenuBar extends Component { MATERIALTEXTPANEUI.installUI(FILETOOLARGE_WINDOW_TEXTPANE); JOptionPane.showConfirmDialog( FRAME_SERVERPACKCREATOR, - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.filetoolarge"), - LOCALIZATIONMANAGER.getLocalizedString("menubar.gui.filetoolargetitle"), + I18N.getMessage("menubar.gui.filetoolarge"), + I18N.getMessage("menubar.gui.filetoolargetitle"), JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, ICON_HASTEBIN); @@ -841,8 +823,7 @@ public class MainMenuBar extends Component { configChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); configChooser.setFileFilter( new FileNameExtensionFilter( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonloadconfig.filter"), - "conf")); + I18N.getMessage("createserverpack.gui.buttonloadconfig.filter"), "conf")); configChooser.setAcceptAllFileFilterUsed(false); configChooser.setMultiSelectionEnabled(false); configChooser.setPreferredSize(CHOOSERDIMENSION); @@ -869,10 +850,7 @@ public class MainMenuBar extends Component { } } catch (IOException ex) { - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.error.buttonloadconfigfromfile"), - ex); + LOG.error("Error loading configuration from selected file.", ex); } } } @@ -970,13 +948,11 @@ public class MainMenuBar extends Component { configChooser = new JFileChooser(); configChooser.setCurrentDirectory(new File(".")); - configChooser.setDialogTitle( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonloadconfig.title")); + configChooser.setDialogTitle(I18N.getMessage("createserverpack.gui.buttonloadconfig.title")); configChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); configChooser.setFileFilter( new FileNameExtensionFilter( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonloadconfig.filter"), - "conf")); + I18N.getMessage("createserverpack.gui.buttonloadconfig.filter"), "conf")); configChooser.setAcceptAllFileFilterUsed(false); configChooser.setMultiSelectionEnabled(false); configChooser.setPreferredSize(CHOOSERDIMENSION); @@ -986,11 +962,7 @@ public class MainMenuBar extends Component { try { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttonloadconfigfromfile"), - configChooser.getSelectedFile().getCanonicalPath())); + LOG.info("Loading from configuration file: " + configChooser.getSelectedFile().getCanonicalPath()); File specifiedConfigFile; try { @@ -1095,7 +1067,7 @@ public class MainMenuBar extends Component { JOptionPane.showMessageDialog( FRAME_SERVERPACKCREATOR, ABOUTWINDOWSCROLLPANE, - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.createserverpack.about.title"), + I18N.getMessage("createserverpack.gui.createserverpack.about.title"), JOptionPane.INFORMATION_MESSAGE, HELPICON); } diff --git a/backend/main/java/de/griefed/serverpackcreator/swing/ServerPackCreatorGui.java b/backend/main/java/de/griefed/serverpackcreator/swing/ServerPackCreatorGui.java index 22c505ff10f828bb747bef1fcd1a5c14e35d04da..6b7e87eb34f826b3ee64cef1b8514c896ca9a085 100644 --- a/backend/main/java/de/griefed/serverpackcreator/swing/ServerPackCreatorGui.java +++ b/backend/main/java/de/griefed/serverpackcreator/swing/ServerPackCreatorGui.java @@ -22,7 +22,7 @@ package de.griefed.serverpackcreator.swing; import de.griefed.serverpackcreator.ApplicationProperties; import de.griefed.serverpackcreator.ConfigurationHandler; import de.griefed.serverpackcreator.ServerPackHandler; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.plugins.ApplicationPlugins; import de.griefed.serverpackcreator.swing.themes.DarkTheme; import de.griefed.serverpackcreator.swing.themes.LightTheme; @@ -101,8 +101,8 @@ public class ServerPackCreatorGui { * * <p>Used for Dependency Injection. * - * <p>Receives an instance of {@link LocalizationManager} or creates one if the received one is - * null. Required for use of localization. + * <p>Receives an instance of {@link I18n} or creates one if the received one is null. Required + * for use of localization. * * <p>Receives an instance of {@link ConfigurationHandler} required to successfully and correctly * create the server pack. @@ -110,8 +110,7 @@ public class ServerPackCreatorGui { * <p>Receives an instance of {@link ServerPackHandler} which is required to generate a server * pack. * - * @param injectedLocalizationManager Instance of {@link LocalizationManager} required for - * localized log messages. + * @param injectedI18n Instance of {@link I18n} required for localized log messages. * @param injectedConfigurationHandler Instance of {@link ConfigurationHandler} required to * successfully and correctly create the server pack. * @param injectedServerPackHandler Instance of {@link ServerPackHandler} required for the @@ -129,7 +128,7 @@ public class ServerPackCreatorGui { * @author Griefed */ public ServerPackCreatorGui( - LocalizationManager injectedLocalizationManager, + I18n injectedI18n, ConfigurationHandler injectedConfigurationHandler, ServerPackHandler injectedServerPackHandler, ApplicationProperties injectedApplicationProperties, @@ -149,11 +148,11 @@ public class ServerPackCreatorGui { } else { this.APPLICATIONPROPERTIES = injectedApplicationProperties; } - LocalizationManager LOCALIZATIONMANAGER; - if (injectedLocalizationManager == null) { - LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + I18n I18N; + if (injectedI18n == null) { + I18N = new I18n(APPLICATIONPROPERTIES); } else { - LOCALIZATIONMANAGER = injectedLocalizationManager; + I18N = injectedI18n; } VersionMeta VERSIONMETA; @@ -172,15 +171,14 @@ public class ServerPackCreatorGui { Utilities UTILITIES; if (injectedUtilities == null) { - UTILITIES = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + UTILITIES = new Utilities(I18N, APPLICATIONPROPERTIES); } else { UTILITIES = injectedUtilities; } ConfigUtilities CONFIGUTILITIES; if (injectedConfigUtilities == null) { - CONFIGUTILITIES = - new ConfigUtilities(LOCALIZATIONMANAGER, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); + CONFIGUTILITIES = new ConfigUtilities(I18N, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); } else { CONFIGUTILITIES = injectedConfigUtilities; } @@ -189,7 +187,7 @@ public class ServerPackCreatorGui { if (injectedConfigurationHandler == null) { CONFIGURATIONHANDLER = new ConfigurationHandler( - LOCALIZATIONMANAGER, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); + I18N, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); } else { CONFIGURATIONHANDLER = injectedConfigurationHandler; } @@ -205,11 +203,7 @@ public class ServerPackCreatorGui { if (injectedServerPackHandler == null) { CREATESERVERPACK = new ServerPackHandler( - LOCALIZATIONMANAGER, - APPLICATIONPROPERTIES, - VERSIONMETA, - UTILITIES, - APPLICATIONPLUGINS); + I18N, APPLICATIONPROPERTIES, VERSIONMETA, UTILITIES, APPLICATIONPLUGINS); } else { CREATESERVERPACK = injectedServerPackHandler; } @@ -234,13 +228,13 @@ public class ServerPackCreatorGui { this.FRAME_SERVERPACKCREATOR = new JFrame( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.createandshowgui") + I18N.getMessage("createserverpack.gui.createandshowgui") + " - " + APPLICATIONPROPERTIES.SERVERPACKCREATOR_VERSION()); this.TAB_CREATESERVERPACK = new TabCreateServerPack( - LOCALIZATIONMANAGER, + I18N, CONFIGURATIONHANDLER, CREATESERVERPACK, VERSIONMETA, @@ -254,39 +248,30 @@ public class ServerPackCreatorGui { TabServerPackCreatorLog TAB_LOG_SERVERPACKCREATOR = new TabServerPackCreatorLog( - LOCALIZATIONMANAGER, - APPLICATIONPROPERTIES, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.tabbedpane.serverpackcreatorlog.tooltip")); + I18N.getMessage("createserverpack.gui.tabbedpane.serverpackcreatorlog.tooltip")); TabAddonsHandlerLog TAB_LOG_ADDONSHANDLER = new TabAddonsHandlerLog( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.tabbedpane.addonshandlerlog.tip")); + I18N.getMessage("createserverpack.gui.tabbedpane.addonshandlerlog.tip")); this.BACKGROUNDPANEL = new BackgroundPanel(bufferedImage, BackgroundPanel.TILED, 0.0f, 0.0f); this.TABBEDPANE = new JTabbedPane(JTabbedPane.TOP); TABBEDPANE.addTab( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.tabbedpane.createserverpack.title"), + I18N.getMessage("createserverpack.gui.tabbedpane.createserverpack.title"), null, TAB_CREATESERVERPACK, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.tabbedpane.createserverpack.tip")); + I18N.getMessage("createserverpack.gui.tabbedpane.createserverpack.tip")); TABBEDPANE.addTab( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.tabbedpane.serverpackcreatorlog.title"), + I18N.getMessage("createserverpack.gui.tabbedpane.serverpackcreatorlog.title"), null, TAB_LOG_SERVERPACKCREATOR, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.tabbedpane.serverpackcreatorlog.tip")); + I18N.getMessage("createserverpack.gui.tabbedpane.serverpackcreatorlog.tip")); TABBEDPANE.addTab( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.tabbedpane.addonshandlerlog.title"), + I18N.getMessage("createserverpack.gui.tabbedpane.addonshandlerlog.title"), null, TAB_LOG_ADDONSHANDLER); @@ -312,7 +297,7 @@ public class ServerPackCreatorGui { MENUBAR = new MainMenuBar( - LOCALIZATIONMANAGER, + I18N, LIGHTTHEME, DARKTHEME, FRAME_SERVERPACKCREATOR, diff --git a/backend/main/java/de/griefed/serverpackcreator/swing/TabAddonsHandlerLog.java b/backend/main/java/de/griefed/serverpackcreator/swing/TabAddonsHandlerLog.java index 02c8e1b14c559475b83d7869b714fcbf693da653..d4ee32f4cc3fffc0efe4ea8c0bdc0364e29f7787 100644 --- a/backend/main/java/de/griefed/serverpackcreator/swing/TabAddonsHandlerLog.java +++ b/backend/main/java/de/griefed/serverpackcreator/swing/TabAddonsHandlerLog.java @@ -19,7 +19,7 @@ */ package de.griefed.serverpackcreator.swing; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.swing.utilities.JComponentTailer; import de.griefed.serverpackcreator.utilities.misc.Generated; import java.io.File; @@ -40,8 +40,8 @@ public class TabAddonsHandlerLog extends JComponentTailer { * * <p>Used for Dependency Injection. * - * <p>Receives an instance of {@link LocalizationManager} or creates one if the received one is - * null. Required for use of localization. + * <p>Receives an instance of {@link I18n} or creates one if the received one is null. Required + * for use of localization. * * @param tooltip {@link String} The tooltip text for this tailer. * @author Griefed diff --git a/backend/main/java/de/griefed/serverpackcreator/swing/TabCreateServerPack.java b/backend/main/java/de/griefed/serverpackcreator/swing/TabCreateServerPack.java index ed8e5513d830233fd00b916836542a94e092cc7e..fe51b7bd610cbf2d9c86616797f3ff7a479e0bff 100644 --- a/backend/main/java/de/griefed/serverpackcreator/swing/TabCreateServerPack.java +++ b/backend/main/java/de/griefed/serverpackcreator/swing/TabCreateServerPack.java @@ -25,7 +25,7 @@ import de.griefed.serverpackcreator.ApplicationProperties; import de.griefed.serverpackcreator.ConfigurationHandler; import de.griefed.serverpackcreator.ConfigurationModel; import de.griefed.serverpackcreator.ServerPackHandler; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.plugins.ApplicationPlugins; import de.griefed.serverpackcreator.swing.themes.DarkTheme; import de.griefed.serverpackcreator.swing.themes.LightTheme; @@ -57,6 +57,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Objects; import java.util.Properties; @@ -118,8 +119,8 @@ public class TabCreateServerPack extends JPanel { private final JFrame FRAME_SERVERPACKCREATOR; private final ConfigurationHandler CONFIGURATIONHANDLER; - private final LocalizationManager LOCALIZATIONMANAGER; - private final ServerPackHandler CREATESERVERPACK; + private final I18n I18N; + private final ServerPackHandler SERVERPACKHANDLER; private final VersionMeta VERSIONMETA; private final Utilities UTILITIES; private final ApplicationProperties APPLICATIONPROPERTIES; @@ -264,8 +265,8 @@ public class TabCreateServerPack extends JPanel { * * <p>Used for Dependency Injection. * - * <p>Receives an instance of {@link LocalizationManager} or creates one if the received one is - * null. Required for use of localization. + * <p>Receives an instance of {@link I18n} or creates one if the received one is null. Required + * for use of localization. * * <p>Receives an instance of {@link ConfigurationHandler} required to successfully and correctly * create the server pack. @@ -273,8 +274,7 @@ public class TabCreateServerPack extends JPanel { * <p>Receives an instance of {@link ServerPackHandler} which is required to generate a server * pack. * - * @param injectedLocalizationManager Instance of {@link LocalizationManager} required for - * localized log messages. + * @param injectedI18n Instance of {@link I18n} required for localized log messages. * @param injectedConfigurationHandler Instance of {@link ConfigurationHandler} required to * successfully and correctly create the server pack. * @param injectedServerPackHandler Instance of {@link ServerPackHandler} required for the @@ -293,7 +293,7 @@ public class TabCreateServerPack extends JPanel { * @author Griefed */ public TabCreateServerPack( - LocalizationManager injectedLocalizationManager, + I18n injectedI18n, ConfigurationHandler injectedConfigurationHandler, ServerPackHandler injectedServerPackHandler, VersionMeta injectedVersionMeta, @@ -315,10 +315,10 @@ public class TabCreateServerPack extends JPanel { this.APPLICATIONPROPERTIES = injectedApplicationProperties; } - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + if (injectedI18n == null) { + this.I18N = new I18n(APPLICATIONPROPERTIES); } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; + this.I18N = injectedI18n; } if (injectedVersionMeta == null) { @@ -335,7 +335,7 @@ public class TabCreateServerPack extends JPanel { } if (injectedUtilities == null) { - this.UTILITIES = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + this.UTILITIES = new Utilities(I18N, APPLICATIONPROPERTIES); } else { this.UTILITIES = injectedUtilities; } @@ -349,7 +349,7 @@ public class TabCreateServerPack extends JPanel { if (injectedConfigUtilities == null) { this.CONFIGUTILITIES = - new ConfigUtilities(LOCALIZATIONMANAGER, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); + new ConfigUtilities(I18N, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); } else { this.CONFIGUTILITIES = injectedConfigUtilities; } @@ -357,21 +357,17 @@ public class TabCreateServerPack extends JPanel { if (injectedConfigurationHandler == null) { this.CONFIGURATIONHANDLER = new ConfigurationHandler( - LOCALIZATIONMANAGER, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); + I18N, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); } else { this.CONFIGURATIONHANDLER = injectedConfigurationHandler; } if (injectedServerPackHandler == null) { - this.CREATESERVERPACK = + this.SERVERPACKHANDLER = new ServerPackHandler( - LOCALIZATIONMANAGER, - APPLICATIONPROPERTIES, - VERSIONMETA, - UTILITIES, - APPLICATIONPLUGINS); + I18N, APPLICATIONPROPERTIES, VERSIONMETA, UTILITIES, APPLICATIONPLUGINS); } else { - this.CREATESERVERPACK = injectedServerPackHandler; + this.SERVERPACKHANDLER = injectedServerPackHandler; } this.FRAME_SERVERPACKCREATOR = injectedServerPackCreatorFrame; @@ -385,8 +381,7 @@ public class TabCreateServerPack extends JPanel { try { SERVERPACKGENERATEDDOCUMENT.insertString( 0, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.openfolder.browse"), + I18N.getMessage("createserverpack.gui.createserverpack.openfolder.browse"), SERVERPACKGENERATEDATTRIBUTESET); } catch (BadLocationException ex) { LOG.error("Error inserting text into aboutDocument.", ex); @@ -402,29 +397,21 @@ public class TabCreateServerPack extends JPanel { try { LAZYMODEDOCUMENT.insertString( 0, - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode0") + I18N.getMessage("configuration.log.warn.checkconfig.copydirs.lazymode0") + "\n\n" - + LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode1") + + I18N.getMessage("configuration.log.warn.checkconfig.copydirs.lazymode1") + "\n" - + LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode2") + + I18N.getMessage("configuration.log.warn.checkconfig.copydirs.lazymode2") + "\n" - + LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode3") + + I18N.getMessage("configuration.log.warn.checkconfig.copydirs.lazymode3") + "\n\n" - + LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.copydirs.lazymode0"), + + I18N.getMessage("configuration.log.warn.checkconfig.copydirs.lazymode0"), LAZYMODEATTRIBUTESET); } catch (BadLocationException ex) { LOG.error("Error inserting text into aboutDocument.", ex); } - this.NONE = - new String[] { - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.createserverpack.forge.none") - }; + this.NONE = new String[] {I18N.getMessage("createserverpack.gui.createserverpack.forge.none")}; this.FABRIC_VERSIONS = new DefaultComboBoxModel<>(VERSIONMETA.fabric().loaderVersionsArrayDescending()); @@ -440,12 +427,9 @@ public class TabCreateServerPack extends JPanel { // Label and textfield modpackDir JLabel labelModpackDir = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelmodpackdir")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labelmodpackdir")); labelModpackDir.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelmodpackdir.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelmodpackdir.tip")); GRIDBAGCONSTRAINTS.gridx = 0; GRIDBAGCONSTRAINTS.gridy = 0; @@ -455,8 +439,7 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(labelModpackDir, GRIDBAGCONSTRAINTS); TEXTFIELD_MODPACKDIRECTORY.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelmodpackdir.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelmodpackdir.tip")); TEXTFIELD_MODPACKDIRECTORY.addDocumentListener( (SimpleDocumentListener) e -> validateModpackDir()); @@ -469,12 +452,9 @@ public class TabCreateServerPack extends JPanel { // Label and textfield server pack suffix JLabel labelServerPackSuffix = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelsuffix")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labelsuffix")); labelServerPackSuffix.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelsuffix.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelsuffix.tip")); GRIDBAGCONSTRAINTS.gridwidth = 2; GRIDBAGCONSTRAINTS.gridx = 4; @@ -484,11 +464,9 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(labelServerPackSuffix, GRIDBAGCONSTRAINTS); TEXTFIELD_SERVERPACKSUFFIX.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelsuffix.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelsuffix.tip")); ERROR_ICON_SERVERPACK_SUFFIX.setDescription( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textsuffix.error")); + I18N.getMessage("createserverpack.gui.createserverpack.textsuffix.error")); TEXTFIELD_SERVERPACKSUFFIX.addDocumentListener((SimpleDocumentListener) e -> validateSuffix()); GRIDBAGCONSTRAINTS.gridwidth = 1; @@ -502,12 +480,9 @@ public class TabCreateServerPack extends JPanel { // Label and textfield clientMods JLabel labelClientMods = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelclientmods")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labelclientmods")); labelClientMods.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelclientmods.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelclientmods.tip")); GRIDBAGCONSTRAINTS.gridx = 0; GRIDBAGCONSTRAINTS.gridy = 2; @@ -516,12 +491,10 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(labelClientMods, GRIDBAGCONSTRAINTS); TEXTAREA_CLIENTSIDEMODS.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelclientmods.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelclientmods.tip")); TEXTAREA_CLIENTSIDEMODS.setFont(new Font("Noto Sans Display Regular", Font.PLAIN, 15)); ERROR_ICON_CLIENTSIDE_MODS.setDescription( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textclientmods.error")); + I18N.getMessage("createserverpack.gui.createserverpack.textclientmods.error")); TEXTAREA_CLIENTSIDEMODS.addDocumentListener((SimpleDocumentListener) e -> validateClientMods()); JPanel CLIENTSIDEMODS_JPANEL = new JPanel(); CLIENTSIDEMODS_JPANEL.setLayout(new GridBagLayout()); @@ -553,12 +526,9 @@ public class TabCreateServerPack extends JPanel { // Label and textfield copyDirs JLabel labelCopyDirs = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelcopydirs")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labelcopydirs")); labelCopyDirs.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelcopydirs.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelcopydirs.tip")); GRIDBAGCONSTRAINTS.gridx = 0; GRIDBAGCONSTRAINTS.gridy = 4; @@ -567,12 +537,10 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(labelCopyDirs, GRIDBAGCONSTRAINTS); TEXTAREA_COPYDIRECTORIES.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelcopydirs.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelcopydirs.tip")); TEXTAREA_COPYDIRECTORIES.setFont(new Font("Noto Sans Display Regular", Font.PLAIN, 15)); ERROR_ICON_COPYDIRECTORIES.setDescription( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textclientmods.error")); + I18N.getMessage("createserverpack.gui.createserverpack.textclientmods.error")); TEXTAREA_COPYDIRECTORIES.addDocumentListener((SimpleDocumentListener) e -> validateCopyDirs()); JPanel COPYDIRECTORIES_JPANEL = new JPanel(); COPYDIRECTORIES_JPANEL.setLayout(new GridBagLayout()); @@ -607,12 +575,9 @@ public class TabCreateServerPack extends JPanel { GRIDBAGCONSTRAINTS.gridwidth = 2; JLabel labelServerIconPath = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labeliconpath")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labeliconpath")); labelServerIconPath.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labeliconpath.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labeliconpath.tip")); GRIDBAGCONSTRAINTS.gridx = 0; GRIDBAGCONSTRAINTS.gridy = 6; @@ -622,11 +587,9 @@ public class TabCreateServerPack extends JPanel { TEXTFIELD_SERVERICONPATH.setText(""); TEXTFIELD_SERVERICONPATH.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textfield.iconpath")); + I18N.getMessage("createserverpack.gui.createserverpack.textfield.iconpath")); ERROR_ICON_SERVERICON.setDescription( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textfield.iconpath.error")); + I18N.getMessage("createserverpack.gui.createserverpack.textfield.iconpath.error")); TEXTFIELD_SERVERICONPATH.addDocumentListener( (SimpleDocumentListener) e -> validateServerIcon()); @@ -637,12 +600,9 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(TEXTFIELD_SERVERICONPATH, GRIDBAGCONSTRAINTS); JLabel labelServerPropertiesPath = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelpropertiespath")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labelpropertiespath")); labelServerPropertiesPath.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelpropertiespath.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelpropertiespath.tip")); GRIDBAGCONSTRAINTS.gridx = 3; GRIDBAGCONSTRAINTS.gridy = 6; @@ -652,11 +612,9 @@ public class TabCreateServerPack extends JPanel { TEXTFIELD_SERVERPROPERTIESPATH.setText(""); TEXTFIELD_SERVERPROPERTIESPATH.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textfield.propertiespath")); + I18N.getMessage("createserverpack.gui.createserverpack.textfield.propertiespath")); ERROR_ICON_SERVERPROPERTIES.setDescription( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textfield.propertiespath.error")); + I18N.getMessage("createserverpack.gui.createserverpack.textfield.propertiespath.error")); TEXTFIELD_SERVERPROPERTIESPATH.addDocumentListener( (SimpleDocumentListener) e -> validateServerProperties()); @@ -671,13 +629,10 @@ public class TabCreateServerPack extends JPanel { GRIDBAGCONSTRAINTS.gridwidth = 5; JLabel labelJavaPath = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labeljavapath")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labeljavapath")); labelJavaPath.setToolTipText( "<html>" - + LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labeljavapath.tip") + + I18N.getMessage("createserverpack.gui.createserverpack.labeljavapath.tip") + "</html>"); GRIDBAGCONSTRAINTS.gridx = 0; @@ -687,11 +642,9 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(labelJavaPath, GRIDBAGCONSTRAINTS); TEXTFIELD_JAVAPATH.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labeljavapath.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labeljavapath.tip")); ERROR_ICON_JAVAPATH.setDescription( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textjavapath.error")); + I18N.getMessage("createserverpack.gui.createserverpack.textjavapath.error")); TEXTFIELD_JAVAPATH.addDocumentListener((SimpleDocumentListener) e -> validateJavaPath()); GRIDBAGCONSTRAINTS.gridx = 0; @@ -704,12 +657,9 @@ public class TabCreateServerPack extends JPanel { // Label and combobox minecraftVersion JLabel labelMinecraftVersion = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelminecraft")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labelminecraft")); labelMinecraftVersion.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelminecraft.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelminecraft.tip")); GRIDBAGCONSTRAINTS.gridx = 0; GRIDBAGCONSTRAINTS.gridy = 10; @@ -732,12 +682,9 @@ public class TabCreateServerPack extends JPanel { // Label and radio buttons Modloader JLabel labelModloader = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelmodloader")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labelmodloader")); labelModloader.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelmodloader.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelmodloader.tip")); GRIDBAGCONSTRAINTS.gridx = 1; GRIDBAGCONSTRAINTS.gridy = 10; @@ -765,12 +712,9 @@ public class TabCreateServerPack extends JPanel { // Label and textfield modloaderVersion JLabel labelModloaderVersion = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelmodloaderversion")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.labelmodloaderversion")); labelModloaderVersion.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelmodloaderversion.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelmodloaderversion.tip")); GRIDBAGCONSTRAINTS.gridx = 2; GRIDBAGCONSTRAINTS.gridy = 10; @@ -799,12 +743,9 @@ public class TabCreateServerPack extends JPanel { // Checkbox installServer CHECKBOX_SERVER = new JCheckBox( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxserver"), - true); + I18N.getMessage("createserverpack.gui.createserverpack.checkboxserver"), true); CHECKBOX_SERVER.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxserver.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.checkboxserver.tip")); CHECKBOX_SERVER.addActionListener(this::actionEventCheckBoxServer); GRIDBAGCONSTRAINTS.gridx = 0; @@ -814,13 +755,9 @@ public class TabCreateServerPack extends JPanel { // Checkbox copyIcon CHECKBOX_ICON = - new JCheckBox( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxicon"), - true); + new JCheckBox(I18N.getMessage("createserverpack.gui.createserverpack.checkboxicon"), true); CHECKBOX_ICON.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxicon.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.checkboxicon.tip")); GRIDBAGCONSTRAINTS.gridx = 1; GRIDBAGCONSTRAINTS.gridy = 14; @@ -830,12 +767,9 @@ public class TabCreateServerPack extends JPanel { // Checkbox copyProperties CHECKBOX_PROPERTIES = new JCheckBox( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxproperties"), - true); + I18N.getMessage("createserverpack.gui.createserverpack.checkboxproperties"), true); CHECKBOX_PROPERTIES.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxproperties.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.checkboxproperties.tip")); GRIDBAGCONSTRAINTS.gridx = 2; GRIDBAGCONSTRAINTS.gridy = 14; @@ -844,13 +778,9 @@ public class TabCreateServerPack extends JPanel { // Checkbox createZIP CHECKBOX_ZIP = - new JCheckBox( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxzip"), - true); + new JCheckBox(I18N.getMessage("createserverpack.gui.createserverpack.checkboxzip"), true); CHECKBOX_ZIP.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxzip.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.checkboxzip.tip")); GRIDBAGCONSTRAINTS.gridx = 3; GRIDBAGCONSTRAINTS.gridy = 14; @@ -858,12 +788,9 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(CHECKBOX_ZIP, GRIDBAGCONSTRAINTS); JLabel labelJavaArgs = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.javaargs")); + new JLabel(I18N.getMessage("createserverpack.gui.createserverpack.javaargs")); labelJavaArgs.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.javaargs.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.javaargs.tip")); GRIDBAGCONSTRAINTS.gridx = 0; GRIDBAGCONSTRAINTS.gridy = 15; @@ -873,8 +800,7 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(labelJavaArgs, GRIDBAGCONSTRAINTS); TEXTAREA_JAVAARGS.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.javaargs.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.javaargs.tip")); TEXTAREA_JAVAARGS.setFont(new Font("Noto Sans Display Regular", Font.PLAIN, 15)); JPanel JAVAARGS_JPANEL = new JPanel(); JAVAARGS_JPANEL.setLayout(new GridBagLayout()); @@ -916,7 +842,7 @@ public class TabCreateServerPack extends JPanel { JButton BUTTON_MODPACKDIRECTORY = new JButton(); BUTTON_MODPACKDIRECTORY.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonmodpackdir")); + I18N.getMessage("createserverpack.gui.buttonmodpackdir")); BUTTON_MODPACKDIRECTORY.setContentAreaFilled(false); BUTTON_MODPACKDIRECTORY.setMultiClickThreshhold(1000); ImageIcon FOLDERICON = @@ -937,8 +863,7 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(BUTTON_MODPACKDIRECTORY, GRIDBAGCONSTRAINTS); JButton BUTTON_CLIENTSIDEMODS = new JButton(); - BUTTON_CLIENTSIDEMODS.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonclientmods")); + BUTTON_CLIENTSIDEMODS.setToolTipText(I18N.getMessage("createserverpack.gui.buttonclientmods")); BUTTON_CLIENTSIDEMODS.setContentAreaFilled(false); BUTTON_CLIENTSIDEMODS.setMultiClickThreshhold(1000); BUTTON_CLIENTSIDEMODS.setIcon(FOLDERICON); @@ -954,8 +879,7 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(BUTTON_CLIENTSIDEMODS, GRIDBAGCONSTRAINTS); JButton BUTTON_COPYDIRECTORIES = new JButton(); - BUTTON_COPYDIRECTORIES.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttoncopydirs")); + BUTTON_COPYDIRECTORIES.setToolTipText(I18N.getMessage("createserverpack.gui.buttoncopydirs")); BUTTON_COPYDIRECTORIES.setContentAreaFilled(false); BUTTON_COPYDIRECTORIES.setIcon(FOLDERICON); BUTTON_COPYDIRECTORIES.setMultiClickThreshhold(1000); @@ -971,8 +895,7 @@ public class TabCreateServerPack extends JPanel { CREATESERVERPACKPANEL.add(BUTTON_COPYDIRECTORIES, GRIDBAGCONSTRAINTS); JButton BUTTON_JAVAPATH = new JButton(); - BUTTON_JAVAPATH.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonjavapath")); + BUTTON_JAVAPATH.setToolTipText(I18N.getMessage("createserverpack.gui.buttonjavapath")); BUTTON_JAVAPATH.setContentAreaFilled(false); BUTTON_JAVAPATH.setIcon(FOLDERICON); BUTTON_JAVAPATH.setMultiClickThreshhold(1000); @@ -989,8 +912,7 @@ public class TabCreateServerPack extends JPanel { JButton BUTTON_SERVERICON = new JButton(); BUTTON_SERVERICON.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.button.icon")); + I18N.getMessage("createserverpack.gui.createserverpack.button.icon")); BUTTON_SERVERICON.setContentAreaFilled(false); BUTTON_SERVERICON.setIcon(FOLDERICON); BUTTON_SERVERICON.setMultiClickThreshhold(1000); @@ -1010,8 +932,7 @@ public class TabCreateServerPack extends JPanel { JButton BUTTON_SERVERPROPERTIES = new JButton(); BUTTON_SERVERPROPERTIES.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.button.properties")); + I18N.getMessage("createserverpack.gui.createserverpack.button.properties")); BUTTON_SERVERPROPERTIES.setContentAreaFilled(false); BUTTON_SERVERPROPERTIES.setIcon(FOLDERICON); BUTTON_SERVERPROPERTIES.setMultiClickThreshhold(1000); @@ -1028,15 +949,13 @@ public class TabCreateServerPack extends JPanel { JButton BUTTON_AIKARS_FLAGS = new JButton(); BUTTON_AIKARS_FLAGS.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.button.properties")); + I18N.getMessage("createserverpack.gui.createserverpack.button.properties")); BUTTON_AIKARS_FLAGS.setContentAreaFilled(false); BUTTON_AIKARS_FLAGS.setIcon( new RotatedIcon( new TextIcon( BUTTON_AIKARS_FLAGS, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.javaargs.aikar"), + I18N.getMessage("createserverpack.gui.createserverpack.javaargs.aikar"), TextIcon.Layout.HORIZONTAL), RotatedIcon.Rotate.UP)); BUTTON_AIKARS_FLAGS.setMultiClickThreshhold(1000); @@ -1067,10 +986,7 @@ public class TabCreateServerPack extends JPanel { STATUS_LABEL_LINE_3 = new JLabel("..." + RETICULATOR.reticulate() + " "); STATUS_LABEL_LINE_4 = new JLabel("..." + RETICULATOR.reticulate() + " "); STATUS_LABEL_LINE_5 = - new JLabel( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.buttongenerateserverpack.ready") - + " "); + new JLabel(I18N.getMessage("createserverpack.gui.buttongenerateserverpack.ready") + " "); // Make sure all labels start on the left and extrend to the right STATUS_LABEL_LINE_0.setHorizontalAlignment(JLabel.LEFT); @@ -1124,13 +1040,11 @@ public class TabCreateServerPack extends JPanel { new ImageIcon(GENERATE.getScaledInstance(32, 32, Image.SCALE_SMOOTH)), new TextIcon( BUTTON_GENERATESERVERPACK, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.buttongenerateserverpack")))); + I18N.getMessage("createserverpack.gui.buttongenerateserverpack")))); BUTTON_GENERATESERVERPACK.addActionListener(this::generateServerpack); BUTTON_GENERATESERVERPACK.setMultiClickThreshhold(1000); BUTTON_GENERATESERVERPACK.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.buttongenerateserverpack.tip")); + I18N.getMessage("createserverpack.gui.buttongenerateserverpack.tip")); GRIDBAGCONSTRAINTS.gridx = 0; GRIDBAGCONSTRAINTS.gridy = 19; @@ -1150,12 +1064,11 @@ public class TabCreateServerPack extends JPanel { 8, FOLDERICON, new TextIcon( - BUTTON_SERVER_PACKS, - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonserverpacks")))); + BUTTON_SERVER_PACKS, I18N.getMessage("createserverpack.gui.buttonserverpacks")))); BUTTON_SERVER_PACKS.addActionListener(this::openServerPacksFolder); BUTTON_SERVER_PACKS.setMultiClickThreshhold(1000); BUTTON_SERVER_PACKS.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonserverpacks.tip")); + I18N.getMessage("createserverpack.gui.buttonserverpacks.tip")); GRIDBAGCONSTRAINTS.gridy = 20; GRIDBAGCONSTRAINTS.anchor = GridBagConstraints.WEST; @@ -1296,8 +1209,7 @@ public class TabCreateServerPack extends JPanel { TEXTFIELD_MODPACKDIRECTORY.setIcon(null); TEXTFIELD_MODPACKDIRECTORY.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelmodpackdir.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelmodpackdir.tip")); TEXTFIELD_MODPACKDIRECTORY.setForeground(getThemeTextColor()); @@ -1323,8 +1235,7 @@ public class TabCreateServerPack extends JPanel { TEXTFIELD_SERVERPACKSUFFIX.setIcon(null); TEXTFIELD_SERVERPACKSUFFIX.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelsuffix.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelsuffix.tip")); TEXTFIELD_SERVERPACKSUFFIX.setForeground(getThemeTextColor()); @@ -1347,8 +1258,7 @@ public class TabCreateServerPack extends JPanel { TEXTAREA_CLIENTSIDEMODS.setIcon(null); TEXTAREA_CLIENTSIDEMODS.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelclientmods.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelclientmods.tip")); TEXTAREA_CLIENTSIDEMODS.setForeground(getThemeTextColor()); @@ -1379,8 +1289,7 @@ public class TabCreateServerPack extends JPanel { TEXTAREA_COPYDIRECTORIES.setIcon(null); TEXTAREA_COPYDIRECTORIES.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labelcopydirs.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labelcopydirs.tip")); TEXTAREA_COPYDIRECTORIES.setForeground(getThemeTextColor()); @@ -1403,8 +1312,7 @@ public class TabCreateServerPack extends JPanel { TEXTFIELD_SERVERICONPATH.setIcon(null); TEXTFIELD_SERVERICONPATH.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textfield.iconpath")); + I18N.getMessage("createserverpack.gui.createserverpack.textfield.iconpath")); TEXTFIELD_SERVERICONPATH.setForeground(getThemeTextColor()); @@ -1425,8 +1333,7 @@ public class TabCreateServerPack extends JPanel { if (CONFIGURATIONHANDLER.checkIconAndProperties(TEXTFIELD_SERVERPROPERTIESPATH.getText())) { TEXTFIELD_SERVERPROPERTIESPATH.setIcon(null); TEXTFIELD_SERVERPROPERTIESPATH.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.textfield.propertiespath")); + I18N.getMessage("createserverpack.gui.createserverpack.textfield.propertiespath")); TEXTFIELD_SERVERPROPERTIESPATH.setForeground(getThemeTextColor()); @@ -1448,8 +1355,7 @@ public class TabCreateServerPack extends JPanel { TEXTFIELD_JAVAPATH.setIcon(null); TEXTFIELD_JAVAPATH.setToolTipText( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.labeljavapath.tip")); + I18N.getMessage("createserverpack.gui.createserverpack.labeljavapath.tip")); TEXTFIELD_JAVAPATH.setForeground(getThemeTextColor()); } else { @@ -1471,10 +1377,8 @@ public class TabCreateServerPack extends JPanel { if (!TEXTAREA_JAVAARGS.getText().isEmpty()) { switch (JOptionPane.showConfirmDialog( CREATESERVERPACKPANEL, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.javaargs.confirm.message"), - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.javaargs.confirm.title"), + I18N.getMessage("createserverpack.gui.createserverpack.javaargs.confirm.message"), + I18N.getMessage("createserverpack.gui.createserverpack.javaargs.confirm.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE)) { case 0: @@ -1515,10 +1419,8 @@ public class TabCreateServerPack extends JPanel { if (CHECKBOX_SERVER.isSelected() && TEXTFIELD_JAVAPATH.getText().isEmpty()) { switch (JOptionPane.showConfirmDialog( CREATESERVERPACKPANEL, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxserver.confirm.message"), - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxserver.confirm.title"), + I18N.getMessage("createserverpack.gui.createserverpack.checkboxserver.confirm.message"), + I18N.getMessage("createserverpack.gui.createserverpack.checkboxserver.confirm.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE)) { case 0: @@ -1528,10 +1430,9 @@ public class TabCreateServerPack extends JPanel { case 1: JOptionPane.showMessageDialog( CREATESERVERPACKPANEL, - LOCALIZATIONMANAGER.getLocalizedString( + I18N.getMessage( "createserverpack.gui.createserverpack.checkboxserver.message.message"), - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.checkboxserver.message.title"), + I18N.getMessage("createserverpack.gui.createserverpack.checkboxserver.message.title"), JOptionPane.ERROR_MESSAGE, null); break; @@ -1700,12 +1601,11 @@ public class TabCreateServerPack extends JPanel { modpackDirChooser.setCurrentDirectory(DIRECTORY_CHOOSER); } modpackDirChooser.setDialogTitle( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonmodpackdir.title")); + I18N.getMessage("createserverpack.gui.buttonmodpackdir.title")); modpackDirChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); modpackDirChooser.setFileFilter( new FileNameExtensionFilter( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.chooser.modpack.filter"), + I18N.getMessage("createserverpack.gui.createserverpack.chooser.modpack.filter"), "zip")); modpackDirChooser.setAcceptAllFileFilterUsed(false); modpackDirChooser.setMultiSelectionEnabled(false); @@ -1739,13 +1639,11 @@ public class TabCreateServerPack extends JPanel { serverIconChooser.setCurrentDirectory(DIRECTORY_CHOOSER); serverIconChooser.setDialogTitle( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.chooser.icon.title")); + I18N.getMessage("createserverpack.gui.createserverpack.chooser.icon.title")); serverIconChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); serverIconChooser.setFileFilter( new FileNameExtensionFilter( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.chooser.icon.filter"), + I18N.getMessage("createserverpack.gui.createserverpack.chooser.icon.filter"), "png", "jpg", "jpeg", @@ -1778,13 +1676,11 @@ public class TabCreateServerPack extends JPanel { serverPropertiesChooser.setCurrentDirectory(DIRECTORY_CHOOSER); serverPropertiesChooser.setDialogTitle( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.chooser.properties.title")); + I18N.getMessage("createserverpack.gui.createserverpack.chooser.properties.title")); serverPropertiesChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); serverPropertiesChooser.setFileFilter( new FileNameExtensionFilter( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.chooser.properties.filter"), + I18N.getMessage("createserverpack.gui.createserverpack.chooser.properties.filter"), "properties")); serverPropertiesChooser.setAcceptAllFileFilterUsed(false); serverPropertiesChooser.setMultiSelectionEnabled(false); @@ -1825,13 +1721,12 @@ public class TabCreateServerPack extends JPanel { } clientModsChooser.setDialogTitle( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonclientmods.title")); + I18N.getMessage("createserverpack.gui.buttonclientmods.title")); clientModsChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); clientModsChooser.setFileFilter( new FileNameExtensionFilter( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonclientmods.filter"), - "jar")); + I18N.getMessage("createserverpack.gui.buttonclientmods.filter"), "jar")); clientModsChooser.setAcceptAllFileFilterUsed(false); clientModsChooser.setMultiSelectionEnabled(true); @@ -1872,8 +1767,7 @@ public class TabCreateServerPack extends JPanel { copyDirsChooser.setCurrentDirectory(DIRECTORY_CHOOSER); } - copyDirsChooser.setDialogTitle( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttoncopydirs.title")); + copyDirsChooser.setDialogTitle(I18N.getMessage("createserverpack.gui.buttoncopydirs.title")); copyDirsChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); copyDirsChooser.setAcceptAllFileFilterUsed(false); copyDirsChooser.setMultiSelectionEnabled(true); @@ -1921,8 +1815,7 @@ public class TabCreateServerPack extends JPanel { javaChooser.setCurrentDirectory(DIRECTORY_CHOOSER); } - javaChooser.setDialogTitle( - LOCALIZATIONMANAGER.getLocalizedString("createserverpack.gui.buttonjavapath.tile")); + javaChooser.setDialogTitle(I18N.getMessage("createserverpack.gui.buttonjavapath.tile")); javaChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); javaChooser.setAcceptAllFileFilterUsed(true); javaChooser.setMultiSelectionEnabled(false); @@ -1938,9 +1831,7 @@ public class TabCreateServerPack extends JPanel { + javaChooser.getSelectedFile().getCanonicalPath().replace("\\", "/")); } catch (IOException ex) { - LOG.error( - "LOCALIZATIONMANAGER.getLocalizedString(\"createserverpack.log.error.buttonjavapath\")", - ex); + LOG.error("Couldn't set java executable path.", ex); } } } @@ -1965,8 +1856,7 @@ public class TabCreateServerPack extends JPanel { JOptionPane.showConfirmDialog( FRAME_SERVERPACKCREATOR, LAZYMODETEXTPANE, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.lazymode"), + I18N.getMessage("createserverpack.gui.createserverpack.lazymode"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); } @@ -1993,6 +1883,9 @@ public class TabCreateServerPack extends JPanel { * @author Griefed */ private ConfigurationModel currentConfigAsModel() { + // To be used and enhanced in a later milestone + HashMap<String, String> scriptSettings = new HashMap<>(); + return new ConfigurationModel( UTILITIES.ListUtils() .cleanList( @@ -2016,7 +1909,8 @@ public class TabCreateServerPack extends JPanel { CHECKBOX_SERVER.isSelected(), CHECKBOX_ICON.isSelected(), CHECKBOX_PROPERTIES.isSelected(), - CHECKBOX_ZIP.isSelected()); + CHECKBOX_ZIP.isSelected(), + scriptSettings); } /** @@ -2040,14 +1934,9 @@ public class TabCreateServerPack extends JPanel { 100, false); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttoncreateserverpack.start")); - // labelGenerateServerPack.setText(LOCALIZATIONMANAGER.getLocalizedString("createserverpack.log.info.buttoncreateserverpack.start")); - updateStatus( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttoncreateserverpack.start")); + LOG.info("Checking entered configuration."); + + updateStatus(I18N.getMessage("createserverpack.log.info.buttoncreateserverpack.start")); List<String> encounteredErrors = new ArrayList<>(100); @@ -2059,35 +1948,26 @@ public class TabCreateServerPack extends JPanel { if (!CONFIGURATIONHANDLER.checkConfiguration( configurationModel, encounteredErrors, true)) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttoncreateserverpack.checked")); + LOG.info("Configuration checked successfully."); updateStatus( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttoncreateserverpack.checked")); + I18N.getMessage("createserverpack.log.info.buttoncreateserverpack.checked")); saveConfig(APPLICATIONPROPERTIES.DEFAULT_CONFIG()); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttoncreateserverpack.generating")); + LOG.info("Starting ServerPackCreator run."); updateStatus( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttoncreateserverpack.generating")); + I18N.getMessage("createserverpack.log.info.buttoncreateserverpack.generating")); try { - CREATESERVERPACK.run(configurationModel); + SERVERPACKHANDLER.run(configurationModel); loadConfig(new File("serverpackcreator.conf")); updateStatus( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttoncreateserverpack.ready")); + I18N.getMessage("createserverpack.log.info.buttoncreateserverpack.ready")); SERVERPACKGENERATEDDOCUMENT.setParagraphAttributes( 0, @@ -2101,8 +1981,7 @@ public class TabCreateServerPack extends JPanel { if (JOptionPane.showConfirmDialog( FRAME_SERVERPACKCREATOR, SERVERPACKGENERATEDTEXTPANE, - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.openfolder.title"), + I18N.getMessage("createserverpack.gui.createserverpack.openfolder.title"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == 0) { @@ -2110,16 +1989,7 @@ public class TabCreateServerPack extends JPanel { try { Desktop.getDesktop() .open( - new File( - String.format( - "%s/%s", - APPLICATIONPROPERTIES.getDirectoryServerPacks(), - configurationModel - .getModpackDir() - .substring( - configurationModel.getModpackDir().lastIndexOf("/") - + 1) - + TEXTFIELD_SERVERPACKSUFFIX.getText()))); + new File(SERVERPACKHANDLER.getServerPackDestination(configurationModel))); } catch (IOException ex) { LOG.error("Error opening file explorer for server pack.", ex); } @@ -2132,9 +2002,7 @@ public class TabCreateServerPack extends JPanel { } else { - updateStatus( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.buttongenerateserverpack.fail")); + updateStatus(I18N.getMessage("createserverpack.gui.buttongenerateserverpack.fail")); if (encounteredErrors.size() > 0) { @@ -2151,8 +2019,7 @@ public class TabCreateServerPack extends JPanel { FRAME_SERVERPACKCREATOR, errors, String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.gui.createserverpack.errors.encountered"), + I18N.getMessage("createserverpack.gui.createserverpack.errors.encountered"), encounteredErrors.size()), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); diff --git a/backend/main/java/de/griefed/serverpackcreator/swing/TabServerPackCreatorLog.java b/backend/main/java/de/griefed/serverpackcreator/swing/TabServerPackCreatorLog.java index 732956c9b6cae44263cc2431dc3417f723631889..e278d83393882a75e44b67590d3c53704a467686 100644 --- a/backend/main/java/de/griefed/serverpackcreator/swing/TabServerPackCreatorLog.java +++ b/backend/main/java/de/griefed/serverpackcreator/swing/TabServerPackCreatorLog.java @@ -19,12 +19,10 @@ */ package de.griefed.serverpackcreator.swing; -import de.griefed.serverpackcreator.ApplicationProperties; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.swing.utilities.JComponentTailer; import de.griefed.serverpackcreator.utilities.misc.Generated; import java.io.File; -import java.util.Properties; import org.apache.commons.io.input.Tailer; import org.apache.commons.io.input.TailerListener; import org.apache.commons.io.input.TailerListenerAdapter; @@ -37,40 +35,19 @@ import org.apache.commons.io.input.TailerListenerAdapter; @Generated public class TabServerPackCreatorLog extends JComponentTailer { - private final LocalizationManager LOCALIZATIONMANAGER; - /** * <strong>Constructor</strong> * * <p>Used for Dependency Injection. * - * <p>Receives an instance of {@link LocalizationManager} or creates one if the received one is - * null. Required for use of localization. + * <p>Receives an instance of {@link I18n} or creates one if the received one is null. Required + * for use of localization. * - * @param injectedLocalizationManager Instance of {@link LocalizationManager} required for - * localized log messages. - * @param injectedApplicationProperties Instance of {@link Properties} required for various - * different things. * @param tooltip {@link String} The tooltip text for this tailer. * @author Griefed */ - public TabServerPackCreatorLog( - LocalizationManager injectedLocalizationManager, - ApplicationProperties injectedApplicationProperties, - String tooltip) { + public TabServerPackCreatorLog(String tooltip) { super(tooltip); - ApplicationProperties APPLICATIONPROPERTIES; - if (injectedApplicationProperties == null) { - APPLICATIONPROPERTIES = new ApplicationProperties(); - } else { - APPLICATIONPROPERTIES = injectedApplicationProperties; - } - - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); - } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; - } createTailer(); } @@ -82,9 +59,7 @@ public class TabServerPackCreatorLog extends JComponentTailer { protected void createTailer() { class MyTailerListener extends TailerListenerAdapter { public void handle(String line) { - if (line.contains( - LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.info.buttoncreateserverpack.start"))) { + if (line.contains("Checking entered configuration.")) { textArea.setText(""); } if (!line.contains("DEBUG")) { diff --git a/backend/main/java/de/griefed/serverpackcreator/swing/utilities/SimpleDocumentListener.java b/backend/main/java/de/griefed/serverpackcreator/swing/utilities/SimpleDocumentListener.java index 67f3e793d0046aac018349545944eb55558960a0..50b97e6fdf02f7d66346862c1e6cba1fa4411509 100644 --- a/backend/main/java/de/griefed/serverpackcreator/swing/utilities/SimpleDocumentListener.java +++ b/backend/main/java/de/griefed/serverpackcreator/swing/utilities/SimpleDocumentListener.java @@ -18,7 +18,5 @@ public interface SimpleDocumentListener extends DocumentListener { } @Override - default void changedUpdate(DocumentEvent e) { - - } + default void changedUpdate(DocumentEvent e) {} } diff --git a/backend/main/java/de/griefed/serverpackcreator/utilities/ConfigUtilities.java b/backend/main/java/de/griefed/serverpackcreator/utilities/ConfigUtilities.java index 1fa5ec5cc0a545225ecad569a476ecb8c4aba778..be34e4f32e657f016f247cb049d5abacbb51e7fe 100644 --- a/backend/main/java/de/griefed/serverpackcreator/utilities/ConfigUtilities.java +++ b/backend/main/java/de/griefed/serverpackcreator/utilities/ConfigUtilities.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import de.griefed.serverpackcreator.ApplicationProperties; import de.griefed.serverpackcreator.ConfigurationModel; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.utilities.common.Utilities; import de.griefed.serverpackcreator.versionmeta.VersionMeta; import java.io.BufferedWriter; @@ -62,14 +62,14 @@ public class ConfigUtilities { private static final Logger LOG = LogManager.getLogger(ConfigUtilities.class); - private final LocalizationManager LOCALIZATIONMANAGER; + private final I18n I18N; private final Utilities UTILITIES; private final ApplicationProperties APPLICATIONPROPERTIES; private final VersionMeta VERSIONMETA; @Autowired public ConfigUtilities( - LocalizationManager injectedLocalizationManager, + I18n injectedI18n, Utilities injectedUtilities, ApplicationProperties injectedApplicationProperties, VersionMeta injectedVersionMeta) @@ -81,14 +81,14 @@ public class ConfigUtilities { this.APPLICATIONPROPERTIES = injectedApplicationProperties; } - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + if (injectedI18n == null) { + this.I18N = new I18n(APPLICATIONPROPERTIES); } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; + this.I18N = injectedI18n; } if (injectedUtilities == null) { - this.UTILITIES = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + this.UTILITIES = new Utilities(I18N, APPLICATIONPROPERTIES); } else { this.UTILITIES = injectedUtilities; } @@ -238,45 +238,37 @@ public class ConfigUtilities { + "%s\nincludeZipCreation = %b\n\n" + "%s\njavaArgs = \"%s\"\n\n" + "%s\nserverPackSuffix = \"%s\"", - LOCALIZATIONMANAGER.getLocalizedString("configuration.writeconfigtofile.modpackdir"), + "# Path to your modpack. Can be either relative or absolute.\n# Example: \"./Some Modpack\" or \"C:/Minecraft/Some Modpack\"", modpackDir.replace("\\", "/"), - LOCALIZATIONMANAGER.getLocalizedString("configuration.writeconfigtofile.clientmods"), + "# List of client-only mods to delete from serverpack.\n# No need to include version specifics. Must be the filenames of the mods, not their project names on CurseForge!\n# Example: [AmbientSounds-,ClientTweaks-,PackMenu-,BetterAdvancement-,jeiintegration-]", UTILITIES.ListUtils() .encapsulateListElements(UTILITIES.ListUtils().cleanList(clientMods)), - LOCALIZATIONMANAGER.getLocalizedString("configuration.writeconfigtofile.copydirs"), + "# Name of directories or files to include in serverpack.\n# When specifying \"saves/world_name\", \"world_name\" will be copied to the base directory of the serverpack\n# for immediate use with the server. Automatically set when projectID,fileID for modpackDir has been specified.\n# Example: [config,mods,scripts]", UTILITIES.ListUtils() .encapsulateListElements(UTILITIES.ListUtils().cleanList(copyDirs)), - LOCALIZATIONMANAGER.getLocalizedString("configuration.writeconfigtofile.custom.icon"), + "# Path to a custom server-icon.png-file to include in the server pack.", serverIconPath, - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.writeconfigtofile.custom.properties"), + "# Path to a custom server.properties-file to include in the server pack.", serverPropertiesPath, - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.writeconfigtofile.includeserverinstallation"), + "# Whether to install a Forge/Fabric/Quilt server for the serverpack. Must be true or false.\n# Default value is true.", includeServer, - LOCALIZATIONMANAGER.getLocalizedString("configuration.writeconfigtofile.javapath"), + "# Path to the Java executable. On Linux systems it would be something like \"/usr/bin/java\".\n# Only needed if includeServerInstallation is true.", javaPath.replace("\\", "/"), - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.writeconfigtofile.minecraftversion"), + "# Which Minecraft version to use. Example: \"1.16.5\".\n# Automatically set when projectID,fileID for modpackDir has been specified.\n# Only needed if includeServerInstallation is true.", minecraftVersion, - LOCALIZATIONMANAGER.getLocalizedString("configuration.writeconfigtofile.modloader"), + "# Which modloader to install. Must be either \"Forge\", \"Fabric\" or \"Quilt\".\n# Automatically set when projectID,fileID for modpackDir has been specified.\n# Only needed if includeServerInstallation is true.", modLoader, - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.writeconfigtofile.modloaderversion"), + "# The version of the modloader you want to install. Example for Fabric=\"0.7.3\", example for Forge=\"36.0.15\".\n# Automatically set when projectID,fileID for modpackDir has been specified.\n# Only needed if includeServerInstallation is true.", modLoaderVersion, - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.writeconfigtofile.includeservericon"), + "# Include a server-icon.png in your serverpack. Must be true or false.\n# Customize server-icon.png in ./server_files.\n# Dimensions must be 64x64!\n# Default value is true.", includeIcon, - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.writeconfigtofile.includeserverproperties"), + "# Include a server.properties in your serverpack. Must be true or false.\n# Customize server.properties in ./server_files.\n# If no server.properties is provided but is set to true, a default one will be provided.\n# Default value is true.", includeProperties, - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.writeconfigtofile.includezipcreation"), + "# Create zip-archive of serverpack. Must be true or false.\n# Default value is true.", includeZip, - LOCALIZATIONMANAGER.getLocalizedString("configuration.writeconfigtofile.javaargs"), + "# Java arguments to set in the start-scripts for the generated server pack. Default value is \"empty\".\n# Leave as \"empty\" to not have Java arguments in your start-scripts.", javaArgs, - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.writeconfigtofile.serverpacksuffix"), + "# Suffix to append to the server pack to be generated. Can be left blank/empty.", serverPackSuffix); // Overwrite any existing config by deleting already existing one. @@ -290,13 +282,10 @@ public class ConfigUtilities { writer.close(); configWritten = true; /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "defaultfiles.log.info.writeconfigtofile.confignew")); + LOG.info("Successfully written new configuration file."); } catch (IOException ex) { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("defaultfiles.log.error.writeconfigtofile"), ex); + LOG.error("Couldn't write serverpackcreator.conf.", ex); } return configWritten; @@ -331,8 +320,7 @@ public class ConfigUtilities { configurationAsList.add(configurationModel.getModpackDir()); configurationAsList.add( UTILITIES.StringUtils().buildString(configurationModel.getClientMods())); - configurationAsList.add( - UTILITIES.StringUtils().buildString(configurationModel.getCopyDirs())); + configurationAsList.add(UTILITIES.StringUtils().buildString(configurationModel.getCopyDirs())); configurationAsList.add(configurationModel.getJavaPath()); configurationAsList.add(configurationModel.getMinecraftVersion()); configurationAsList.add(configurationModel.getModLoader()); @@ -423,30 +411,23 @@ public class ConfigUtilities { String serverIconPath, String serverPropertiesPath) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.start")); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.modpackdir"), - modpackDirectory)); + LOG.info("Your configuration is:"); + LOG.info("Modpack directory: " + modpackDirectory); if (clientsideMods.isEmpty()) { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.printconfig.noclientmods")); + LOG.warn("No client mods specified."); } else { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.clientmods")); + LOG.info("Client mods specified. Client mods are:"); for (String mod : clientsideMods) { LOG.info(String.format(" %s", mod)); } } /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.copydirs")); + LOG.info("Directories to copy:"); if (copyDirectories != null) { @@ -456,63 +437,22 @@ public class ConfigUtilities { } else { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.error( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.error.printconfig.copydirs")); + LOG.error("List of directories to copy is empty."); } /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.server"), - installServer)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.javapath"), - javaInstallPath)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.printconfig.minecraftversion"), - minecraftVer)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.modloader"), - modloader)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.printconfig.modloaderversion"), - modloaderVersion)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.icon"), - includeIcon)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.properties"), - includeProperties)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.zip"), - includeZip)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.javaargs"), - javaArgs)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.printconfig.serverpacksuffix"), - serverPackSuffix)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("utilities.log.info.config.print.servericon"), - serverIconPath)); - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "utilities.log.info.config.print.serverproperties"), - serverPropertiesPath)); + LOG.info("Include server installation: " + installServer); + LOG.info("Java Installation path: " + javaInstallPath); + LOG.info("Minecraft version: " + minecraftVer); + LOG.info("Modloader: " + modloader); + LOG.info("Modloader Version: " + modloaderVersion); + LOG.info("Include server icon: " + includeIcon); + LOG.info("Include server properties: " + includeProperties); + LOG.info("Create zip-archive of serverpack: " + includeZip); + LOG.info("Java arguments for start-scripts: " + javaArgs); + LOG.info("Server pack suffix: " + serverPackSuffix); + LOG.info("Path to custom server-icon: " + serverIconPath); + LOG.info("Path to custom server.properties: " + serverPropertiesPath); } /** @@ -546,6 +486,7 @@ public class ConfigUtilities { if (checkCurseForgeJsonForFabric(configurationModel.getCurseModpack())) { + LOG.debug("Setting modloader to Fabric."); if (modloaderAndVersion[0].equalsIgnoreCase("Fabric")) { configurationModel.setModLoader("Fabric"); @@ -554,9 +495,7 @@ public class ConfigUtilities { } else { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.iscurse.fabric")); - LOG.debug( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.debug.modloader.forge")); + LOG.info("Please make sure to check the configuration for the used Fabric version after ServerPackCreator is done setting up the modpack and new config file."); configurationModel.setModLoader("Fabric"); configurationModel.setModLoaderVersion(VERSIONMETA.fabric().releaseLoaderVersion()); @@ -565,7 +504,7 @@ public class ConfigUtilities { } else { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.debug(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.debug.modloader.forge")); + LOG.debug("Setting modloader to Forge."); configurationModel.setModLoader("Forge"); configurationModel.setModLoaderVersion(modloaderAndVersion[1]); @@ -734,8 +673,7 @@ public class ConfigUtilities { */ public List<String> suggestCopyDirs(String modpackDir) { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.suggestcopydirs.start")); + LOG.info("Preparing a list of directories to include in server pack..."); File[] listDirectoriesInModpack = new File(modpackDir).listFiles(); @@ -754,9 +692,7 @@ public class ConfigUtilities { np); } - for (int idirs = 0; - idirs < APPLICATIONPROPERTIES.getDirectoriesToExclude().size(); - idirs++) { + for (int idirs = 0; idirs < APPLICATIONPROPERTIES.getDirectoriesToExclude().size(); idirs++) { int i = idirs; @@ -764,10 +700,7 @@ public class ConfigUtilities { n -> (n.contains(APPLICATIONPROPERTIES.getDirectoriesToExclude().get(i)))); } - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.suggestcopydirs.list"), - dirsInModpack)); + LOG.info("Modpack directory checked. Suggested directories for copyDirs-setting are: " + dirsInModpack); return dirsInModpack; } @@ -783,7 +716,7 @@ public class ConfigUtilities { * @author Griefed */ public boolean checkCurseForgeJsonForFabric(JsonNode modpackJson) { - + // TODO check ids for Fabric API loader thingy for (int i = 0; i < modpackJson.get("files").size(); i++) { LOG.debug( @@ -795,7 +728,7 @@ public class ConfigUtilities { || modpackJson.get("files").get(i).get("fileID").asText().equalsIgnoreCase("306612")) { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.containsfabric")); + LOG.info("Fabric detected. Setting modloader to \"Fabric\"."); return true; } } diff --git a/backend/main/java/de/griefed/serverpackcreator/utilities/ConfigurationCreator.java b/backend/main/java/de/griefed/serverpackcreator/utilities/ConfigurationCreator.java index 2f5ecda84938d61ebfc8e330701bba26c103a0f8..175de12dd01203e678bd291e93b8e4a912b84ad4 100644 --- a/backend/main/java/de/griefed/serverpackcreator/utilities/ConfigurationCreator.java +++ b/backend/main/java/de/griefed/serverpackcreator/utilities/ConfigurationCreator.java @@ -21,7 +21,7 @@ package de.griefed.serverpackcreator.utilities; import de.griefed.serverpackcreator.ApplicationProperties; import de.griefed.serverpackcreator.ConfigurationHandler; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.utilities.common.Utilities; import de.griefed.serverpackcreator.utilities.misc.Generated; import de.griefed.serverpackcreator.versionmeta.VersionMeta; @@ -45,7 +45,7 @@ public class ConfigurationCreator { private static final Logger LOG = LogManager.getLogger(ConfigurationCreator.class); - private final LocalizationManager LOCALIZATIONMANAGER; + private final I18n I18N; private final ConfigurationHandler CONFIGURATIONHANDLER; private final ApplicationProperties APPLICATIONPROPERTIES; private final VersionMeta VERSIONMETA; @@ -53,7 +53,7 @@ public class ConfigurationCreator { private final ConfigUtilities CONFIGUTILITIES; public ConfigurationCreator( - LocalizationManager injectedLocalizationManager, + I18n injectedI18n, ConfigurationHandler injectedConfigurationHandler, ApplicationProperties injectedApplicationProperties, Utilities injectedUtilities, @@ -67,10 +67,10 @@ public class ConfigurationCreator { this.APPLICATIONPROPERTIES = injectedApplicationProperties; } - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + if (injectedI18n == null) { + this.I18N = new I18n(APPLICATIONPROPERTIES); } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; + this.I18N = injectedI18n; } if (injectedVersionMeta == null) { @@ -87,14 +87,14 @@ public class ConfigurationCreator { } if (injectedUtilities == null) { - this.UTILITIES = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + this.UTILITIES = new Utilities(I18N, APPLICATIONPROPERTIES); } else { this.UTILITIES = injectedUtilities; } if (injectedConfigUtilities == null) { this.CONFIGUTILITIES = - new ConfigUtilities(LOCALIZATIONMANAGER, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); + new ConfigUtilities(I18N, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); } else { this.CONFIGUTILITIES = injectedConfigUtilities; } @@ -102,7 +102,7 @@ public class ConfigurationCreator { if (injectedConfigurationHandler == null) { this.CONFIGURATIONHANDLER = new ConfigurationHandler( - LOCALIZATIONMANAGER, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); + I18N, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); } else { this.CONFIGURATIONHANDLER = injectedConfigurationHandler; } @@ -155,98 +155,71 @@ public class ConfigurationCreator { Scanner reader = new Scanner(System.in); - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.start"), "-cgen")); + "You started ServerPackCreator with the \"-cgen\" argument. Step-by-step generation of config file initiated..."); do { - // --------------------------------------------------------------------------------------------MODPACK DIRECTORY--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.modpack.enter")); - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.modpack.example")); + // -----------------------------------------------------------------MODPACK DIRECTORY--------- + + LOG.info("Please enter your modpack path. This path can be relative to ServerPackCreator, or absolute."); + LOG.info("Example: \"./Some Modpack\" or \"C:/Minecraft/Some Modpack\""); do { do { - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.modpack.cli") + " "); + System.out.print("Path to modpack directory: "); tmpModpackDir = reader.nextLine(); } while (!CONFIGURATIONHANDLER.checkModpackDir(tmpModpackDir, encounteredErrors)); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - tmpModpackDir)); - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.modpack.checkreturninfo")); + LOG.info("You entered: " + tmpModpackDir); + LOG.info("If you are satisfied with this setting, enter ture. If not, enter false to restart modpack directory configuration."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.answer") + " "); + System.out.print("Answer: "); } while (!UTILITIES.BooleanUtils().readBoolean()); modpackDir = tmpModpackDir.replace("\\", "/"); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - modpackDir)); + + LOG.info("You entered: " + modpackDir); System.out.println(); - // -----------------------------------------------------------------------------------------CLIENTSIDE-ONLY MODS--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.clientmods.enter")); + // --------------------------------------------------------------CLIENTSIDE-ONLY MODS--------- + + LOG.info("Enter filenames of clientside-only mods, one per line. When you are done, simply press enter with empty input."); do { clientMods.clear(); clientMods.addAll(UTILITIES.ListUtils().readStringArray()); /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - clientMods)); + LOG.info("You entered: " + clientMods); if (clientMods.isEmpty()) { clientMods = APPLICATIONPROPERTIES.getListFallbackMods(); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.warn.checkconfig.clientmods")); + LOG.warn("No clientside-only mods specified. Using fallback list."); for (String mod : clientMods) { LOG.warn(String.format(" %s", mod)); } } - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.clientmods.checkreturninfo")); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.answer") + " "); + LOG.info("If you are satisfied with these values, enter true. If not, enter false to restart clientmod configuration."); + + System.out.print("Answer: "); } while (!UTILITIES.BooleanUtils().readBoolean()); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - clientMods)); + LOG.info("You entered: " + clientMods); tmpClientMods = new String[clientMods.size()]; clientMods.toArray(tmpClientMods); System.out.println(); - // ------------------------------------------------------------------DIRECTORIES OR FILES TO - // COPY TO SERVER PACK--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.copydirs.enter")); + // ---------------------------------------DIRECTORIES OR FILES TO COPY TO SERVER PACK--------- + + LOG.info("Which directories or files should be copied to the server pack? These are folder- or filenames inside your modpack directory or explicit source/file;destination/file-combinations."); List<String> dirList = Arrays.asList( @@ -254,296 +227,190 @@ public class ConfigurationCreator { new File(modpackDir) .list((current, name) -> new File(current, name).isDirectory()))); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.copydirs.dirsinmodpack"), - dirList.toString().replace("[", "").replace("]", ""))); + LOG.info("The modpack directory you specified contains the following directories: " + UTILITIES.StringUtils().buildString(dirList)); + do { do { copyDirs.clear(); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.copydirs.specify")); + + LOG.info("Specify your directories and files you want to be copied:"); copyDirs.addAll(UTILITIES.ListUtils().readStringArray()); } while (!CONFIGURATIONHANDLER.checkCopyDirs(copyDirs, modpackDir, encounteredErrors)); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - copyDirs)); - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.copydirs.checkreturninfo")); + LOG.info("You entered: " + copyDirs); + LOG.info("If you are satisfied with these values, enter true. If not, enter false to restart clientmod configuration."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.answer") + " "); + System.out.print("Answer: "); } while (!UTILITIES.BooleanUtils().readBoolean()); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - copyDirs)); + LOG.info("You entered: " + copyDirs); tmpCopyDirs = new String[copyDirs.size()]; copyDirs.toArray(tmpCopyDirs); System.out.println(); - // ---------------------------------------------------------------------------PATH TO THE - // CUSTOM SERVER-ICON.PNG--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.custom.icon.enter")); + // ------------------------------------------------PATH TO THE CUSTOM SERVER-ICON.PNG--------- + + LOG.info("Enter the path to your custom server-icon.png-file, if you want to include one. Leave blank if you are fine with the default."); do { do { - /* This log is meant to be read by the user, therefore we allow translation. */ - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.custom.icon.path")); + System.out.print("Path to your server-icon.png: "); tmpServerIcon = reader.nextLine(); } while (!CONFIGURATIONHANDLER.checkIconAndProperties(tmpServerIcon)); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - tmpServerIcon)); - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.custom.icon.end")); - - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.answer") + " "); + LOG.info("You entered: " + tmpServerIcon); + LOG.info("If you are satisfied with this setting, enter ture. If not, enter false to restart server-icon.png configuration."); + System.out.print("Answer: "); } while (!UTILITIES.BooleanUtils().readBoolean()); serverIconPath = tmpServerIcon.replace("\\", "/"); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - serverIconPath)); + + LOG.info("You entered: " + serverIconPath); System.out.println(); - // -------------------------------------------------------------------------PATH TO THE CUSTOM - // SERVER.PROPERTIES--------- + //-----------------------------------------------PATH TO THE CUSTOM SERVER.PROPERTIES--------- - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.custom.properties.enter")); + LOG.info("Enter the path to your custom server.properties-file, if you want to include one. Leave blank if you are fine with the default."); do { do { - /* This log is meant to be read by the user, therefore we allow translation. */ - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.custom.properties.path")); + + System.out.print("Path to your server.properties: "); tmpServerProperties = reader.nextLine(); } while (!CONFIGURATIONHANDLER.checkIconAndProperties(tmpServerProperties)); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - tmpServerProperties)); - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.custom.properties.end")); + LOG.info("You entered: " + tmpServerProperties); + LOG.info("If you are satisfied with this setting, enter ture. If not, enter false to restart server-icon.png configuration."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.answer") + " "); + System.out.print("Answer: "); } while (!UTILITIES.BooleanUtils().readBoolean()); serverPropertiesPath = tmpServerProperties.replace("\\", "/"); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - serverPropertiesPath)); + + LOG.info("You entered: " + serverPropertiesPath); System.out.println(); - // -------------------------------------------------------------WHETHER TO INCLUDE MODLOADER - // SERVER INSTALLATION--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.server.enter")); + // ----------------------------------WHETHER TO INCLUDE MODLOADER SERVER INSTALLATION--------- + + LOG.info("Do you want ServerPackCreator to install the modloader server for your server pack? Must be true or false."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.server.include") + " "); + System.out.print("Include modloader server installation: "); includeServerInstallation = UTILITIES.BooleanUtils().readBoolean(); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - includeServerInstallation)); + LOG.info("You entered: " + includeServerInstallation); - // -------------------------------------------------------------------------------MINECRAFT - // VERSION MODPACK USES--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.minecraft.enter")); + // ----------------------------------------------------MINECRAFT VERSION MODPACK USES--------- + LOG.info("Which version of Minecraft does your modpack use?"); do { - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.minecraft.specify") - + " "); + System.out.print("Minecraft version: "); minecraftVersion = reader.nextLine(); } while (!VERSIONMETA.minecraft().checkMinecraftVersion(minecraftVersion)); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - minecraftVersion)); + LOG.info("You entered: " + minecraftVersion); System.out.println(); - // ---------------------------------------------------------------------------------------MODLOADER MODPACK USES--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.modloader.enter")); + // ------------------------------------------------------------MODLOADER MODPACK USES--------- + + LOG.info("What modloader does your modpack use?"); do { - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.modloader.cli") + " "); + System.out.print("Modloader: "); modLoader = reader.nextLine(); } while (!CONFIGURATIONHANDLER.checkModloader(modLoader)); modLoader = CONFIGUTILITIES.getModLoaderCase(modLoader); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - modLoader)); + LOG.info("You entered: " + modLoader); System.out.println(); - // ----------------------------------------------------------------------------VERSION OF - // MODLOADER MODPACK USES--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString( - "configuration.log.info.modloaderversion.enter"), - modLoader)); + // -------------------------------------------------VERSION OF MODLOADER MODPACK USES--------- + LOG.info("What version of " + modLoader + " does your modpack use?"); do { - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.modloaderversion.cli") - + " "); + System.out.print("Modloader version: "); modLoaderVersion = reader.nextLine(); } while (!CONFIGURATIONHANDLER.checkModloaderVersion( modLoader, modLoaderVersion, minecraftVersion)); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - modLoaderVersion)); + LOG.info("You entered: " + modLoaderVersion); System.out.println(); - // ------------------------------------------------------------------------------------PATH TO - // JAVA INSTALLATION--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.java.enter")); - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.java.enter2")); - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.java.example")); + // ---------------------------------------------------------PATH TO JAVA INSTALLATION--------- + LOG.info( + "Specify the path to your Java installation. Must end with \"java\" on Linux, or \"java.exe\" on Windows."); + LOG.info("If you leave this empty, ServerPackCreator will try to determine the path for you."); + LOG.info("Example Linux: /usr/bin/java | Example Windows: C:/Program Files/AdoptOpenJDK/jdk-8.0.275.1-hotspot/jre/bin/java.exe"); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.java.cli") + " "); + System.out.print("Path to your Java installation: "); javaPath = CONFIGURATIONHANDLER.getJavaPath(reader.nextLine()); - //noinspection RedundantStringFormatCall - System.out.println( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.warn.getjavapath.set"), - javaPath)); + System.out.println("Automatically acquired path to Java installation: " + javaPath); System.out.println(); - // ------------------------------------------------------------WHETHER TO INCLUDE - // SERVER-ICON.PNG IN SERVER PACK--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.icon.enter")); + // ---------------------------------WHETHER TO INCLUDE SERVER-ICON.PNG IN SERVER PACK--------- + + LOG.info("Do you want ServerPackCreator to include a server-icon in your server pack? Must be true or false."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.icon.cli") + " "); + System.out.print("Include server-icon.png: "); includeServerIcon = UTILITIES.BooleanUtils().readBoolean(); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - includeServerIcon)); + LOG.info("You entered: " + includeServerIcon); System.out.println(); - // ----------------------------------------------------------WHETHER TO INCLUDE - // SERVER.PROPERTIES IN SERVER PACK--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.properties.enter")); + // -------------------------------WHETHER TO INCLUDE SERVER.PROPERTIES IN SERVER PACK--------- + + LOG.info("Do you want ServerPackCreator to include a server.properties in your server pack? Must be true or false."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.properties.cli") + " "); + System.out.print("Include server.properties: "); includeServerProperties = UTILITIES.BooleanUtils().readBoolean(); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - includeServerProperties)); + LOG.info("You entered: " + includeServerProperties); System.out.println(); - // ----------------------------------------------------WHETHER TO INCLUDE CREATION OF - // ZIP-ARCHIVE OF SERVER PACK--------- - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.zip.enter")); + // -------------------------WHETHER TO INCLUDE CREATION OF ZIP-ARCHIVE OF SERVER PACK--------- + LOG.info("Do you want ServerPackCreator to create a ZIP-archive of your server pack? Must be true or false."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.zip.cli") + " "); + System.out.print("Create ZIP-archive: "); includeZipCreation = UTILITIES.BooleanUtils().readBoolean(); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.checkreturn"), - includeZipCreation)); + LOG.info("You entered: " + includeZipCreation); - // -------------------------------------------------------------------------JAVA ARGS TO - // EXECUTE THE SERVER WITH--------- + // ----------------------------------------------JAVA ARGS TO EXECUTE THE SERVER WITH--------- - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.javaargs.cli")); + LOG.info("Specify the Java arguments, if any, to execute the server with. Can be left blank."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.javaargs.enter")); + System.out.print("Java args: "); javaArgs = reader.nextLine(); if (javaArgs.isEmpty()) { javaArgs = "empty"; } - LOG.info( - String.format( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.printconfig.javaargs"), - javaArgs)); + LOG.info("Java arguments for start-scripts: " + javaArgs); - // ------------------------------------------------------------------------------SUFFIX TO - // APPEND TO SERVER PACK--------- + // ---------------------------------------------------SUFFIX TO APPEND TO SERVER PACK--------- - LOG.info( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.serverpacksuffix.cli")); + LOG.info("Enter the suffix you want to append to your server pack. Can be left empty."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.serverpacksuffix.enter")); + System.out.print("Server pack suffix: "); serverPackSuffix = reader.nextLine(); - // ------------------------------------------------------------------------------PRINT CONFIG - // TO CONSOLE AND LOG--------- + // ---------------------------------------------------PRINT CONFIG TO CONSOLE AND LOG--------- CONFIGUTILITIES.printConfigurationModel( modpackDir, clientMods, @@ -561,17 +428,15 @@ public class ConfigurationCreator { serverIconPath, serverPropertiesPath); - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.config.enter")); + LOG.info("If you are satisfied with these values, enter true. If not, enter false to restart config generation."); - System.out.print( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.answer") + " "); + System.out.print("Answer: "); } while (!UTILITIES.BooleanUtils().readBoolean()); reader.close(); - // -----------------------------------------------------------------------------------------WRITE CONFIG TO FILE--------- + // ----------------------------------------------------------------WRITE CONFIG TO FILE--------- if (CONFIGUTILITIES.writeConfigToFile( modpackDir, Arrays.asList(tmpClientMods), @@ -589,8 +454,8 @@ public class ConfigurationCreator { javaArgs, serverPackSuffix, APPLICATIONPROPERTIES.DEFAULT_CONFIG())) { - /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.info(LOCALIZATIONMANAGER.getLocalizedString("configuration.log.info.config.written")); + + LOG.info("New config file successfully written. Thanks go to Whitebear60 for initially writing the CLI-Config-Generation."); } } } diff --git a/backend/main/java/de/griefed/serverpackcreator/utilities/common/BooleanUtilities.java b/backend/main/java/de/griefed/serverpackcreator/utilities/common/BooleanUtilities.java index 023469967e2f18b9854c8675143290cd6f3bf228..a4b1332a10736c45f9675f563e5aa7b888763c56 100644 --- a/backend/main/java/de/griefed/serverpackcreator/utilities/common/BooleanUtilities.java +++ b/backend/main/java/de/griefed/serverpackcreator/utilities/common/BooleanUtilities.java @@ -20,7 +20,7 @@ package de.griefed.serverpackcreator.utilities.common; import de.griefed.serverpackcreator.ApplicationProperties; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.utilities.misc.Generated; import java.util.Scanner; import org.apache.logging.log4j.LogManager; @@ -34,24 +34,9 @@ import org.apache.logging.log4j.Logger; public class BooleanUtilities { private static final Logger LOG = LogManager.getLogger(BooleanUtilities.class); - private final LocalizationManager LOCALIZATIONMANAGER; - private final ApplicationProperties APPLICATIONPROPERTIES; - public BooleanUtilities( - LocalizationManager injectedLocalizationManager, - ApplicationProperties injectedApplicationProperties) { + public BooleanUtilities() { - if (injectedApplicationProperties == null) { - this.APPLICATIONPROPERTIES = new ApplicationProperties(); - } else { - this.APPLICATIONPROPERTIES = injectedApplicationProperties; - } - - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); - } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; - } } /** @@ -85,25 +70,18 @@ public class BooleanUtilities { if (stringBoolean.matches("[Tt]rue") || stringBoolean.matches("1") || stringBoolean.matches("[Yy]es") - || stringBoolean.matches("[Yy]") - || stringBoolean.matches(LOCALIZATIONMANAGER.getLocalizedString("cli.input.true")) - || stringBoolean.matches(LOCALIZATIONMANAGER.getLocalizedString("cli.input.yes")) - || stringBoolean.matches(LOCALIZATIONMANAGER.getLocalizedString("cli.input.yes.short"))) { + || stringBoolean.matches("[Yy]")) { return true; } else if (stringBoolean.matches("[Ff]alse") || stringBoolean.matches("0") || stringBoolean.matches("[Nn]o") - || stringBoolean.matches("[Nn]") - || stringBoolean.matches(LOCALIZATIONMANAGER.getLocalizedString("cli.input.false")) - || stringBoolean.matches(LOCALIZATIONMANAGER.getLocalizedString("cli.input.no")) - || stringBoolean.matches(LOCALIZATIONMANAGER.getLocalizedString("cli.input.no.short"))) { + || stringBoolean.matches("[Nn]")) { return false; } else { /* This log is meant to be read by the user, therefore we allow translation. */ - LOG.warn( - LOCALIZATIONMANAGER.getLocalizedString("configuration.log.warn.converttoboolean.warn")); + LOG.warn("Warning. Couldn't parse boolean. Assuming false."); return false; } } diff --git a/backend/main/java/de/griefed/serverpackcreator/utilities/common/FileUtilities.java b/backend/main/java/de/griefed/serverpackcreator/utilities/common/FileUtilities.java index 8b53156ca715447832cbc1da0019cb629c55e81c..2c9ff1ba6854c16ebd829a104319dcddee34b186 100644 --- a/backend/main/java/de/griefed/serverpackcreator/utilities/common/FileUtilities.java +++ b/backend/main/java/de/griefed/serverpackcreator/utilities/common/FileUtilities.java @@ -75,7 +75,6 @@ public class FileUtilities { * @author Griefed */ public void unzipArchive(String zipFile, String destinationDirectory) { - /* This log is meant to be read by the user, therefore we allow translation. */ LOG.info("Extracting ZIP-file: " + zipFile); try (ZipFile zip = new ZipFile(zipFile)) { diff --git a/backend/main/java/de/griefed/serverpackcreator/utilities/common/JarUtilities.java b/backend/main/java/de/griefed/serverpackcreator/utilities/common/JarUtilities.java index b5c35c1e6daeee8037a1d45bc23c71b70ef565b3..409fa8ab40c827cc200b9b258779355064477986 100644 --- a/backend/main/java/de/griefed/serverpackcreator/utilities/common/JarUtilities.java +++ b/backend/main/java/de/griefed/serverpackcreator/utilities/common/JarUtilities.java @@ -205,8 +205,8 @@ public class JarUtilities { * <br> * Example for dev-environment: <code>G:/GitLab/ServerPackCreator/build/classes/java/main * </code><br> - * See {@link ServerPackCreator#main(String[])} source code for an example on how this is acquired - * automatically. + * See {@link ServerPackCreator#main(String[])} source code for an example on how this is + * acquired automatically. * @param directoryToCopy String. Path to the directory inside the JAR-file you want to copy. * @param destinationDirectory String. Path to the destination directory you want to copy source * to. diff --git a/backend/main/java/de/griefed/serverpackcreator/utilities/common/Utilities.java b/backend/main/java/de/griefed/serverpackcreator/utilities/common/Utilities.java index fb08984aebdf464e514ea9b3ce706a705b9a2a07..f85e06e96bb20606e6fa661afd7aa4f192b41ee9 100644 --- a/backend/main/java/de/griefed/serverpackcreator/utilities/common/Utilities.java +++ b/backend/main/java/de/griefed/serverpackcreator/utilities/common/Utilities.java @@ -1,7 +1,7 @@ package de.griefed.serverpackcreator.utilities.common; import de.griefed.serverpackcreator.ApplicationProperties; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -23,19 +23,15 @@ public class Utilities { private final WebUtilities WEB_UTILITIES; @Autowired - public Utilities( - LocalizationManager injectedLocalizationManager, - ApplicationProperties injectedApplicationProperties) { + public Utilities(I18n injectedI18n, ApplicationProperties injectedApplicationProperties) { - this.BOOLEAN_UTILITIES = - new BooleanUtilities(injectedLocalizationManager, injectedApplicationProperties); + this.BOOLEAN_UTILITIES = new BooleanUtilities(); this.FILE_UTILITIES = new FileUtilities(); this.JAR_UTILITIES = new JarUtilities(); this.LIST_UTILITIES = new ListUtilities(); this.STRING_UTILITIES = new StringUtilities(); this.SYSTEM_UTILITIES = new SystemUtilities(); - this.WEB_UTILITIES = - new WebUtilities(injectedApplicationProperties, injectedLocalizationManager); + this.WEB_UTILITIES = new WebUtilities(injectedApplicationProperties); } public BooleanUtilities BooleanUtils() { diff --git a/backend/main/java/de/griefed/serverpackcreator/utilities/common/WebUtilities.java b/backend/main/java/de/griefed/serverpackcreator/utilities/common/WebUtilities.java index 34a0cf983f460c7060785bf24765caca19b29c7a..d066ff6515a5cafee2bab053eddc9228a3ecc1c4 100644 --- a/backend/main/java/de/griefed/serverpackcreator/utilities/common/WebUtilities.java +++ b/backend/main/java/de/griefed/serverpackcreator/utilities/common/WebUtilities.java @@ -1,7 +1,7 @@ package de.griefed.serverpackcreator.utilities.common; import de.griefed.serverpackcreator.ApplicationProperties; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import java.awt.Desktop; import java.io.BufferedReader; import java.io.DataOutputStream; @@ -33,23 +33,14 @@ public class WebUtilities { private static final Logger LOG = LogManager.getLogger(WebUtilities.class); private final ApplicationProperties APPLICATIONPROPERTIES; - private final LocalizationManager LOCALIZATIONMANAGER; - public WebUtilities( - ApplicationProperties injectedApplicationProperties, - LocalizationManager injectedLocalizationManager) { + public WebUtilities(ApplicationProperties injectedApplicationProperties) { if (injectedApplicationProperties == null) { this.APPLICATIONPROPERTIES = new ApplicationProperties(); } else { this.APPLICATIONPROPERTIES = injectedApplicationProperties; } - - if (injectedLocalizationManager == null) { - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); - } else { - this.LOCALIZATIONMANAGER = injectedLocalizationManager; - } } /** @@ -321,8 +312,7 @@ public class WebUtilities { if (response.contains(requestURL.replace("/documents", ""))) { return response; } else { - return LOCALIZATIONMANAGER.getLocalizedString( - "createserverpack.log.error.abouttab.hastebin.response"); + return "Error encountered when acquiring response from URL."; } } } diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/VersionMeta.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/VersionMeta.java index cb3a71dd21ade2d14dc83c2423bb63809ea432c9..4e3ec3bf7424dae5b6d6ab1a8a4523fd2c8f40dd 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/VersionMeta.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/VersionMeta.java @@ -60,8 +60,6 @@ public class VersionMeta { new ObjectMapper() .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); - private final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = - DocumentBuilderFactory.newInstance(); private final File MINECRAFT_MANIFEST; private final File FORGE_MANIFEST; @@ -119,8 +117,8 @@ public class VersionMeta { checkManifests(); - this.FORGE_META = new ForgeMeta(forgeManifest); - this.MINECRAFT_META = new MinecraftMeta(minecraftManifest, this.FORGE_META); + this.FORGE_META = new ForgeMeta(forgeManifest, OBJECT_MAPPER); + this.MINECRAFT_META = new MinecraftMeta(minecraftManifest, this.FORGE_META, OBJECT_MAPPER); this.FABRIC_META = new FabricMeta(fabricManifest, fabricInstallerManifest); this.FORGE_META.initialize(this.MINECRAFT_META); this.QUIL_META = new QuiltMeta(quiltManifest, quiltInstallerManifest); @@ -315,12 +313,13 @@ public class VersionMeta { * @author Griefed */ private Document getXml(InputStream manifest) { + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = null; Document xml = null; try { - documentBuilder = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder(); + documentBuilder = documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException ex) { LOG.error("Couldn't read document.", ex); diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricInstaller.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricInstaller.java index b6b56af05c66f206eccafb4fea84c52ef662e5c7..2f823e2b43f1106e68588398a324c45f2083026e 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricInstaller.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricInstaller.java @@ -44,7 +44,7 @@ public class FabricInstaller { private HashMap<String, URL> installerUrlMeta; /** - * Constructor + * Create a new instance of the Fabric Installer. * * @param installerManifest {@link Document} containing Fabric installer information * @author Griefed @@ -103,10 +103,9 @@ public class FabricInstaller { * Update this {@link FabricInstaller} with information from the given {@link Document}. * * @param installerManifest {@link Document} containing new installer information. - * @return This instance of {@link FabricInstaller}. * @author Griefed */ - protected FabricInstaller update(Document installerManifest) { + protected void update(Document installerManifest) { this.latestInstaller = installerManifest .getElementsByTagName("latest") @@ -154,8 +153,6 @@ public class FabricInstaller { } }); - - return this; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricLoader.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricLoader.java index 357be2c0bc1398fc9b7ed1f22f6b28071caa5c87..15946d188974a5920f22b062f67578dec6839b1a 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricLoader.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricLoader.java @@ -35,7 +35,7 @@ public class FabricLoader { private String release; /** - * Constructor + * Create a new instance of the Fabric Loader. * * @param loaderManifest {@link Document} containing Fabrics manifest. * @author Griefed @@ -72,10 +72,9 @@ public class FabricLoader { * Update the latest, release and releases information. * * @param loaderManifest {@link Document} containing Fabrics manifest. - * @return This instance of {@link FabricLoader}. * @author Griefed */ - protected FabricLoader update(Document loaderManifest) { + protected void update(Document loaderManifest) { this.latest = loaderManifest .getElementsByTagName("latest") @@ -100,8 +99,6 @@ public class FabricLoader { .item(0) .getNodeValue()); } - - return this; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricMeta.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricMeta.java index 0ef7e03fbfd5b862be04047c6251475c0e1474a7..6f28f6ed0f26b799172f77fa6dd4ac75fa472292 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricMeta.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/fabric/FabricMeta.java @@ -50,7 +50,7 @@ public class FabricMeta { private final FabricInstaller FABRIC_INSTALLER; /** - * Constructor + * Create a new Fabric Meta instance. * * @param fabricManifest {@link File} Fabric manifest file.. * @param fabricInstallerManifest {@link File} Fabric-installer manifest file.. @@ -66,16 +66,12 @@ public class FabricMeta { /** * Update the {@link FabricLoader} and {@link FabricInstaller} information. * - * @return This instance of {@link FabricMeta}. * @throws MalformedURLException if a URL could not be constructed * @author Griefed */ - public FabricMeta update() throws MalformedURLException { - + public void update() throws MalformedURLException { this.FABRIC_LOADER.update(getXml(this.FABRIC_MANIFEST)); this.FABRIC_INSTALLER.update(getXml(this.FABRIC_INSTALLER_MANIFEST)); - - return this; } private Document getXml(File manifest) { diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeInstance.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeInstance.java index 6a88c327ce89e0fb663ed95f37329cc48d712c65..794c0bbe5392117d919685346268ac877e2f7c6d 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeInstance.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeInstance.java @@ -39,7 +39,7 @@ public class ForgeInstance { private final MinecraftMeta MINECRAFT_META; /** - * Constructor. + * Create a new Forge Instance instance. * * @param minecraftVersion {@link String} Minecraft version. * @param forgeVersion {@link String} Forge version. diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeLoader.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeLoader.java index 2496e10330b7238dc0a02862bbd4552918b54387..bc38a28a6d77591dd865925f1b6fc17eede2ef40 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeLoader.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeLoader.java @@ -64,7 +64,7 @@ public class ForgeLoader { private HashMap<String, ForgeInstance> instanceMeta; /** - * Constructor + * Create a new instance of the Forge Loader. * * @param forgemanifest {@link JsonNode} containing information about available Forge versions. * @param injectedMinecraftMeta {@link MinecraftMeta} for retroactively updating the previously @@ -80,10 +80,9 @@ public class ForgeLoader { * Update the available Forge loader information. * * @param forgeManifest {@link JsonNode} containing information about available Forge versions. - * @return This instance of {@link ForgeLoader}. * @author Griefed */ - protected ForgeLoader update(JsonNode forgeManifest) { + protected void update(JsonNode forgeManifest) { minecraftVersions.clear(); forgeVersions.clear(); @@ -159,8 +158,6 @@ public class ForgeLoader { versionMeta.put(mcVersion, forgeVersionsForMCVer); }); - - return this; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeMeta.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeMeta.java index 42b0b0c06067bc7a1c63d3c6c6cd1d5d205915fc..1c2e3425cf5cd744509635fbe943e52e676f5cde 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeMeta.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/forge/ForgeMeta.java @@ -19,7 +19,6 @@ */ package de.griefed.serverpackcreator.versionmeta.forge; -import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; import de.griefed.serverpackcreator.versionmeta.Type; @@ -39,15 +38,20 @@ import java.util.Optional; public class ForgeMeta { private final File FORGE_MANIFEST; - private final ObjectMapper OBJECTMAPPER = - new ObjectMapper() - .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private final ObjectMapper OBJECTMAPPER; private ForgeLoader forgeLoader; - public ForgeMeta(File forgeManifest) { + /** + * Create a new Forge Meta, using a manifest file. + * + * @param forgeManifest {@link File} The manifest from which to acquire version information. + * @param objectMapper {@link ObjectMapper} for parsing. + * @author Griefed + */ + public ForgeMeta(File forgeManifest, ObjectMapper objectMapper) { this.FORGE_MANIFEST = forgeManifest; + this.OBJECTMAPPER = objectMapper; } /** @@ -70,15 +74,12 @@ public class ForgeMeta { * Update this instances {@link ForgeLoader} with new information. Usually called after the Forge * manifest has been refreshed. * - * @return This instance of {@link ForgeMeta} * @throws IOException if the manifest could not be parsed into a {@link * com.fasterxml.jackson.databind.JsonNode}. * @author Griefed */ - public ForgeMeta update() throws IOException { + public void update() throws IOException { this.forgeLoader.update(OBJECTMAPPER.readTree(this.FORGE_MANIFEST)); - - return this; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftClient.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftClient.java index 8385ae727a4f7906a42070509e519d778bcca7fe..8b9ca238bcad6f48e766601611936035a59ca99e 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftClient.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftClient.java @@ -19,14 +19,13 @@ */ package de.griefed.serverpackcreator.versionmeta.minecraft; +import com.fasterxml.jackson.databind.ObjectMapper; import de.griefed.serverpackcreator.versionmeta.Type; import de.griefed.serverpackcreator.versionmeta.forge.ForgeInstance; import de.griefed.serverpackcreator.versionmeta.forge.ForgeMeta; import java.net.URL; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; /** * Relevant information about a given Minecraft client. @@ -35,13 +34,11 @@ import org.apache.logging.log4j.Logger; */ public class MinecraftClient { - private static final Logger LOG = LogManager.getLogger(MinecraftClient.class); - private final String VERSION; private final Type TYPE; private final URL URL; private final MinecraftServer MINECRAFT_SERVER; - private ForgeMeta FORGE_META; + private final ForgeMeta FORGE_META; /** * Constructor using version, type and url. @@ -51,14 +48,16 @@ public class MinecraftClient { * @param url {@link URL} Url to this versions manifest. * @param forgeMeta {@link ForgeMeta} to acquire Forge instances for this {@link MinecraftClient} * version. + * @param objectMapper {@link ObjectMapper} for parsing. * @author Griefed */ - protected MinecraftClient(String version, Type type, URL url, ForgeMeta forgeMeta) { + protected MinecraftClient( + String version, Type type, URL url, ForgeMeta forgeMeta, ObjectMapper objectMapper) { this.VERSION = version; this.TYPE = type; this.URL = url; this.FORGE_META = forgeMeta; - this.MINECRAFT_SERVER = new MinecraftServer(version, type, url); + this.MINECRAFT_SERVER = new MinecraftServer(version, type, url, objectMapper); } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftClientMeta.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftClientMeta.java index d425c9222e8c27c42ccf6ec54778233170331384..909da75cf3c56f6093ce36d8aa71d0a94f8e56e6 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftClientMeta.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftClientMeta.java @@ -19,7 +19,6 @@ */ package de.griefed.serverpackcreator.versionmeta.minecraft; -import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import de.griefed.serverpackcreator.versionmeta.Type; @@ -41,10 +40,7 @@ import org.apache.logging.log4j.Logger; public class MinecraftClientMeta { private static final Logger LOG = LogManager.getLogger(MinecraftClientMeta.class); - private final ObjectMapper OBJECTMAPPER = - new ObjectMapper() - .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private final ObjectMapper OBJECTMAPPER; private final ForgeMeta FORGE_META; private final File MINECRAFT_MANIFEST; @@ -56,26 +52,28 @@ public class MinecraftClientMeta { private HashMap<String, MinecraftClient> meta = new HashMap<>(); /** - * Constructor. + * Create a new Minecraft Client Meta. * * @param injectedForgeMeta {@link ForgeMeta} to acquire Forge instances for this {@link * MinecraftClient} version. * @param minecraftManifest {@link File} Minecraft manifest file. + * @param objectMapper {@link ObjectMapper} for parsing. * @author Griefed */ - protected MinecraftClientMeta(File minecraftManifest, ForgeMeta injectedForgeMeta) { + protected MinecraftClientMeta( + File minecraftManifest, ForgeMeta injectedForgeMeta, ObjectMapper objectMapper) { this.MINECRAFT_MANIFEST = minecraftManifest; this.FORGE_META = injectedForgeMeta; + this.OBJECTMAPPER = objectMapper; } /** * Update the meta information. * - * @return This instance of {@link MinecraftClientMeta} * @throws IOException if the manifest could not be read. * @author Griefed */ - protected MinecraftClientMeta update() throws IOException { + protected void update() throws IOException { RELEASES.clear(); SNAPSHOTS.clear(); @@ -95,7 +93,8 @@ public class MinecraftClientMeta { minecraftVersion.get("id").asText(), Type.RELEASE, new URL(minecraftVersion.get("url").asText()), - this.FORGE_META)); + this.FORGE_META, + OBJECTMAPPER)); } catch (IOException ex) { LOG.debug( "No server available for MinecraftClient version " @@ -111,7 +110,8 @@ public class MinecraftClientMeta { minecraftVersion.get("id").asText(), Type.SNAPSHOT, new URL(minecraftVersion.get("url").asText()), - this.FORGE_META)); + this.FORGE_META, + OBJECTMAPPER)); } catch (IOException ex) { LOG.debug( "No server available for MinecraftClient version " @@ -138,8 +138,6 @@ public class MinecraftClientMeta { meta.get(minecraftManifest.get("latest").get("snapshot").asText()).url(), meta.get(minecraftManifest.get("latest").get("snapshot").asText()).server(), this.FORGE_META); - - return this; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftMeta.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftMeta.java index 0e2dc6d120b0003a82b52f30aa7746e128d24030..0d4ab53073b006914e9861be92b19e7703710095 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftMeta.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftMeta.java @@ -19,6 +19,7 @@ */ package de.griefed.serverpackcreator.versionmeta.minecraft; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; import de.griefed.serverpackcreator.versionmeta.Type; import de.griefed.serverpackcreator.versionmeta.forge.ForgeMeta; @@ -35,22 +36,22 @@ import java.util.Optional; */ public class MinecraftMeta { - private final File MINECRAFT_MANIFEST; private final MinecraftClientMeta MINECRAFT_CLIENT_META; private final MinecraftServerMeta MINECRAFT_SERVER_META; /** - * Constructor. + * Create a new Minecraft Meta instance. * * @param minecraftManifest {@link File} Minecraft manifest file. * @param injectedForgeMeta {@link ForgeMeta} to acquire Forge instances for this {@link * MinecraftClient} version. + * @param objectMapper {@link ObjectMapper} for parsing. * @author Griefed */ - public MinecraftMeta(File minecraftManifest, ForgeMeta injectedForgeMeta) { - this.MINECRAFT_MANIFEST = minecraftManifest; + public MinecraftMeta( + File minecraftManifest, ForgeMeta injectedForgeMeta, ObjectMapper objectMapper) { this.MINECRAFT_CLIENT_META = - new MinecraftClientMeta(this.MINECRAFT_MANIFEST, injectedForgeMeta); + new MinecraftClientMeta(minecraftManifest, injectedForgeMeta, objectMapper); this.MINECRAFT_SERVER_META = new MinecraftServerMeta(this.MINECRAFT_CLIENT_META); } @@ -58,14 +59,12 @@ public class MinecraftMeta { * Update the {@link MinecraftClientMeta} and {@link MinecraftServerMeta}. Usually called after * the manifest-files have been refreshed. * - * @return This instance of {@link MinecraftMeta}. * @throws IOException if the {@link MinecraftClientMeta} could not be initialized. * @author Griefed */ - public MinecraftMeta update() throws IOException { + public void update() throws IOException { this.MINECRAFT_CLIENT_META.update(); this.MINECRAFT_SERVER_META.update(); - return this; } /* diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftServer.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftServer.java index 1a51045edc7f4f2086cbe3f7adb98ed92dcb03c5..d6f4f16394862ce1b9a0deb29c816fc4c2255664 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftServer.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftServer.java @@ -19,7 +19,6 @@ */ package de.griefed.serverpackcreator.versionmeta.minecraft; -import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import de.griefed.serverpackcreator.versionmeta.Type; @@ -35,10 +34,7 @@ import java.util.Optional; */ public class MinecraftServer { - private final ObjectMapper OBJECT_MAPPER = - new ObjectMapper() - .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private final ObjectMapper OBJECT_MAPPER; private final URL MANIFEST_URL; private final String VERSION; private final Type TYPE; @@ -46,21 +42,28 @@ public class MinecraftServer { private JsonNode serverJson = null; /** - * Constructor + * Create a new Minecraft Server. * * @param mcVersion {@link String} The Minecraft version of this server. * @param mcType {@link Type} The release-type of this server. Either {@link Type#RELEASE} or * {@link Type#SNAPSHOT}. * @param mcUrl {@link URL} The URL to the download of this servers JAR-file. + * @param objectMapper {@link ObjectMapper} for parsing. * @author Griefed */ - protected MinecraftServer(String mcVersion, Type mcType, URL mcUrl) { + protected MinecraftServer(String mcVersion, Type mcType, URL mcUrl, ObjectMapper objectMapper) { this.MANIFEST_URL = mcUrl; this.VERSION = mcVersion; this.TYPE = mcType; + this.OBJECT_MAPPER = objectMapper; } - private void setServerJson() { + /** + * Read and store the server manifest. + * + * @author Griefed + */ + protected void setServerJson() { try { this.serverJson = OBJECT_MAPPER.readTree(MANIFEST_URL.openStream()); } catch (IOException e) { diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftServerMeta.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftServerMeta.java index 209b7001a25e65cd5bb5d1f937728307d2ec433a..2ce07454c7c510b874f477cc0d61de4e2bcfded3 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftServerMeta.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/minecraft/MinecraftServerMeta.java @@ -37,7 +37,7 @@ class MinecraftServerMeta { private HashMap<String, MinecraftServer> meta; /** - * Constructor. + * Create a new Minecraft Server Meta instance. * * @param minecraftClientMeta Instance of {@link MinecraftClientMeta}. * @author Griefed @@ -49,10 +49,9 @@ class MinecraftServerMeta { /** * Update this instance of {@link MinecraftServerMeta} with new information. * - * @return This instance of {@link MinecraftServerMeta}. * @author Griefed */ - protected MinecraftServerMeta update() { + protected void update() { this.RELEASES.clear(); MINECRAFT_CLIENT_META.releases().forEach(client -> this.RELEASES.add(client.server())); @@ -67,8 +66,6 @@ class MinecraftServerMeta { MINECRAFT_CLIENT_META .snapshots() .forEach(client -> this.meta.put(client.version(), client.server())); - - return this; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltInstaller.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltInstaller.java index a2e1fe95c2ad7c1af588ad09dc7bd31618492d21..1efcdd7535ffdadf3da662c5d85a986a91165247 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltInstaller.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltInstaller.java @@ -43,7 +43,7 @@ public class QuiltInstaller { private HashMap<String, URL> installerUrlMeta; /** - * Constructor + * Create a new Quilt Installer instance. * * @param installerManifest {@link Document} containing Quilt installer information * @author Griefed @@ -102,10 +102,9 @@ public class QuiltInstaller { * Update this {@link QuiltInstaller} with information from the given {@link Document}. * * @param installerManifest {@link Document} containing new installer information. - * @return This instance of {@link QuiltInstaller}. * @author Griefed */ - protected QuiltInstaller update(Document installerManifest) { + protected void update(Document installerManifest) { this.latestInstaller = installerManifest .getElementsByTagName("latest") @@ -153,8 +152,6 @@ public class QuiltInstaller { } }); - - return this; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltLoader.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltLoader.java index e110f9f72a8c964b21514537c3dd8c976b9d787e..e7dc01481db8278aaeb1956089f096092ed05f29 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltLoader.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltLoader.java @@ -35,7 +35,7 @@ public class QuiltLoader { private String release; /** - * Constructor + * Create a new Quilt Loader instance. * * @param loaderManifest {@link Document} containing Quilts manifest. * @author Griefed @@ -72,10 +72,9 @@ public class QuiltLoader { * Update the latest, release and releases information. * * @param loaderManifest {@link Document} containing Quilts manifest. - * @return This instance of {@link QuiltLoader}. * @author Griefed */ - protected QuiltLoader update(Document loaderManifest) { + protected void update(Document loaderManifest) { this.latest = loaderManifest .getElementsByTagName("latest") @@ -100,8 +99,6 @@ public class QuiltLoader { .item(0) .getNodeValue()); } - - return this; } /** diff --git a/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltMeta.java b/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltMeta.java index 1de51a5e562eb12e932e8549fb710a9269b03259..860bc3529fab4ad87d803fb05b48a7f08bbe54a9 100644 --- a/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltMeta.java +++ b/backend/main/java/de/griefed/serverpackcreator/versionmeta/quilt/QuiltMeta.java @@ -50,7 +50,7 @@ public class QuiltMeta { private final QuiltInstaller QUILT_INSTALLER; /** - * Constructor + * Create a new Quilt Meta instance. * * @param quiltManifest {@link File} Quilt manifest file.. * @param quiltInstallerManifest {@link File} Quilt-installer manifest file.. @@ -66,16 +66,12 @@ public class QuiltMeta { /** * Update the {@link QuiltLoader} and {@link QuiltInstaller} information. * - * @return This instance of {@link QuiltMeta}. * @throws MalformedURLException if a URL could not be constructed * @author Griefed */ - public QuiltMeta update() throws MalformedURLException { - + public void update() throws MalformedURLException { this.QUILT_LOADER.update(getXml(this.QUILT_MANIFEST)); this.QUILT_INSTALLER.update(getXml(this.QUILT_INSTALLER_MANIFEST)); - - return this; } private Document getXml(File manifest) { diff --git a/backend/main/resources/CHANGELOG.md b/backend/main/resources/CHANGELOG.md index 020ec99323eb480d09597c04a6218d4082930fbd..3acc83e9ff93482180019ada4e2585c24f2bf855 100644 --- a/backend/main/resources/CHANGELOG.md +++ b/backend/main/resources/CHANGELOG.md @@ -1,3 +1,15 @@ +## [3.7.0](https://git.griefed.de/Griefed/ServerPackCreator/compare/3.6.0...3.7.0) (2022-06-29) + + +### 💎 Improvements + +* **Start scripts:** Various improvements, additions and fixes to the start scripts ([204ac6e](https://git.griefed.de/Griefed/ServerPackCreator/commit/204ac6e32532143ccb550b1c67d020176d8a3365)) + + +### 🦊CI/CD + +* **Maven publishing:** Only publish maven artifacts when a beta or a full release was published ([1323088](https://git.griefed.de/Griefed/ServerPackCreator/commit/1323088fff61033c427b9dc948e7a5c4ea64af1f)) + ## [3.6.0](https://git.griefed.de/Griefed/ServerPackCreator/compare/3.5.1...3.6.0) (2022-06-26) diff --git a/backend/main/resources/de/griefed/resources/lang/lang_de_de.properties b/backend/main/resources/de/griefed/resources/lang/lang_de_de.properties index 44fc681637436020b809348ccf57b51e6b20e92f..b7bdee5a7e9e2c905e9dae6e792d96ec139e99ec 100644 --- a/backend/main/resources/de/griefed/resources/lang/lang_de_de.properties +++ b/backend/main/resources/de/griefed/resources/lang/lang_de_de.properties @@ -4,29 +4,3 @@ localeUnlocalizedName=German (Germany) localeName=Deutsch (Deutschland) encoding.check=\u00E7\u00EA\u00FD\u00F4\u00ED\u0159\u017E\u00C4\u00D6\u00DC 8\u2132\u0287n \u0287\u01DDpu\u01DD\u028D pun \u0287\u0265\u01DD\u0279p \u0265\u0254n\u0250 s\u01DD u\u0250\u026F \u01DD\u0131\u028D - -cli.usingLanguage=Benutzte Sprache: - -cli.input.true=[Ww]ahr -cli.input.yes=[Jj]a -cli.input.yes.short=[Jj] -cli.input.no=[Nn]ein -cli.input.no.short=[Nn] -cli.input.false=[Ff]alsch - -run.menu.options=Was m\u00F6chtest du als n\u00E4chstes tun? -run.menu.options1=Hilfe ausgeben -run.menu.options2=Auf Updates pr\u00FCfen -run.menu.options3=Sprache \u00E4ndern -run.menu.options4=Eine neue Konfiguration erstellen -run.menu.options5=ServerPackCreator im Kommandozeilen-Modus starten -run.menu.options6=ServerPackCreator als Webanwendung starten -run.menu.options7=ServerPackCreator mit grafischer Oberfl\u00E4che starten -run.menu.options0=Beenden -run.menu.options.select=Gib die Zahl deiner Auswahl ein -run.menu.error.gui=Deine Umgebung unterst\u00FCtzt keine grafische Oberfl\u00E4che. -run.menu.error.selection=Keine valide Zahl. Bitte w\u00E4hle eine Zahl zwischen 0 und 7. -run.menu.exit=Beende... -run.menu.change.locale=Welche Sprache m\u00F6chtest du benutzen? -run.menu.change.locale.format=(Sprach-Format ist en_us, de_de, uk_ua etc.) -run.menu.change.locale.error=Inkorrektes Format. ServerPackCreator unterst\u00FCtzt aktuell nur Sprachen im Format en_us (Sprache, Land). \ No newline at end of file diff --git a/backend/main/resources/de/griefed/resources/lang/lang_en_us.properties b/backend/main/resources/de/griefed/resources/lang/lang_en_us.properties index ed080f81ff6faf4f26065ee06c25ae01eddc3ea1..4ff0f5f066f5e74e6587d57a8a02f1e94cf49c83 100644 --- a/backend/main/resources/de/griefed/resources/lang/lang_en_us.properties +++ b/backend/main/resources/de/griefed/resources/lang/lang_en_us.properties @@ -5,51 +5,9 @@ localeName=English (US) encoding.check=\u00E7\u00EA\u00FD\u00F4\u00ED\u0159\u017E\u00C4\u00D6\u00DC\u00FC\u00F6\u00E4 8\u2132\u0287n \u0287\u01DDpu\u01DD\u028D pun \u0287\u0265\u01DD\u0279p \u0265\u0254n\u0250 s\u01DD u\u0250\u026F \u01DD\u0131\u028D -cli.usingLanguage=Using language: - -cli.input.true=[Tt]rue -cli.input.yes=[Yy]es -cli.input.yes.short=[Yy] -cli.input.no=[Nn]o -cli.input.no.short=[Nn] -cli.input.false=[Ff]alse - # DO NOT REMOVE %s \n OR SIMILAR VALUES. DOING SO WILL BREAK SERVERPACKCREATOR FUNCTIONALITY. # PLEASE BE AWARE OF WHITESPACE AND LINE BREAKS (\n)! -# CONSOLE -serverpackcreator.help.intro=# How to use ServerPackCreator:\n# java -jar ServerPackCreator.jar\n# Simply running the JAR without extra arguments runs ServerPackCreator in GUI mode unless\n# you are running in a headless environment. In the case of a headless environment, the CLI\n# mode will automatically be used.\n# -serverpackcreator.help.arguments.intro=# Extra arguments to use ServerPackCreator with:\n# -serverpackcreator.help.arguments.lang=# -lang : Allows you to use one of the available languages for ServerPackCreator. I can not\n# guarantee that each of the following available languages is 100% translated.\n# You best choice is en_us, or not specifying any as that is the default, because\n# I write ServerPackCreator with english in mind. Available usages:\n# -lang en_us\n# -lang uk_ua\n# -lang de_de\n# -serverpackcreator.help.arguments.help=# -cgen : Only available for the commandline interface. This will start the generation of\n# a new configuration file. You will be asked to enter information about your modpack\n# step-by-step. Each setting you enter will be checked for errors before it is saved.\n# If everything you enter is valid and without errors, it will be written to a new\n# serverpackcreator.conf and ServerPackCreator will immediately start a run with said\n# configuration file, generating a server pack for you.\n# -serverpackcreator.help.arguments.update=# -update : Check whether a new version of ServerPackCreator is available for download.\n# If an update is available, the version and link to the release of said update are\n# written to the console so you can from work with it from there.\n# Note: Automatic updates are currently not planned nor supported, and neither are\n# downloads of any available updates to your system. You need to update manually.\n# -serverpackcreator.help.arguments.cgen=# -cgen : Only available for the commandline interface. This will start the generation of\n# a new configuration file. You will be asked to enter information about your modpack\n# step-by-step. Each setting you enter will be checked for errors before it is saved.\n# If everything you enter is valid and without errors, it will be written to a new\n# serverpackcreator.conf and ServerPackCreator will immediately start a run with said\n# configuration file, generating a server pack for you.\n# -serverpackcreator.help.arguments.cli=# -cli : Run ServerPackCreator in Command-line interface mode. Checks the serverpackcreator.conf\n# for errors and if none are found, starts the generation of a server pack with the configuration\n# provided by your serverpackcreator.conf.\n# -serverpackcreator.help.arguments.web=# -web : Run ServerPackCreator as a webservice available at http://localhost:8080. The webservice\n# provides the same functionality as running ServerPackCreator in GUI mode (so no Commandline\n# arguments and a non-headless environment) as well as a REST API which can be used in different ways.\n# For more information about the REST API, please see the Java documentation:\n# - GitHub Pages: https://griefed.github.io/ServerPackCreator/\n# - GitLab Pages: https://griefed.pages.griefed.de/ServerPackCreator/\n# -serverpackcreator.help.arguments.gui=# -gui : Run ServerPackCreator using the graphical user interface. If your environment supports\n# graphics, i.e. is not headless, then this is the default mode in which ServerPackCreator\n# started as when no arguments are used.\n# -serverpackcreator.help.arguments.setup=# --setup : Set up and prepare the environment for subsequent runs of ServerPackCreator.\n# This will create/copy all files needed for ServerPackCreator to function\n# properly from inside its JAR-file and setup everything else, too.\n# -serverpackcreator.help.support.intro=# Support:\n# -serverpackcreator.help.support.issues=# Issues: Encountered a bug, or want some part of the documentation to be improved on? Got a suggestion?\n# Open an issue on GitHub at: https://github.com/Griefed/ServerPackCreator/issues\n# -serverpackcreator.help.support.discord=# Discord: If you would like to chat with me, ask me questions, or see when there's something new\n# regarding ServerPackCreator coming up, you can join my Discord server to stay up-to-date.\n# - Discord link: https://discord.griefed.de\n# -serverpackcreator.help.support.wiki=# Help/Wiki: If you want additional help on how to use ServerPackCreator, take a look at my wiki articles\n# regarding ServerPackCreator and some of the more advanced things it can do.\n# - Help: https://wiki.griefed.de/en/Documentation/ServerPackCreator/ServerPackCreator-Help\n# - HowTo: https://wiki.griefed.de/en/Documentation/ServerPackCreator/ServerPackCreator-HowTo\n# -serverpackcreator.help.support.someluv=# Buy Me A Coffee:\n# You like ServerPackCreator and would like to support me? By all means, every bit is very much\n# appreciated and helps me pay for servers and food. Food is most important. And coffee. Food and Coffee.\n# Those two get converted into code. Thank you very much!\n# - Github Sponsors: https://github.com/sponsors/Griefed -run.menu.options=What would you like to do next? -run.menu.options1=Print help -run.menu.options2=Check for updates -run.menu.options3=Change locale -run.menu.options4=Generate a new configuration -run.menu.options5=Run ServerPackCreator in CLI-mode -run.menu.options6=Run ServerPackCreator as a webservice -run.menu.options7=Run ServerPackCraator with a GUI -run.menu.options0=Exit -run.menu.options.select=Enter the number of your selection -run.menu.error.gui=You environment does not support a GUI. -run.menu.error.selection=Not a valid number. Please pick a number from 0 to 7. -run.menu.exit=Exiting... -run.menu.change.locale=What locale would you like to use? -run.menu.change.locale.format=(Locale format is en_us, de_de, uk_ua etc.) -run.menu.change.locale.error=Incorrect format. ServerPackCreator currently only supports locales in the format of en_us (Language, Country). - # GUI createserverpack.gui.createandshowgui=ServerPackCreator createserverpack.gui.tabbedpane.createserverpack.title=Create Server Pack @@ -57,12 +15,8 @@ createserverpack.gui.tabbedpane.createserverpack.tip=Configure and start generat createserverpack.gui.tabbedpane.serverpackcreatorlog.title=ServerPackCreator Log createserverpack.gui.tabbedpane.serverpackcreatorlog.tip=Latest ServerPackCreator log tail. createserverpack.gui.tabbedpane.serverpackcreatorlog.tooltip=Use File -> Upload ServerPackCreator Log to HasteBin for issue reports on GitHub. -createserverpack.gui.tabbedpane.modloaderinstallerlog.title=Modloader-Installer Log -createserverpack.gui.tabbedpane.modloaderinstallerlog.tip=Latest modloader-installer log tail. createserverpack.gui.tabbedpane.addonshandlerlog.title=Addons Log createserverpack.gui.tabbedpane.addonshandlerlog.tip=Latest addons log tail. -createserverpack.gui.tabbedpane.about.title=About -createserverpack.gui.tabbedpane.about.tip=Info, Updates, Support. createserverpack.gui.createserverpack.labelmodpackdir=Enter the path to your modpack directory: createserverpack.gui.createserverpack.labelmodpackdir.tip=Example: \"./Survive Create Prosper 4\" or \"/path/to/modpack.zip\" createserverpack.gui.createserverpack.labelsuffix=Server pack suffix @@ -71,7 +25,6 @@ createserverpack.gui.createserverpack.textsuffix.error=Server suffix contains il createserverpack.gui.createserverpack.labelclientmods=Enter the list of clientside-only mods in your modpack: createserverpack.gui.createserverpack.labelclientmods.tip=Comma separated. Example: AmbientSounds,BackTools,BetterAdvancement,BetterPing createserverpack.gui.createserverpack.textclientmods.error=Must not end with , or spaces or it contains illegal characters. -createserverpack.gui.createserverpack.textclientmods.fallback=Set clientMods with fallback list. createserverpack.gui.createserverpack.labelcopydirs=Enter the list of directories or files in your modpack to include in the server pack: createserverpack.gui.createserverpack.labelcopydirs.tip=Comma separated. Example: mods, config, options.txt or explicit source/file;destination/file-combinations createserverpack.gui.createserverpack.labeliconpath=Path to custom icon: @@ -112,18 +65,6 @@ createserverpack.gui.createserverpack.checkboxproperties.tip=Whether to copy the createserverpack.gui.createserverpack.checkboxzip=Create ZIP-archive? createserverpack.gui.createserverpack.checkboxzip.tip=Whether to create a ZIP-archive of the server pack for immediate upload. createserverpack.gui.createserverpack.about.title=About ServerPackCreator -createserverpack.gui.createserverpack.help.modpackdir=The directory containing your modpack. This directory contains all files of your modpack like the mods\ndirectory, or your worlds or any and all configuration files regarding your modpack. -createserverpack.gui.createserverpack.help.clientsidemods=Mods which are NOT supposed to be in your server pack. Usually mods which only add visual content to the\ngame, ambient sounds or shaders or some such. Every entry must be separated by a \",\" and NOT contain\nspecial characters such as [ ] ( ) \\ / ;\nYou only need to specify the beginning of the filename up to, but excluding,\nthe version number. ServerPackCreator checks whether any of the mods which are\ncopied from the modpack to the serverpack start with any strings in this list and,\nif there's a match, excludes that file from the serverpack.\nLoad a new configuration and see the default setting for the list of\nclientside-only mods for a detailed example. -createserverpack.gui.createserverpack.help.directories=These are the directories, files or explicit source/file;destination/file-combinations which are to be included\nin the generated server pack. The simplest example is the \"mods\"-folder, as without it, the server would\nhave no mods. As with Clientside mods,every entry must be separated by a \",\" and NOT contain special\ncharacters such as [ ] ( ) \\ / ; The exception being files, as the source and destination must be\nseparated by a \";\". In order to exclude a file or directory from the server pack to be generated\nprefix the entry with an !. All directories and files must in the modpack directory, therefore\nrelative paths must be used. -createserverpack.gui.createserverpack.help.pathtojava=This is the path to your java binary (Linux) or java.exe (Windows), including the file. Setting this path\nis required if you plan on having ServerPackCreator install the server for your chosen modloader. Pressing\nthe button next to the textfield will try to locate the directory of your Java installation, to make it\neasier to select the needed file. Should you leave this textfield empty, ServerPackCreator will try to\ndetermine the path during the generation of a server pack. -createserverpack.gui.createserverpack.help.minecraftversion=This is the Minecraft version your modpack uses and which the server pack will use as well. This field is\nrequired if you plan on having ServerPackCreator install the modloader-server in the generated server pack. -createserverpack.gui.createserverpack.help.modloader=The modloader your modpack uses and which the server pack will use as well. This field is required if you\nplan on having ServerPackCreator install the modloader-server in the generated server pack. Must be either\nForge, Fabric or Quilt. Other modloaders are not supported. -createserverpack.gui.createserverpack.help.modloaderversion=The modloader version your modpack uses and which the server pack will use as well. This field is required\nif you plan on having ServerPackCreator install the modloader-server in the generated server pack. -createserverpack.gui.createserverpack.help.installserver=Whether ServerPackCreator should install the server for the specified modloader, modloader version and\nMinecraft version. Checking this box enables the installation and requires said textfields to be filled out correctly. -createserverpack.gui.createserverpack.help.copypropertires= Whether ServerPackCreator should copy the server.properties file from the \"./server_files/\"-directory to\nthe server pack. Checking this box will tell ServerPackCreator to copy said file to the generated server pack.\nMake sure to customize the file in the aforementioned directory if you plan on using this feature. -createserverpack.gui.createserverpack.help.copyicon=Whether ServerPackCreator should copy the server-icon.png from the \"./server_files/\"-directory to the\nserver pack. Checking this box will tell ServerPackCreator to copy said file to the generated server pack.\nMake sure to customize the file in the aforementioned directory if you plan on using this feature. -createserverpack.gui.createserverpack.help.createzip=Whether ServerPackCreator should create a ZIP-archive of the generated server pack. Checking this box will\ntell ServerPackCreator to create said ZIP-archive which will be placed in the root of your modpack directory. -createserverpack.gui.createserverpack.help.javaargs=This setting allows you to set customized JVM flag/JavaArgs for the start-scripts which can be generated by\nServerPackCreator, if you've enabled the corresponding setting. You can either specify your own\nJVM flags/Java Args, use Aikars popular ones, or set them empty. createserverpack.gui.createserverpack.lazymode=Lazy Mode specified. Prepare for unforeseen consequences, Mr. Freeman. createserverpack.gui.createserverpack.openfolder.title=Browse server pack? createserverpack.gui.createserverpack.openfolder.browse=Would you like to browse the newly generated server pack? @@ -144,7 +85,6 @@ createserverpack.gui.buttoncopydirs=Open the file explorer to select the directo createserverpack.gui.buttoncopydirs.title=Select directories to include in server pack. createserverpack.gui.buttonjavapath=Open the file explorer to select the Java binary/executable. createserverpack.gui.buttonjavapath.tile=Select Java executable/binary. -createserverpack.gui.buttonloadconfig=Load configuration from a file. createserverpack.gui.buttonloadconfig.title=Select serverpackcreator.conf to load. createserverpack.gui.buttonloadconfig.filter=ServerPackCreator Configuration-File createserverpack.gui.buttongenerateserverpack=Generate @@ -158,18 +98,12 @@ createserverpack.gui.about.hastebin.dialog=Open in browser or copy to clipboard? createserverpack.gui.about.hastebin.dialog.yes=Open in Browser createserverpack.gui.about.hastebin.dialog.no=Neither createserverpack.gui.about.hastebin.dialog.clipboard=Copy to clipboard -createserverpack.gui.about.discord=Get support and chat on Griefed's Discord server. menubar.gui.filetoolarge=Size exceeds 10MB or 400.000 characters in length.\nMust be smaller than 10MB and 400.000 characters\nfor HasteBin upload. menubar.gui.filetoolargetitle=File too large! -menubar.gui.javaargs.ok=OK -menubar.gui.javaargs.aikar=Use Aikars flags -menubar.gui.javaargs.empty=Empty -menubar.gui.javaargs.cancel=Cancel menubar.gui.menu.file=File menubar.gui.menu.edit=Edit menubar.gui.menu.view=View menubar.gui.menu.about=About -menubar.gui.menu.help=Help menubar.gui.menuitem.loadconfig=Load Configuration menubar.gui.menuitem.saveconfig=Save Configuration menubar.gui.menuitem.saveas=Save Configuration As... @@ -181,7 +115,6 @@ menubar.gui.menuitem.updatefallback.updated=Your fallback list has been updated! menubar.gui.menuitem.updatefallback.nochange=No update available. menubar.gui.menuitem.exit=Exit menubar.gui.menuitem.theme=Toggle light/dark-mode -menubar.gui.menuitem.javaargs=Edit Start-Scripts Java Args menubar.gui.menuitem.serverproperties=Open server.properties in Editor menubar.gui.menuitem.servericon=Open server-icon.png in Editor menubar.gui.menuitem.addonsdir=Open addons-directory @@ -209,29 +142,10 @@ update.dialog.yes=Open in Browser update.dialog.no=Neither update.dialog.clipboard=Copy to clipboard -# OTHER -configuration.writeconfigtofile.modpackdir=# Path to your modpack. Can be either relative or absolute.\n# Example: \"./Some Modpack\" or \"C:/Minecraft/Some Modpack\" -configuration.writeconfigtofile.clientmods=# List of client-only mods to delete from serverpack.\n# No need to include version specifics. Must be the filenames of the mods, not their project names on CurseForge!\n# Example: [AmbientSounds-,ClientTweaks-,PackMenu-,BetterAdvancement-,jeiintegration-] -configuration.writeconfigtofile.copydirs=# Name of directories or files to include in serverpack.\n# When specifying \"saves/world_name\", \"world_name\" will be copied to the base directory of the serverpack\n# for immediate use with the server. Automatically set when projectID,fileID for modpackDir has been specified.\n# Example: [config,mods,scripts] -configuration.writeconfigtofile.custom.icon=# Path to a custom server-icon.png-file to include in the server pack. -configuration.writeconfigtofile.custom.properties=# Path to a custom server.properties-file to include in the server pack. -configuration.writeconfigtofile.includeserverinstallation=# Whether to install a Forge/Fabric/Quilt server for the serverpack. Must be true or false.\n# Default value is true. -configuration.writeconfigtofile.javapath=# Path to the Java executable. On Linux systems it would be something like \"/usr/bin/java\".\n# Only needed if includeServerInstallation is true. -configuration.writeconfigtofile.minecraftversion=# Which Minecraft version to use. Example: \"1.16.5\".\n# Automatically set when projectID,fileID for modpackDir has been specified.\n# Only needed if includeServerInstallation is true. -configuration.writeconfigtofile.modloader=# Which modloader to install. Must be either \"Forge\", \"Fabric\" or \"Quilt\".\n# Automatically set when projectID,fileID for modpackDir has been specified.\n# Only needed if includeServerInstallation is true. -configuration.writeconfigtofile.modloaderversion=# The version of the modloader you want to install. Example for Fabric=\"0.7.3\", example for Forge=\"36.0.15\".\n# Automatically set when projectID,fileID for modpackDir has been specified.\n# Only needed if includeServerInstallation is true. -configuration.writeconfigtofile.includeservericon=# Include a server-icon.png in your serverpack. Must be true or false.\n# Customize server-icon.png in ./server_files.\n# Dimensions must be 64x64!\n# Default value is true. -configuration.writeconfigtofile.includeserverproperties=# Include a server.properties in your serverpack. Must be true or false.\n# Customize server.properties in ./server_files.\n# If no server.properties is provided but is set to true, a default one will be provided.\n# Default value is true. -configuration.writeconfigtofile.includezipcreation=# Create zip-archive of serverpack. Must be true or false.\n# Default value is true. -configuration.writeconfigtofile.javaargs=# Java arguments to set in the start-scripts for the generated server pack. Default value is \"empty\".\n# Leave as \"empty\" to not have Java arguments in your start-scripts. -configuration.writeconfigtofile.serverpacksuffix=# Suffix to append to the server pack to be generated. Can be left blank/empty. - # LOGS ## Error logs configuration.log.error.answer=Incorrect value specified. Please try again. configuration.log.error.checkconfig.start=Couldn't parse config file. Consider checking your config file and fixing empty values. If the value needs to be an empty string, leave its value to "". -configuration.log.error.checkconfig.failure=Config check not successful. Check your config for errors. -configuration.log.error.printconfig.copydirs=List of directories to copy is empty. configuration.log.error.checkmodpackdir=Modpack directory not specified. Please specify an existing directory. configuration.log.error.checkcopydirs.empty=No directories or files specified for copying. This would result in an empty serverpack. configuration.log.error.checkcopydirs.notfound=Copy-file or copy-directory %s does not exist. Please specify existing directories or files. @@ -240,19 +154,12 @@ configuration.log.error.checkcopydirs.read=No read-permission for %s configuration.log.error.checkjavapath.windows=Windows environment detected. Your Java path must end with .exe! configuration.log.error.checkmodloader=Invalid modloader specified. Modloader must be either Forge, Fabric or Quilt. configuration.log.error.checkmodloaderversion=Specified incorrect modloader version. Please check your modpack for the correct version and enter again. -configuration.log.error.isminecraftversioncorrect.empty=You didn't specify your Minecraft version. -configuration.log.error.isfabricversioncorrect.empty=You did not specify a Fabric version. -configuration.log.error.isforgeversioncorrect.empty=You did not specify a Forge version. configuration.log.error.isdir.copydir=There's something wrong with your setting of directories to include in your server pack. -configuration.log.error.isdir.minecraftversion=There's something wrong with your Minecraft version setting. -configuration.log.error.isdir.modloaderversion=There's something wrong with your Modloader version setting. -configuration.log.error.isdir.modloader=There's something wrong with your Modloader or Modloader version setting. configuration.log.error.modpackdirectory=Modpack directory %s could not be found. configuration.log.error.servericon=The specified server-icon does not exist: %s configuration.log.error.serverproperties=The specified server.properties does not exist: %s configuration.log.error.minecraft=Incorrect Minecraft version specified. configuration.log.error.encountered=Encountered %s errors during the configuration check. -configuration.log.error.encountered.specific=Error %s: %s configuration.log.error.zip.overrides=The ZIP-file you specified only contains one directory: %s. ZIP-files for ServerPackCreator must be full modpacks, with all their contents being in the root of the ZIP-file. configuration.log.error.zip.modsorconfig=The ZIP-file you specified does not contain the mods or config directories. What use is a modded server without mods and their configurations? configuration.log.error.zip.directories=Couldn't acquire directories in ZIP-file. @@ -260,227 +167,55 @@ configuration.log.error.zip.manifest=Error parsing CurseForge manifest.json from configuration.log.error.zip.instance=Error parsing minecraftisntance.json from ZIP-file. configuration.log.error.zip.config=Error parsing config.json from ZIP-file. configuration.log.error.zip.mmcpack=Error parsing mmc-pack.json from ZIP-file. -defaultfiles.log.error.writeconfigtofile.config=Could not delete existing config file. -defaultfiles.log.error.writeconfigtofile.old=Could not delete old existing config file from previous versions of ServerPackCreator. -defaultfiles.log.error.writeconfigtofile=Couldn't write serverpackcreator.conf. -createserverpack.log.error.cleanupenvironment.folder.delete=Error deleting file from server-packs/%s. -createserverpack.log.error.cleanupenvironment.zip.delete=Error deleting old zip archive. -createserverpack.log.error.cleanupserverpack.delete=Could not delete %s. -createserverpack.log.error.buttonloadconfigfromfile=Error loading configuration from selected file. -createserverpack.log.error.buttoncreateserverpack.tempfile=Could not delete temporary config file. -createserverpack.log.error.abouttab.hastebin.response=Error encountered when acquiring response from URL. -createserverpack.log.error.fabric.improvedlauncher=Error downloading the improved Fabric server launcher. createserverpack.log.error.minecraft.server=A server is not available for the specified Minecraft version. createserverpack.log.error.copy.directory=Couldn't gather file %s from directory %s. createserverpack.log.error.copy=An error occurred gathering files to copy to the server pack. -main.log.error.runincli=Please check your serverpackcreator.conf for any incorrect settings. This message is also displayed if ServerPackCreator downloaded and setup a modpack from a projectID,fileID for modpackDir. about.log.error.document=Error inserting string into document. about.log.error.browser=Error opening browser. update.log.error.github.fetch=Couldn't set repository. Is GitHub available, do you have a working internet connection? -update.log.error.gitlab.fetch=Couldn't set repository. Is GitLab available, do you have a working internet connection? ## Info logs configuration.log.info.start=You started ServerPackCreator with the "%s" argument. Step-by-step generation of config file initiated... -configuration.log.info.modpack.enter=Please enter your modpack path. This path can be relative to ServerPackCreator, or absolute. configuration.log.info.modpack.example=Example: "./Some Modpack" or "C:/Minecraft/Some Modpack" configuration.log.info.modpack.cli=Path to modpack directory: -configuration.log.info.modpack.checkreturninfo=If you are satisfied with this setting, enter ture. If not, enter false to restart modpack directory configuration. -configuration.log.info.clientmods.enter=Enter filenames of clientside-only mods, one per line. When you are done, simply press enter with empty input. -configuration.log.info.checkreturn=You entered: %s -configuration.log.info.clientmods.checkreturninfo=If you are satisfied with these values, enter true. If not, enter false to restart clientmod configuration. configuration.log.info.answer=Answer: -configuration.log.info.copydirs.enter=Which directories or files should be copied to the server pack? These are folder- or filenames inside your modpack directory or explicit source/file;destination/file-combinations. -configuration.log.info.copydirs.dirsinmodpack=The modpack directory you specified contains the following directories: %s configuration.log.info.copydirs.specify=Specify your directories and files you want to be copied: -configuration.log.info.copydirs.checkreturninfo=If you are satisfied with these values, enter true. If not, enter false to restart clientmod configuration. -configuration.log.info.custom.icon.enter=Enter the path to your custom server-icon.png-file, if you want to include one. Leave blank if you are fine with the default. configuration.log.info.custom.icon.path=Path to your server-icon.png: configuration.log.info.custom.icon.end=If you are satisfied with this setting, enter ture. If not, enter false to restart server-icon.png configuration. -configuration.log.info.custom.properties.enter=Enter the path to your custom server.properties-file, if you want to include one. Leave blank if you are fine with the default. configuration.log.info.custom.properties.path=Path to your server.properties: configuration.log.info.custom.properties.end=If you are satisfied with this setting, enter ture. If not, enter false to restart server-icon.png configuration. -configuration.log.info.server.enter=Do you want ServerPackCreator to install the modloader server for your server pack? Must be true or false. configuration.log.info.server.include=Include modloader server installation: -configuration.log.info.minecraft.enter=Which version of Minecraft does your modpack use? -configuration.log.info.minecraft.specify=Minecraft version: -configuration.log.info.modloader.enter=What modloader does your modpack use? -configuration.log.info.modloader.cli=Modloader: -configuration.log.info.modloaderversion.enter=What version of %s does your modpack use? -configuration.log.info.modloaderversion.cli=Modloader version: -configuration.log.info.javaargs.enter=Java args: -configuration.log.info.javaargs.cli=Specify the Java arguments, if any, to execute the server with. Can be left blank. -configuration.log.info.serverpacksuffix.cli=Enter the suffix you want to append to your server pack. Can be left empty. -configuration.log.info.serverpacksuffix.enter=Server pack suffix: -configuration.log.info.java.enter=Specify the path to your Java installation. Must end with "java" on Linux, or "java.exe" on Windows. -configuration.log.info.java.enter2=If you leave this empty, ServerPackCreator will try to determine the path for you. +configuration.log.info.minecraft.specify=Minecraft version: configuration.log.info.java.example=Example Linux: /usr/bin/java | Example Windows: C:/Program Files/AdoptOpenJDK/jdk-8.0.275.1-hotspot/jre/bin/java.exe configuration.log.info.java.cli=Path to your Java installation: -configuration.log.info.icon.enter=Do you want ServerPackCreator to include a server-icon in your server pack? Must be true or false. configuration.log.info.icon.cli=Include server-icon.png: -configuration.log.info.properties.enter=Do you want ServerPackCreator to include a server.properties in your server pack? Must be true or false. configuration.log.info.properties.cli=Include server.properties: -configuration.log.info.zip.enter=Do you want ServerPackCreator to create a ZIP-archive of your server pack? Must be true or false. -configuration.log.info.zip.cli=Create ZIP-archive: -configuration.log.info.config.enter=If you are satisfied with these values, enter true. If not, enter false to restart config generation. -configuration.log.info.config.written=New config file successfully written. Thanks go to Whitebear60 for initially writing the CLI-Config-Generation. -configuration.log.info.checkconfig.start=Checking configuration... -configuration.log.info.checkconfig.success=Config check successful. No errors encountered. -configuration.log.info.iscurse.fabric=Please make sure to check the configuration for the used Fabric version after ServerPackCreator is done setting up the modpack and new config file. -configuration.log.info.containsfabric=Fabric detected. Setting modloader to Fabric. -configuration.log.info.suggestcopydirs.start=Preparing a list of directories to include in server pack... -configuration.log.info.suggestcopydirs.list=Modpack directory checked. Suggested directories for copyDirs-setting are: %s -configuration.log.info.printconfig.start=Your configuration is: -configuration.log.info.printconfig.modpackdir=Modpack directory: %s -configuration.log.info.printconfig.clientmods=Client mods specified. Client mods are: -configuration.log.info.printconfig.copydirs=Directories to copy: -configuration.log.info.printconfig.server=Include server installation: %s -configuration.log.info.printconfig.javapath=Java Installation path: %s -configuration.log.info.printconfig.minecraftversion=Minecraft version: %s -configuration.log.info.printconfig.modloader=Modloader: %s -configuration.log.info.printconfig.modloaderversion=Modloader Version: %s -configuration.log.info.printconfig.icon=Include server icon: %s -configuration.log.info.printconfig.properties=Include server properties: %s -configuration.log.info.printconfig.zip=Create zip-archive of serverpack: %s -configuration.log.info.printconfig.javaargs=Java arguments for start-scripts: %s -configuration.log.info.printconfig.serverpacksuffix=Server pack suffix: %s -defaultfiles.log.info.forgemanifest.create=Forge Manifest JSON File does not exist, creating... -defaultfiles.log.info.forgemanifest.created=Forge Manifest JSON File created. -defaultfiles.log.info.filessetup.enter=Checking for default files... -defaultfiles.log.info.filessetup.finish=Setup completed. -defaultfiles.log.info.checkforfile=%s generated. Please customize if you intend on using it. -defaultfiles.log.info.checkforconfig.old=creator.conf migrated to serverpackcreator.conf. -defaultfiles.log.info.checkforconfig.config=serverpackcreator.conf generated. Please customize. -defaultfiles.log.info.checkforforgelinux=start-forge.sh generated. Please customize if you intend on using it. -defaultfiles.log.info.checkforproperties=server.properties generated. Please customize if you intend on using it. -defaultfiles.log.info.checkforicon=server-icon.png generated. Please customize if you intend on using it. -defaultfiles.log.info.writeconfigtofile.config=Deleted existing configuration file. -defaultfiles.log.info.writeconfigtofile.confignew=Successfully written new configuration file. -defaultfiles.log.info.writeconfigtofile.old=Deleted old existing config file from previous versions of ServerPackCreator, to ensure new one is always used. createserverpack.log.info.overwrite=Server pack already exists and overwrite disabled. -createserverpack.log.info.cleanup=Server pack cleanup disabled. -createserverpack.log.info.cleanupenvironment.folder.enter=Found old server_pack. Cleaning up... -createserverpack.log.info.cleanupenvironment.folder.complete=Cleanup of previous server_pack completed. -createserverpack.log.info.cleanupenvironment.zip.enter=Found old server_pack.zip. Cleaning up... -createserverpack.log.info.cleanupenvironment.zip.complete=Old server_pack.zip deleted. -createserverpack.log.info.copystartscripts.forge=Creating Forge start scripts... -createserverpack.log.info.copystartscripts.fabric=Creating Fabric start scripts... -createserverpack.log.info.copystartscripts.quilt=Creating Quilt start scripts... -createserverpack.log.info.copyfiles.setup=Gathering %s file(s). -createserverpack.log.info.copyfiles.copy=Copying files to the server pack. This may take a while... -createserverpack.log.info.excludeclientmods=Preparing a list of mods to include in server pack... -createserverpack.log.info.copyicon=Copying server-icon.png... -createserverpack.log.info.copyproperties=Copying server.properties... -createserverpack.log.info.installserver.fabric.enter=Starting Fabric installation. -createserverpack.log.info.installserver.fabric.download=Fabric installer successfully downloaded. -createserverpack.log.info.installserver.quilt.enter=Starting Quilt installation. -createserverpack.log.info.installserver.quilt.download=Quilt installer successfully downloaded. -createserverpack.log.info.installserver=Server for Minecraft %s, %s %s installed. -createserverpack.log.info.installserver.forge.enter=Starting Forge installation. -createserverpack.log.info.installserver.forge.download=Forge installer successfully downloaded. -createserverpack.log.info.installserver.enter=Starting server installation for Minecraft %s, %s %s. -createserverpack.log.info.installserver.details=For details regarding the installation of this modloader server, see logs/modloader_installer.log. -createserverpack.log.info.zipbuilder.exclusion.deactivated=File exclusion from ZIP-archives deactivated. -createserverpack.log.info.zipbuilder.enter=Creating zip archive of serverpack... -createserverpack.log.info.zipbuilder.finish=Finished creation of zip archive. -createserverpack.log.info.forgeshell=Forge shell script generated. -createserverpack.log.info.fabric.improved=Successfully provided improved Fabric Server Launcher. -createserverpack.log.info.download=Trying to download %s. -createserverpack.log.info.downloadfabricjar.enter=Trying to download Fabric installer... -createserverpack.log.info.downloadforgejar.enter=Trying to download specified Forge installer... -createserverpack.log.info.cleanupserverpack.enter=Cleanup after modloader server installation. -createserverpack.log.info.cleanupserverpack.deleted=Deleted %s -createserverpack.log.info.cleanupserverpack.rename=Renamed forge.jar and deleted old one. -createserverpack.log.info.cleanupserverpack.forgelog=Forge installer log deleted. -createserverpack.log.info.buttonclientmods=Selected mods: %s -createserverpack.log.info.buttonloadconfigfromfile=Loading from configuration file: %s createserverpack.log.info.buttoncreateserverpack.start=Checking entered configuration. createserverpack.log.info.buttoncreateserverpack.checked=Configuration checked successfully. -createserverpack.log.info.buttoncreateserverpack.tempfile=Deleted temporary config file. -createserverpack.log.info.buttoncreateserverpack.writing=Writing GUI configuration to new serverpackcreator.conf. createserverpack.log.info.buttoncreateserverpack.generating=Starting ServerPackCreator run. createserverpack.log.info.buttoncreateserverpack.ready=ServerPackCreator ready. -createserverpack.log.info.noaddonstoexecute=No Server Pack addons to execute. -createserverpack.log.info.executingaddons=Starting execution of Server Pack addons. Check addons.log in the logs-directory for details about their execution. -createserverpack.log.info.addonsexecuted=Addons executed. Finishing... -createserverpack.log.info.scantoml=Scanning Minecraft 1.13.x and newer Forge mods for sideness... -createserverpack.log.info.scanannotation=Scanning Minecraft 1.12.x and older mods for sideness... -createserverpack.log.info.scanfabricmodjson=Scanning Fabric mods for sideness... -createserverpack.log.info.scanquiltmodjson=Scanning Quilt mods for sideness... -createserverpack.log.info.bat.delete=Deleted run.bat. -createserverpack.log.info.sh.delete=Deleted run.sh. createserverpack.log.info.icon=No custom icon specified or the file doesn't exist. createserverpack.log.info.properties=No custom properties specified or the file doesn't exist. -main.log.info.system.enter=SYSTEM INFORMATION: -main.log.info.system.jarpath=JAR Path: %s -main.log.info.system.jarname=JAR Name: %s main.log.info.system.java=Java version: %s -main.log.info.system.osarchitecture=OS architecture: %s -main.log.info.system.osname=OS name: %s -main.log.info.system.osversion=OS version: %s main.log.info.system.include=Include this information when reporting an issue on GitHub. -main.log.info.runincli.server=Not installing modded server. -main.log.info.runincli.icon=Not including servericon. -main.log.info.runincli.properties=Not including server.properties. -main.log.info.runincli.zip=Not creating zip archive of serverpack. -main.log.info.runincli.serverpack=Server pack available at: %s -main.log.info.runincli.archive=Server pack archive available at: %s_server_pack.zip -main.log.info.runincli.finish=Done! -main.log.info.newupdate=A new (pre)release is available: %s downloadable at %s -addonshandler.log.info.setlistofaddons=Plugins found: -addonshandler.log.info.setlistofaddons.notfound=No plugins found. -addonshandler.log.info.setlistofserverpackaddons=Server Pack plugins: -addonshandler.log.info.setlistofserverpackaddons.notfound=No Server Pack plugins found. -addonshandler.log.info.runserverpackaddons=All plugins executed. Returning to ServerPackCreator. updates.log.info.none=No updates available. -utilities.log.info.config.print.servericon=Path to custom server-icon: %s -utilities.log.info.config.print.serverproperties=Path to custom server.properties: %s ## Warn logs -configuration.log.warn.converttoboolean.warn=Warning. Couldn't parse boolean. Assuming false. -configuration.log.warn.printconfig.noclientmods=No client mods specified. -configuration.log.warn.checkmodpackdir=Couldn't find directory %s. -configuration.log.warn.getjavapath.set=Automatically acquired path to Java installation: %s -configuration.log.warn.checkconfig.clientmods=No clientside-only mods specified. Using fallback list. configuration.log.warn.checkconfig.copydirs.lazymode0=!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!! configuration.log.warn.checkconfig.copydirs.lazymode1=Lazy mode specified. This will copy the WHOLE modpack to the server pack. No exceptions. configuration.log.warn.checkconfig.copydirs.lazymode2=You will not receive support from me for a server pack generated this way. configuration.log.warn.checkconfig.copydirs.lazymode3=Do not open an issue on GitHub if this configuration errors or results in a broken server pack. -configuration.log.warn.checkconfig.copydirs.lazymode.ignore=You specified lazy mode in your configuration, but your copyDirs configuration contains other entries. To use the lazy mode, only specify "lazy_mode" and nothing else. Ignoring lazy mode. -# BEWARE INDENTATION! -defaultfiles.log.warn.filessetup.warning0=################################################################ -defaultfiles.log.warn.filessetup.warning1=# ONE OR MORE DEFAULT FILE(S) GENERATED. # -defaultfiles.log.warn.filessetup.warning2=# CHECK THE LOGS TO FIND OUT WHICH FILE(S) WAS/WERE GENERATED. # -defaultfiles.log.warn.filessetup.warning3=# CUSTOMIZE THEM BEFORE CONTINUING! # -# BEWARE INDENTATION! -main.log.warn.wip0=################################################################ -main.log.warn.wip1=# WORK IN PROGRESS! # -main.log.warn.wip2=# USE AT YOUR OWN RISK! BE AWARE THAT DATA LOSS IS POSSIBLE! # -main.log.warn.wip3=# I WILL NOT BE HELD RESPONSIBLE FOR DATA LOSS! # -main.log.warn.wip4=# YOU HAVE BEEN WARNED! # main.log.warn.windows=ServerPackCreator webservice-mode does not support Windows. Are you sure you want to proceed? Prepare for unforeseen consequences. main.log.warn.windows.input=Answer Yes to proceed, No to quit: main.log.warn.windows.no=Answered no. Existing... main.log.warn.windows.yes=No regrets, Mr. Freeman... -createserverpack.log.warn.zipbuilder.minecraftjar1=!!! NOTE: The minecraft_server.jar will not be included in the zip-archive. !!! -createserverpack.log.warn.zipbuilder.minecraftjar2=!!! Mojang strictly prohibits the distribution of their software through third parties. !!! -createserverpack.log.warn.zipbuilder.minecraftjar3=!!! Tell your users to execute the download scripts to get the Minecraft server jar. !!! ## Debug logs -defaultfiles.log.debug.manifest.created=Manifest %s created. main.log.debug.help.exit=Help printed. Exiting with code 0. main.log.debug.warning=Warning user about possible data loss. -configuration.log.debug.isdir.copydirs=copyDirs setting check passed. -configuration.log.debug.isdir.minecraftversion=minecraftVersion setting check passed. -configuration.log.debug.isdir.modloader=modLoader setting check passed. -configuration.log.debug.isdir.modloaderversion=modLoaderVersion setting check passed. configuration.log.debug.modloader.forge=Setting modloader to Forge. # Addon logs -addons.log.info.execute.pregen=Executing PreGenExtension addons. -addons.log.info.execute.pregen.none=No PreGenExtension addons to execute. -addons.log.info.execute.prezip=Executing PreZipExtension addons. -addons.log.info.execute.prezip.none=No PreZipExtension addons to execute. -addons.log.info.execute.postgen=Executing PostGenExtension addons. -addons.log.info.execute.postgen.none=No PostGenExtension addons to execute. addons.log.info.execute.addon=Executing addon %s addons.log.error=Addon %s encountered an error. \ No newline at end of file diff --git a/backend/main/resources/de/griefed/resources/lang/lang_uk_ua.properties b/backend/main/resources/de/griefed/resources/lang/lang_uk_ua.properties index 3a3813f430d4a3778d56984d2807b3d5e5341a91..b0979455b131379153b24dd419908ffbf236732e 100644 --- a/backend/main/resources/de/griefed/resources/lang/lang_uk_ua.properties +++ b/backend/main/resources/de/griefed/resources/lang/lang_uk_ua.properties @@ -5,11 +5,3 @@ localeName=\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430 (\u0423\ encoding.check=\u00E7\u00EA\u00FD\u00F4\u00ED\u0159\u017E\u00C4\u00D6\u00DC 8\u2132\u0287n \u0287\u01DDpu\u01DD\u028D pun \u0287\u0265\u01DD\u0279p \u0265\u0254n\u0250 s\u01DD u\u0250\u026F \u01DD\u0131\u028D -cli.usingLanguage=\u0412\u0438\u043A\u043E\u0440\u0438\u0441\u0442\u043E\u0432\u0443\u0454\u0442\u044C\u0441\u044F \u043C\u043E\u0432\u0430: - -cli.input.true=[Tt]rue -cli.input.yes=[\u0422\u0442]\u0430\u043A -cli.input.yes.short=[\u0422\u0442] -cli.input.no=[\u041D\u043D]\u0456 -cli.input.no.short=[\u041D\u043D] -cli.input.false=[Ff]alse diff --git a/backend/main/resources/de/griefed/resources/server_files/default_template.ps1 b/backend/main/resources/de/griefed/resources/server_files/default_template.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..3ee6dd21dcd3b49aedee881c522df31cfb1ec57a --- /dev/null +++ b/backend/main/resources/de/griefed/resources/server_files/default_template.ps1 @@ -0,0 +1,394 @@ +# Start script generated by ServerPackCreator SPC_SERVERPACKCREATOR_VERSION_SPC. +# Depending on which modloader is set, different checks are run to ensure the server will start accordingly. +# If the modloader checks and setup are passed, Minecraft and EULA checks are run. +# If everything is in order, the server is started. + +if ( (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) +{ + Write-Host "Warning! Running with administrator-privileges is not recommended." +} + +Set-Location "$PSScriptRoot" + +$MinecraftVersion = "SPC_MINECRAFT_VERSION_SPC" +$ModLoader = "SPC_MODLOADER_SPC" +$ModLoaderVersion = "SPC_MODLOADER_VERSION_SPC" +$Args = "SPC_JAVA_ARGS_SPC" +$Java = "SPC_JAVA_SPC" +$FabricInstallerVersion = "SPC_FABRIC_INSTALLER_VERSION_SPC" +$QuiltInstallerVersion = "SPC_QUILT_INSTALLER_VERSION_SPC" +$MinecraftServerUrl = "SPC_MINECRAFT_SERVER_URL_SPC" + +# Variables with do_not_manually_edit are set automatically during script execution, +# so manually editing them will have no effect, as they will be overridden. +$MinecraftServerJarLocation = "do_not_manually_edit" +$LauncherJarLocation = "do_not_manually_edit" +$ServerRunCommand = "do_not_manually_edit" + +Function DeleteFileSilently +{ + param ($FileToDelete) + + $ErrorActionPreference = "SilentlyContinue"; + if ((Get-Item "${FileToDelete}").PSIsContainer) + { + Remove-Item "${FileToDelete}" -Recurse + } + else + { + Remove-Item "${FileToDelete}" + } + $ErrorActionPreference = "Continue"; +} + +Function PauseScript +{ + Write-Host "Press any key to continue" -ForegroundColor Yellow + $host.ui.RawUI.ReadKey("NoEcho,IncludeKeyDown") > $null +} + +Function Crash +{ + Write-Host "Exiting..." + PauseScript + exit 1 +} + +Function global:RunJavaCommand +{ + param ($CommandToRun) + + CMD /C "`"${Java}`" ${CommandToRun}" +} + +# $1 = Filename to check for +# $2 = Filename to save download as +# $3 = URL to download $2 from +# true if the File was successfully downloaded, false if it already exists +Function DownloadIfNotExists +{ + param ($FileToCheck, $FileToDownload, $DownloadURL) + + if (!(Test-Path -Path $FileToCheck -PathType Leaf)) + { + + Write-Host "${FileToCheck} could not be found." + Write-Host "Downloading ${FileToDownload}" + Write-Host "from ${DownloadURL}" + + Invoke-WebRequest -URI "${DownloadURL}" -OutFile "${FileToDownload}" + + if (Test-Path -Path "${FileToDownload}" -PathType Leaf) + { + Write-Host "Download complete." + return $true + } + + } + else + { + Write-Host "${FileToCheck} present." + return $false + } + +} + +# If modloader = Forge, run Forge-speci}c checks +Function global:SetupForge +{ + "" + "Running Forge checks and setup..." + $ForgeInstallerUrl = "https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MinecraftVersion}-${ModLoaderVersion}/forge-${MinecraftVersion}-${ModLoaderVersion}-installer.jar" + $ForgeJarLocation = "do_not_manually_edit" + $MINOR = ${MinecraftVersion}.Split(".") + + if ($MINOR[1] -le 16) + { + $ForgeJarLocation = "forge.jar" + $script:LauncherJarLocation = "forge.jar" + $script:MinecraftServerJarLocation = "minecraft_server.${MinecraftVersion}.jar" + $script:ServerRunCommand = "-Dlog4j2.formatMsgNoLookups=true ${Args} -jar ${LauncherJarLocation} nogui" + } + else + { + $ForgeJarLocation = "libraries/net/minecraftforge/forge/${MinecraftVersion}-${ModLoaderVersion}/forge-${MinecraftVersion}-${ModLoaderVersion}-server.jar" + $script:MinecraftServerJarLocation = "libraries/net/minecraft/server/${MinecraftVersion}/server-${MinecraftVersion}.jar" + $script:ServerRunCommand = "-Dlog4j2.formatMsgNoLookups=true @user_jvm_args.txt @libraries/net/minecraftforge/forge/${MinecraftVersion}-${ModLoaderVersion}/win_args.txt nogui" + + if (!(Test-Path -Path 'user_jvm_args.txt' -PathType Leaf)) + { + "# Xmx and Xms set the maximum and minimum RAM usage, respectively.`n" + + "# They can take any number, followed by an M or a G.`n" + + "# M means Megabyte, G means Gigabyte.`n" + + "# For example, to set the maximum to 3GB: -Xmx3G`n" + + "# To set the minimum to 2.5GB: -Xms2500M`n" + + "# A good default for a modded server is 4GB.`n" + + "# Uncomment the next line to set it.`n" + + "# -Xmx4G`n" + + "${script:Args}" | Out-File user_jvm_args.txt -encoding utf8 + } + else + { + "user_jvm_args.txt present..." + } + } + + if ((DownloadIfNotExists "${ForgeJarLocation}" "forge-installer.jar" "${ForgeInstallerUrl}")) + { + "Forge Installer downloaded. Installing..." + RunJavaCommand "-jar forge-installer.jar --installServer" + + if ($MINOR[1] -gt 16) + { + DeleteFileSilently 'run.bat' + DeleteFileSilently 'run.sh' + } + else + { + "Renaming forge-${MinecraftVersion}-${ModLoaderVersion}.jar to forge.jar" + Move-Item "forge-${MinecraftVersion}-${ModLoaderVersion}.jar" 'forge.jar' + } + + if ((Test-Path -Path "${ForgeJarLocation}" -PathType Leaf)) + { + DeleteFileSilently 'forge-installer.jar' + DeleteFileSilently 'forge-installer.jar.log' + "Installation complete. forge-installer.jar deleted." + } + else + { + DeleteFileSilently 'forge-installer.jar' + "Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection." + Crash + } + } + "" +} + +# If modloader = Fabric, run Fabric-speci}c checks +Function global:SetupFabric +{ + "" + "Running Fabric checks and setup..." + $FabricInstallerUrl = "https://maven.fabricmc.net/net/fabricmc/fabric-installer/${FabricInstallerVersion}/fabric-installer-${FabricInstallerVersion}.jar" + $ImprovedFabricLauncherUrl = "https://meta.fabricmc.net/v2/versions/loader/${MinecraftVersion}/${ModLoaderVersion}/${FabricInstallerVersion}/server/jar" + + $ErrorActionPreference = "SilentlyContinue"; + $script:ImprovedFabricLauncherAvailable = [int][System.Net.WebRequest]::Create("${ImprovedFabricLauncherUrl}").GetResponse().StatusCode + $ErrorActionPreference = "Continue"; + + if ("${ImprovedFabricLauncherAvailable}" -eq "200") + { + "Improved Fabric Server Launcher available..." + "The improved launcher will be used to run this Fabric server." + $script:LauncherJarLocation = "fabric-server-launcher.jar" + (DownloadIfNotExists "${script:LauncherJarLocation}" "${script:LauncherJarLocation}" "${ImprovedFabricLauncherUrl}") > $null + } + else + { + try + { + $ErrorActionPreference = "SilentlyContinue"; + $FabricAvailable = [int][System.Net.WebRequest]::Create("https://meta.fabricmc.net/v2/versions/loader/${MinecraftVersion}/${ModLoaderVersion}/server/json").GetResponse().StatusCode + $ErrorActionPreference = "Continue"; + } + catch + { + $FabricAvailable = "400" + } + if ("${FabricAvailable}" -ne "200") + { + "Fabric is not available for Minecraft ${MinecraftVersion}, Fabric ${ModLoaderVersion}." + Crash + } + + if ((DownloadIfNotExists "fabric-server-launch.jar" "fabric-installer.jar" "${FabricInstallerUrl}")) + { + "Installer downloaded..." + $script:LauncherJarLocation = "fabric-server-launch.jar" + $script:MinecraftServerJarLocation = "server.jar" + RunJavaCommand "-jar fabric-installer.jar server -mcversion ${MinecraftVersion} -loader ${ModLoaderVersion} -downloadMinecraft" + + if ((Test-Path -Path 'fabric-server-launch.jar' -PathType Leaf)) + { + DeleteFileSilently '.fabric-installer' -Recurse + DeleteFileSilently 'fabric-installer.jar' + "Installation complete. fabric-installer.jar deleted." + } + else + { + DeleteFileSilently 'fabric-installer.jar' + "fabric-server-launch.jar not found. Maybe the Fabric servers are having trouble." + "Please try again in a couple of minutes and check your internet connection." + Crash + } + } + else + { + "fabric-server-launch.jar present. Moving on..." + $script:LauncherJarLocation = "fabric-server-launcher.jar" + $script:MinecraftServerJarLocation = "server.jar" + } + } + $script:ServerRunCommand = "-Dlog4j2.formatMsgNoLookups=true ${script:Args} -jar ${script:LauncherJarLocation} nogui" + "" +} + + +# If modloader = Quilt, run Quilt-speci}c checks +Function global:SetupQuilt +{ + "" + "Running Quilt checks and setup..." + + $QuiltInstallerUrl = "https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/${QuiltInstallerVersion}/quilt-installer-${QuiltInstallerVersion}.jar" + + if ((ConvertFrom-JSON (Invoke-WebRequest -Uri "https://meta.fabricmc.net/v2/versions/intermediary/${MinecraftVersion}")).Length -eq 0) + { + "Quilt is not available for Minecraft ${MinecraftVersion}, Quilt ${ModLoaderVersion}." + Crash + } + elseif ((DownloadIfNotExists "quilt-server-launch.jar" "quilt-installer.jar" "${QuiltInstallerUrl}")) + { + "Installer downloaded. Installing..." + RunJavaCommand "-jar quilt-installer.jar install server ${MinecraftVersion} --download-server --install-dir=." + + if ((Test-Path -Path 'quilt-server-launch.jar' -PathType Leaf)) + { + DeleteFileSilently 'quilt-installer.jar' + "Installation complete. quilt-installer.jar deleted." + } + else + { + DeleteFileSilently 'quilt-installer.jar' + "quilt-server-launch.jar not found. Maybe the Quilt servers are having trouble." + "Please try again in a couple of minutes and check your internet connection." + Crash + } + + } + else + { + "quilt-server-launch.jar present. Moving on..." + } + $script:LauncherJarLocation = "quilt-server-launch.jar" + $script:MinecraftServerJarLocation = "server.jar" + $script:ServerRunCommand = "-Dlog4j2.formatMsgNoLookups=true ${Args} -jar ${LauncherJarLocation} nogui" + "" +} + +# Check for a minecraft server and download it if necessary +Function global:Minecraft +{ + "" + if (($ModLoader -eq "Fabric") -and (${ImprovedFabricLauncherAvailable} -eq "200")) + { + "Skipping Minecraft Server JAR checks because we are using the improved Fabric Server Launcher." + } + else + { + (DownloadIfNotExists "${MinecraftServerJarLocation}" "${MinecraftServerJarLocation}" "${MinecraftServerUrl}") > $null + } + "" +} + +# Check for eula.txt and generate if necessary +Function Eula +{ + "" + if (!(Test-Path -Path 'eula.txt' -PathType Leaf)) + { + "Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA." + "Mojang's EULA is available to read at https://aka.ms/MinecraftEULA" + "If you agree to Mojang's EULA then type 'I agree'" + $Answer = Read-Host -Prompt 'Answer: ' + + if (${Answer} -eq "I agree") + { + "User agreed to Mojang's EULA." + + "#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).`n" + + "eula=true" | Out-File eula.txt -encoding utf8 + } + else + { + "User did not agree to Mojang's EULA." + "Entered: ${Answer}" + "You can not run a Minecraft server unless you agree to Mojang#s EULA." + Crash + } + } + else + { + "eula.txt present. Moving on..." + } + "" +} + +if ( ${PSScriptRoot}.Contains(" ")) +{ + "WARNING! The current location of this script contains spaces. This may cause this server to crash!" + "It is strongly recommended to move this server pack to a location whose path does NOT contain SPACES!" + "" + "Current path:" + "${PSScriptRoot}" + "" + + $WhyMustPowerShellBeThisWayLikeSeriouslyWhatTheFrag = Read-Host -Prompt 'Are you sure you want to continue? (Yes/No): ' + + if (${WhyMustPowerShellBeThisWayLikeSeriouslyWhatTheFrag} -eq "Yes") + { + "Alrighty. Prepare for unforseen consequences, Mr. Freeman..." + } + else + { + Crash + } +} + +# Main +if ("${ModLoader}" -eq "Forge") +{ + SetupForge +} +elseif ( "${ModLoader}" -eq "Fabric" ) +{ + SetupFabric +} +elseif ( "${ModLoader}" -eq "Quilt" ) +{ + SetupQuilt +} +else +{ + "Incorrect modloader specified." + Crash +} + +Minecraft +Eula + +"" +"Starting server..." +"" +"Minecraft version: ${MinecraftVersion}" +"Modloader: ${ModLoader}" +"Modloader version: ${ModLoaderVersion}" +if (!("${LauncherJarLocation}" -eq "do_not_manually_edit")) +{ + "Launcher JAR: ${LauncherJarLocation}" +} +"" +"Java args: ${Args}" +"Java path: ${Java}" +"Run Command: ${Java} ${ServerRunCommand}" +"Java version:" +RunJavaCommand "-version" +"" + +RunJavaCommand "${ServerRunCommand}" + +"" +"Exiting..." +PauseScript +exit 0 diff --git a/backend/main/resources/de/griefed/resources/server_files/default_template.sh b/backend/main/resources/de/griefed/resources/server_files/default_template.sh new file mode 100644 index 0000000000000000000000000000000000000000..7a4c72812cea186a1f048112c304a6d68ee0f0c0 --- /dev/null +++ b/backend/main/resources/de/griefed/resources/server_files/default_template.sh @@ -0,0 +1,347 @@ +#!/usr/bin/env bash + +# Start script generated by ServerPackCreator SPC_SERVERPACKCREATOR_VERSION_SPC. +# Depending on which modloader is set, different checks are run to ensure the server will start accordingly. +# If the modloader checks and setup are passed, Minecraft and EULA checks are run. +# If everything is in order, the server is started. + +if [[ "$(id -u)" == "0" ]]; then + echo "Warning! Running with administrator-privileges is not recommended." +fi + +MINECRAFT_VERSION="SPC_MINECRAFT_VERSION_SPC" +MODLOADER="SPC_MODLOADER_SPC" +MODLOADER_VERSION="SPC_MODLOADER_VERSION_SPC" +ARGS="SPC_JAVA_ARGS_SPC" +JAVA="SPC_JAVA_SPC" +FABRIC_INSTALLER_VERSION="SPC_FABRIC_INSTALLER_VERSION_SPC" +QUILT_INSTALLER_VERSION="SPC_QUILT_INSTALLER_VERSION_SPC" +MINECRAFT_SERVER_URL="SPC_MINECRAFT_SERVER_URL_SPC" + +# Variables with do_not_manually_edit are set automatically during script execution, +# so manually editing them will have no effect, as they will be overridden. +MINECRAFT_SERVER_JAR_LOCATION="do_not_manually_edit" +LAUNCHER_JAR_LOCATION="do_not_manually_edit" +SERVER_RUN_COMMAND="do_not_manually_edit" + +crash() { + echo "Exiting..." + read -n 1 -s -r -p "Press any key to continue" + exit 1 +} + +# $1 = Filename to check for +# $2 = Filename to save download as +# $3 = URL to download $2 from +# true if the file was successfully downloaded, false if it already exists +downloadIfNotExist() { + if [[ ! -s "${1}" ]]; then + echo "${1} could not be found." >&2 + echo "Downloading ${2}" >&2 + echo "from ${3}" >&2 + wget -q --progress=bar --show-progress -O "./${2}" "${3}" + if [[ -s "${2}" ]]; then + echo "Download complete." >&2 + echo "true" + fi + else + echo "${1} present." >&2 + echo "false" + fi +} + +runJavaCommand() { + "$JAVA" ${1} +} + +# If modloader = Forge, run Forge-specific checks +setup_forge() { + echo "" + echo "Running Forge checks and setup..." + + FORGE_INSTALLER_URL="https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}-installer.jar" + + FORGE_JAR_LOCATION="do_not_manually_edit" + IFS="." read -ra MINOR <<<"${MINECRAFT_VERSION}" + + if [[ ${MINOR[1]} -le 16 ]]; then + + FORGE_JAR_LOCATION="forge.jar" + LAUNCHER_JAR_LOCATION="forge.jar" + MINECRAFT_SERVER_JAR_LOCATION="minecraft_server.${MINECRAFT_VERSION}.jar" + SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui" + + else + + FORGE_JAR_LOCATION="libraries/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}-server.jar" + MINECRAFT_SERVER_JAR_LOCATION="libraries/net/minecraft/server/${MINECRAFT_VERSION}/server-${MINECRAFT_VERSION}.jar" + SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true @user_jvm_args.txt @libraries/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/unix_args.txt nogui" + + if [[ ! -s "user_jvm_args.txt" ]]; then + + { + echo "# Xmx and Xms set the maximum and minimum RAM usage, respectively." + echo "# They can take any number, followed by an M or a G." + echo "# M means Megabyte, G means Gigabyte." + echo "# For example, to set the maximum to 3GB: -Xmx3G" + echo "# To set the minimum to 2.5GB: -Xms2500M" + echo "# A good default for a modded server is 4GB." + echo "# Uncomment the next line to set it." + echo "# -Xmx4G" + echo "${ARGS}" + } >>user_jvm_args.txt + + else + echo "user_jvm_args.txt present..." + fi + + fi + + if [[ $(downloadIfNotExist "${FORGE_JAR_LOCATION}" "forge-installer.jar" "${FORGE_INSTALLER_URL}") == "true" ]]; then + + echo "Forge Installer downloaded. Installing..." + runJavaCommand "-jar forge-installer.jar --installServer" + + if [[ ${MINOR[1]} -gt 16 ]]; then + + rm -f run.bat + rm -f run.sh + + else + + echo "Renaming forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}.jar to forge.jar" + mv forge-"${MINECRAFT_VERSION}"-"${MODLOADER_VERSION}".jar forge.jar + + fi + + if [[ -s "${FORGE_JAR_LOCATION}" ]]; then + + rm -f forge-installer.jar + rm -f forge-installer.jar.log + echo "Installation complete. forge-installer.jar deleted." + + else + + rm -f forge-installer.jar + echo "Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection." + crash + + fi + + fi + echo "" +} + +# If modloader = Fabric, run Fabric-specific checks +setup_fabric() { + echo "" + echo "Running Fabric checks and setup..." + + FABRIC_INSTALLER_URL="https://maven.fabricmc.net/net/fabricmc/fabric-installer/${FABRIC_INSTALLER_VERSION}/fabric-installer-${FABRIC_INSTALLER_VERSION}.jar" + FABRIC_CHECK_URL="https://meta.fabricmc.net/v2/versions/loader/${MINECRAFT_VERSION}/${MODLOADER_VERSION}/server/json" + FABRIC_AVAILABLE="$(wget --server-response --spider --quiet ${FABRIC_CHECK_URL} 2>&1 | awk 'NR==1{print $2}')" + IMPROVED_FABRIC_LAUNCHER_URL="https://meta.fabricmc.net/v2/versions/loader/${MINECRAFT_VERSION}/${MODLOADER_VERSION}/${FABRIC_INSTALLER_VERSION}/server/jar" + IMPROVED_FABRIC_LAUNCHER_AVAILABLE="$(wget --server-response --spider --quiet ${IMPROVED_FABRIC_LAUNCHER_URL} 2>&1 | awk 'NR==1{print $2}')" + + if [[ "$IMPROVED_FABRIC_LAUNCHER_AVAILABLE" == "200" ]]; then + + echo "Improved Fabric Server Launcher available..." + echo "The improved launcher will be used to run this Fabric server." + LAUNCHER_JAR_LOCATION="fabric-server-launcher.jar" + downloadIfNotExist "fabric-server-launcher.jar" "fabric-server-launcher.jar" "${IMPROVED_FABRIC_LAUNCHER_URL}" >/dev/null + + elif [[ "${FABRIC_AVAILABLE}" != "200" ]]; then + + echo "Fabric is not available for Minecraft ${MINECRAFT_VERSION}, Fabric ${MODLOADER_VERSION}." + crash + + elif [[ $(downloadIfNotExist "fabric-server-launch.jar" "fabric-installer.jar" "${FABRIC_INSTALLER_URL}") == "true" ]]; then + + echo "Installer downloaded..." + LAUNCHER_JAR_LOCATION="fabric-server-launch.jar" + MINECRAFT_SERVER_JAR_LOCATION="server.jar" + runJavaCommand "-jar fabric-installer.jar server -mcversion ${MINECRAFT_VERSION} -loader ${MODLOADER_VERSION} -downloadMinecraft" + + if [[ -s "fabric-server-launch.jar" ]]; then + + rm -rf .fabric-installer + rm -f fabric-installer.jar + echo "Installation complete. fabric-installer.jar deleted." + + else + + rm -f fabric-installer.jar + echo "fabric-server-launch.jar not found. Maybe the Fabric servers are having trouble." + echo "Please try again in a couple of minutes and check your internet connection." + crash + + fi + + else + + echo "fabric-server-launch.jar present. Moving on..." + LAUNCHER_JAR_LOCATION="fabric-server-launcher.jar" + MINECRAFT_SERVER_JAR_LOCATION="server.jar" + + fi + + SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui" + echo "" +} + +# If modloader = Quilt, run Quilt-specific checks +setup_quilt() { + echo "" + echo "Running Quilt checks and setup..." + + QUILT_INSTALLER_URL="https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/${QUILT_INSTALLER_VERSION}/quilt-installer-${QUILT_INSTALLER_VERSION}.jar" + QUILT_CHECK_URL="https://meta.fabricmc.net/v2/versions/intermediary/${MINECRAFT_VERSION}" + QUILT_AVAILABLE="$(wget -qO- ${QUILT_CHECK_URL})" + + if [[ "${#QUILT_AVAILABLE}" -eq "2" ]]; then + + echo "Quilt is not available for Minecraft ${MINECRAFT_VERSION}, Quilt ${MODLOADER_VERSION}." + crash + + elif [[ $(downloadIfNotExist "quilt-server-launch.jar" "quilt-installer.jar" "${QUILT_INSTALLER_URL}") == "true" ]]; then + + echo "Installer downloaded. Installing..." + runJavaCommand "-jar quilt-installer.jar install server ${MINECRAFT_VERSION} --download-server --install-dir=." + + if [[ -s "quilt-server-launch.jar" ]]; then + + rm quilt-installer.jar + echo "Installation complete. quilt-installer.jar deleted." + + else + + rm -f quilt-installer.jar + echo "quilt-server-launch.jar not found. Maybe the Quilt servers are having trouble." + echo "Please try again in a couple of minutes and check your internet connection." + crash + + fi + + else + echo "quilt-server-launch.jar present. Moving on..." + fi + + LAUNCHER_JAR_LOCATION="quilt-server-launch.jar" + MINECRAFT_SERVER_JAR_LOCATION="server.jar" + SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui" + echo "" +} + +# Check for a minecraft server and download it if necessary +minecraft() { + echo "" + if [[ "${MODLOADER}" == "Fabric" && "$IMPROVED_FABRIC_LAUNCHER_AVAILABLE" == "200" ]]; then + + echo "Skipping Minecraft Server JAR checks because we are using the improved Fabric Server Launcher." + + else + + downloadIfNotExist "${MINECRAFT_SERVER_JAR_LOCATION}" "${MINECRAFT_SERVER_JAR_LOCATION}" "${MINECRAFT_SERVER_URL}" >/dev/null + + fi + echo "" +} + +# Check for eula.txt and generate if necessary +eula() { + echo "" + if [[ ! -s "eula.txt" ]]; then + + echo "Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA." + echo "Mojang's EULA is available to read at https://aka.ms/MinecraftEULA" + echo "If you agree to Mojang's EULA then type 'I agree'" + echo -n "Response: " + read -r ANSWER + + if [[ "${ANSWER}" == "I agree" ]]; then + + echo "User agreed to Mojang's EULA." + echo "#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA)." >eula.txt + echo "eula=true" >>eula.txt + + else + + echo "User did not agree to Mojang's EULA." + echo "Entered: ${ANSWER}" + crash + + fi + + else + echo "eula.txt present. Moving on..." + fi + echo "" +} + +# Main +if [[ "${MODLOADER}" == "Forge" ]]; then + + setup_forge + +elif [[ "${MODLOADER}" == "Fabric" ]]; then + + setup_fabric + +elif [[ "${MODLOADER}" == "Quilt" ]]; then + + setup_quilt + +else + + echo "Incorrect modloader specified." + crash + +fi + +if [[ "${PWD}" == *" "* ]]; then + + echo "WARNING! The current location of this script contains spaces. This may cause this server to crash!" + echo "It is strongly recommended to move this server pack to a location whose path does NOT contain SPACES!" + echo "" + echo "Current path:" + echo "${PWD}t" + echo "" + + echo -n "Are you sure you want to continue? (Yes/No): " + read -r ITIS2022WHYARESPACESSTILLSUCHAPROBLEMWHATTHEFRAG + + if [[ "${ITIS2022WHYARESPACESSTILLSUCHAPROBLEMWHATTHEFRAG}" == "Yes" ]]; then + + echo "Alrighty. Prepare for unforseen consequences, Mr. Freeman..." + + else + crash + fi +fi + +minecraft +eula + +echo "" +echo "Starting server..." +echo "" +echo "Minecraft version: ${MINECRAFT_VERSION}" +echo "Modloader: ${MODLOADER}" +echo "Modloader version: ${MODLOADER_VERSION}" +if [[ ${LAUNCHER_JAR_LOCATION} != "do_not_manually_edit" ]]; then + echo "Launcher JAR: ${LAUNCHER_JAR_LOCATION}" +fi +echo "" +echo "Java args: ${ARGS}" +echo "Java path: ${JAVA}" +echo "Run Command: ${JAVA} ${SERVER_RUN_COMMAND}" +echo "Java version:" +"${JAVA}" -version +echo "" + +runJavaCommand "${SERVER_RUN_COMMAND}" + +echo "" +echo "Exiting..." +read -n 1 -s -r -p "Press any key to continue" +exit 0 diff --git a/backend/main/resources/serverpackcreator.properties b/backend/main/resources/serverpackcreator.properties index 0e8d41a3841c3b1ebe5f5f8817d12e7577df2442..fb0b15fc1b75e242d9b997864cea286db37f5374 100644 --- a/backend/main/resources/serverpackcreator.properties +++ b/backend/main/resources/serverpackcreator.properties @@ -19,4 +19,5 @@ de.griefed.serverpackcreator.configuration.saveloadedconfig=false de.griefed.serverpackcreator.configuration.directories.mustinclude=mods,config,defaultconfigs de.griefed.serverpackcreator.plugins.directory=./plugins de.griefed.serverpackcreator.serverpack.zip.exclude=minecraft_server.MINECRAFT_VERSION.jar,server.jar,libraries/net/minecraft/server/MINECRAFT_VERSION/server-MINECRAFT_VERSION.jar -de.griefed.serverpackcreator.serverpack.zip.exclude.enabled=true \ No newline at end of file +de.griefed.serverpackcreator.serverpack.zip.exclude.enabled=true +de.griefed.serverpackcreator.serverpack.script.template=default_template.ps1,default_template.sh \ No newline at end of file diff --git a/backend/test/java/de/griefed/serverpackcreator/ApplicationPropertiesTest.java b/backend/test/java/de/griefed/serverpackcreator/ApplicationPropertiesTest.java index 19a056d945bd0474511ec5b061d2d3502b39f36a..fa61b48c0922387d2cda75b4014365c7e311b802 100644 --- a/backend/test/java/de/griefed/serverpackcreator/ApplicationPropertiesTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/ApplicationPropertiesTest.java @@ -30,15 +30,6 @@ public class ApplicationPropertiesTest { APPLICATIONPROPERTIES.SERVERPACKCREATOR_PROPERTIES(), new File("serverpackcreator.properties")); - Assertions.assertNotNull(APPLICATIONPROPERTIES.START_SCRIPT_WINDOWS()); - Assertions.assertEquals(APPLICATIONPROPERTIES.START_SCRIPT_WINDOWS(), new File("start.bat")); - - Assertions.assertNotNull(APPLICATIONPROPERTIES.START_SCRIPT_LINUX()); - Assertions.assertEquals(APPLICATIONPROPERTIES.START_SCRIPT_LINUX(), new File("start.sh")); - - Assertions.assertNotNull(APPLICATIONPROPERTIES.USER_JVM_ARGS()); - Assertions.assertEquals(APPLICATIONPROPERTIES.USER_JVM_ARGS(), new File("user_jvm_args.txt")); - Assertions.assertNotNull(APPLICATIONPROPERTIES.FALLBACK_CLIENTSIDE_MODS()); Assertions.assertEquals( APPLICATIONPROPERTIES.FALLBACK_CLIENTSIDE_MODS(), diff --git a/backend/test/java/de/griefed/serverpackcreator/ConfigurationHandlerTest.java b/backend/test/java/de/griefed/serverpackcreator/ConfigurationHandlerTest.java index b679f2a87130061a663bed4794471528aa9e3994..64d9768201d5eeb705c3177504c8cc147af4312d 100644 --- a/backend/test/java/de/griefed/serverpackcreator/ConfigurationHandlerTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/ConfigurationHandlerTest.java @@ -1,6 +1,6 @@ package de.griefed.serverpackcreator; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.utilities.ConfigUtilities; import de.griefed.serverpackcreator.utilities.common.Utilities; import de.griefed.serverpackcreator.versionmeta.VersionMeta; @@ -28,7 +28,7 @@ class ConfigurationHandlerTest { } ApplicationProperties APPLICATIONPROPERTIES = new ApplicationProperties(); - LocalizationManager LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + I18n I18N = new I18n(APPLICATIONPROPERTIES); ServerPackCreator SERVER_PACK_CREATOR = new ServerPackCreator(new String[] {"--setup"}); SERVER_PACK_CREATOR.run(ServerPackCreator.CommandlineParser.Mode.SETUP); this.VERSIONMETA = @@ -39,12 +39,12 @@ class ConfigurationHandlerTest { APPLICATIONPROPERTIES.FABRIC_INSTALLER_VERSION_MANIFEST_LOCATION(), APPLICATIONPROPERTIES.QUILT_VERSION_MANIFEST_LOCATION(), APPLICATIONPROPERTIES.QUILT_INSTALLER_VERSION_MANIFEST_LOCATION()); - Utilities UTILITIES = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + Utilities UTILITIES = new Utilities(I18N, APPLICATIONPROPERTIES); ConfigUtilities CONFIGUTILITIES = - new ConfigUtilities(LOCALIZATIONMANAGER, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); + new ConfigUtilities(I18N, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); this.CONFIGURATIONHANDLER = new ConfigurationHandler( - LOCALIZATIONMANAGER, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); + I18N, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); } @Test diff --git a/backend/test/java/de/griefed/serverpackcreator/ServerPackCreatorTest.java b/backend/test/java/de/griefed/serverpackcreator/ServerPackCreatorTest.java index 918ed50ae5f260050ed8fe9fd05be7c09bddb025..22eee3a32178182e871e9df7513037b89e596be5 100644 --- a/backend/test/java/de/griefed/serverpackcreator/ServerPackCreatorTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/ServerPackCreatorTest.java @@ -31,6 +31,8 @@ public class ServerPackCreatorTest { Assertions.assertTrue(new File("./server-packs").isDirectory()); Assertions.assertTrue(new File("./server_files/server.properties").exists()); Assertions.assertTrue(new File("./server_files/server-icon.png").exists()); + Assertions.assertTrue(new File("./server_files/default_template.ps1").exists()); + Assertions.assertTrue(new File("./server_files/default_template.sh").exists()); Assertions.assertTrue(new File("./serverpackcreator.conf").exists()); } } diff --git a/backend/test/java/de/griefed/serverpackcreator/ServerPackHandlerTest.java b/backend/test/java/de/griefed/serverpackcreator/ServerPackHandlerTest.java index 08c6f74d2fe97e217153dd99e0383da92c575336..761616459d9268cf81d9b0d73251a40ea57e9587 100644 --- a/backend/test/java/de/griefed/serverpackcreator/ServerPackHandlerTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/ServerPackHandlerTest.java @@ -2,7 +2,7 @@ package de.griefed.serverpackcreator; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.plugins.ApplicationPlugins; import de.griefed.serverpackcreator.spring.serverpack.ServerPackModel; import de.griefed.serverpackcreator.utilities.ConfigUtilities; @@ -36,7 +36,7 @@ class ServerPackHandlerTest { } ApplicationProperties APPLICATIONPROPERTIES = new ApplicationProperties(); - LocalizationManager LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + I18n I18N = new I18n(APPLICATIONPROPERTIES); ServerPackCreator SERVER_PACK_CREATOR = new ServerPackCreator(new String[] {"--setup"}); SERVER_PACK_CREATOR.run(ServerPackCreator.CommandlineParser.Mode.SETUP); VersionMeta VERSIONMETA = @@ -47,16 +47,16 @@ class ServerPackHandlerTest { APPLICATIONPROPERTIES.FABRIC_INSTALLER_VERSION_MANIFEST_LOCATION(), APPLICATIONPROPERTIES.QUILT_VERSION_MANIFEST_LOCATION(), APPLICATIONPROPERTIES.QUILT_INSTALLER_VERSION_MANIFEST_LOCATION()); - Utilities UTILITIES = new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + Utilities UTILITIES = new Utilities(I18N, APPLICATIONPROPERTIES); ConfigUtilities CONFIGUTILITIES = - new ConfigUtilities(LOCALIZATIONMANAGER, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); + new ConfigUtilities(I18N, UTILITIES, APPLICATIONPROPERTIES, VERSIONMETA); this.CONFIGURATIONHANDLER = new ConfigurationHandler( - LOCALIZATIONMANAGER, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); + I18N, VERSIONMETA, APPLICATIONPROPERTIES, UTILITIES, CONFIGUTILITIES); ApplicationPlugins PLUGINMANAGER = new ApplicationPlugins(); this.SERVERPACKHANDLER = new ServerPackHandler( - LOCALIZATIONMANAGER, APPLICATIONPROPERTIES, VERSIONMETA, UTILITIES, PLUGINMANAGER); + I18N, APPLICATIONPROPERTIES, VERSIONMETA, UTILITIES, PLUGINMANAGER); } @Test @@ -78,7 +78,7 @@ class ServerPackHandlerTest { Assertions.assertTrue(new File("server-packs/forge_tests/forge.jar").exists()); Assertions.assertTrue(new File("server-packs/forge_tests/server.properties").exists()); Assertions.assertTrue(new File("server-packs/forge_tests/server-icon.png").exists()); - Assertions.assertTrue(new File("server-packs/forge_tests/start.bat").exists()); + Assertions.assertTrue(new File("server-packs/forge_tests/start.ps1").exists()); Assertions.assertTrue(new File("server-packs/forge_tests/start.sh").exists()); try { Files.copy( diff --git a/backend/test/java/de/griefed/serverpackcreator/WebServiceTest.java b/backend/test/java/de/griefed/serverpackcreator/WebServiceTest.java index 3a2fb63122a9987a13f78180dd4bd63aab0f58c1..84f1ab67f03854e5fe070803d8cc36d600bea5f4 100644 --- a/backend/test/java/de/griefed/serverpackcreator/WebServiceTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/WebServiceTest.java @@ -1,6 +1,6 @@ package de.griefed.serverpackcreator; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; @@ -14,7 +14,7 @@ import org.springframework.context.annotation.PropertySources; public class WebServiceTest { private final ServerPackCreator SERVERPACKCREATOR; - private final LocalizationManager LOCALIZATIONMANAGER; + private final I18n I18N; private final ApplicationProperties APPLICATIONPROPERTIES; WebServiceTest() throws IOException { @@ -34,7 +34,7 @@ public class WebServiceTest { } this.APPLICATIONPROPERTIES = new ApplicationProperties(); - this.LOCALIZATIONMANAGER = new LocalizationManager(APPLICATIONPROPERTIES); + this.I18N = new I18n(APPLICATIONPROPERTIES); this.SERVERPACKCREATOR = new ServerPackCreator(new String[] {"--setup"}); this.SERVERPACKCREATOR.run(ServerPackCreator.CommandlineParser.Mode.SETUP); this.SERVERPACKCREATOR.checkDatabase(); diff --git a/backend/test/java/de/griefed/serverpackcreator/i18n/LocalizationManagerTest.java b/backend/test/java/de/griefed/serverpackcreator/i18n/I18nTest.java similarity index 57% rename from backend/test/java/de/griefed/serverpackcreator/i18n/LocalizationManagerTest.java rename to backend/test/java/de/griefed/serverpackcreator/i18n/I18nTest.java index 5c9fdcb54c311c7641549b6438e5301e9ac7ec1d..4caa5e58148da41ba07d404bcfcfaef30531aa0a 100644 --- a/backend/test/java/de/griefed/serverpackcreator/i18n/LocalizationManagerTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/i18n/I18nTest.java @@ -12,20 +12,20 @@ import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class LocalizationManagerTest { +public class I18nTest { - private final Logger LOG = LogManager.getLogger(LocalizationManagerTest.class); + private final Logger LOG = LogManager.getLogger(I18nTest.class); - LocalizationManagerTest() { + I18nTest() { FileUtils.deleteQuietly(new File("lang")); } @Test void newTest() { FileUtils.deleteQuietly(new File("lang")); - LocalizationManager localizationManager = new LocalizationManager(); + I18n i18n = new I18n(); Assertions.assertEquals( - "English (United States)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "English (United States)", i18n.getMessage("localeUnlocalizedName")); } @Test @@ -33,20 +33,20 @@ public class LocalizationManagerTest { FileUtils.deleteQuietly(new File("lang")); LOG.info("newLocaleTest() en_us"); - LocalizationManager localizationManager = - new LocalizationManager(new ApplicationProperties(), "en_us"); + I18n i18n = + new I18n(new ApplicationProperties(), "en_us"); Assertions.assertEquals( - "English (United States)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "English (United States)", i18n.getMessage("localeUnlocalizedName")); LOG.info("newLocaleTest() uk_ua"); - localizationManager = new LocalizationManager(new ApplicationProperties(), "uk_ua"); + i18n = new I18n(new ApplicationProperties(), "uk_ua"); Assertions.assertEquals( - "Ukrainian (Ukraine)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "Ukrainian (Ukraine)", i18n.getMessage("localeUnlocalizedName")); LOG.info("newLocaleTest() de_de"); - localizationManager = new LocalizationManager(new ApplicationProperties(), "de_de"); + i18n = new I18n(new ApplicationProperties(), "de_de"); Assertions.assertEquals( - "German (Germany)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "German (Germany)", i18n.getMessage("localeUnlocalizedName")); } @Test @@ -54,7 +54,7 @@ public class LocalizationManagerTest { FileUtils.deleteQuietly(new File("lang")); LOG.info("newPropertiesTest() en_us"); - LocalizationManager localizationManager; + I18n i18n; ApplicationProperties applicationProperties = new ApplicationProperties(); try (FileInputStream fileInputStream = new FileInputStream("backend/test/resources/testresources/languages/en_us.properties")) { @@ -64,9 +64,9 @@ public class LocalizationManagerTest { } catch (Exception ex) { ex.printStackTrace(); } - localizationManager = new LocalizationManager(applicationProperties); + i18n = new I18n(applicationProperties); Assertions.assertEquals( - "English (United States)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "English (United States)", i18n.getMessage("localeUnlocalizedName")); LOG.info("newPropertiesTest() de_de"); try (FileInputStream fileInputStream = @@ -77,9 +77,9 @@ public class LocalizationManagerTest { } catch (Exception ex) { ex.printStackTrace(); } - localizationManager = new LocalizationManager(applicationProperties); + i18n = new I18n(applicationProperties); Assertions.assertEquals( - "German (Germany)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "German (Germany)", i18n.getMessage("localeUnlocalizedName")); LOG.info("newPropertiesTest() uk_ua"); try (FileInputStream fileInputStream = @@ -90,9 +90,9 @@ public class LocalizationManagerTest { } catch (Exception ex) { ex.printStackTrace(); } - localizationManager = new LocalizationManager(applicationProperties); + i18n = new I18n(applicationProperties); Assertions.assertEquals( - "Ukrainian (Ukraine)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "Ukrainian (Ukraine)", i18n.getMessage("localeUnlocalizedName")); } @Test @@ -104,25 +104,25 @@ public class LocalizationManagerTest { } LOG.info("getLocalizedStringTest() en_us"); - LocalizationManager localizationManager = - new LocalizationManager(new ApplicationProperties(), "en_us"); + I18n i18n = + new I18n(new ApplicationProperties(), "en_us"); Assertions.assertEquals( - "English (United States)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "English (United States)", i18n.getMessage("localeUnlocalizedName")); LOG.info("getLocalizedStringTest() uk_ua"); - localizationManager = new LocalizationManager(new ApplicationProperties(), "uk_ua"); + i18n = new I18n(new ApplicationProperties(), "uk_ua"); Assertions.assertEquals( - "Ukrainian (Ukraine)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "Ukrainian (Ukraine)", i18n.getMessage("localeUnlocalizedName")); LOG.info("getLocalizedStringTest() de_de"); - localizationManager = new LocalizationManager(new ApplicationProperties(), "de_de"); + i18n = new I18n(new ApplicationProperties(), "de_de"); Assertions.assertEquals( - "German (Germany)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "German (Germany)", i18n.getMessage("localeUnlocalizedName")); LOG.info("getLocalizedStringTest() ab_cd"); - localizationManager = new LocalizationManager(new ApplicationProperties(), "ab_cd"); + i18n = new I18n(new ApplicationProperties(), "ab_cd"); Assertions.assertEquals( - "English (United States)", localizationManager.getLocalizedString("localeUnlocalizedName")); + "English (United States)", i18n.getMessage("localeUnlocalizedName")); } @Test @@ -136,9 +136,9 @@ public class LocalizationManagerTest { } LOG.info("customLanguageTest() ef_gh"); - LocalizationManager localizationManager = - new LocalizationManager(new ApplicationProperties(), "ef_gh"); + I18n i18n = + new I18n(new ApplicationProperties(), "ef_gh"); Assertions.assertEquals( - "I bims 1 Sprache", localizationManager.getLocalizedString("localeUnlocalizedName")); + "I bims 1 Sprache", i18n.getMessage("localeUnlocalizedName")); } } diff --git a/backend/test/java/de/griefed/serverpackcreator/utilities/ConfigUtilitiesTest.java b/backend/test/java/de/griefed/serverpackcreator/utilities/ConfigUtilitiesTest.java index a0aeb29fd6aa069ed6cc9dff87e1c99cef1310ca..bdcedd2cb109c639261461dcd0fb97fbeab1c755 100644 --- a/backend/test/java/de/griefed/serverpackcreator/utilities/ConfigUtilitiesTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/utilities/ConfigUtilitiesTest.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import de.griefed.serverpackcreator.ApplicationProperties; import de.griefed.serverpackcreator.ConfigurationModel; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import de.griefed.serverpackcreator.utilities.common.Utilities; import de.griefed.serverpackcreator.versionmeta.VersionMeta; import java.io.File; @@ -23,7 +23,7 @@ public class ConfigUtilitiesTest { private final ConfigUtilities CONFIGUTILITIES; ConfigUtilitiesTest() throws IOException { - LocalizationManager LOCALIZATIONMANAGER = new LocalizationManager(); + I18n I18N = new I18n(); ApplicationProperties APPLICATIONPROPERTIES = new ApplicationProperties(); VersionMeta VERSIONMETA = new VersionMeta( @@ -35,8 +35,8 @@ public class ConfigUtilitiesTest { APPLICATIONPROPERTIES.QUILT_INSTALLER_VERSION_MANIFEST_LOCATION()); this.CONFIGUTILITIES = new ConfigUtilities( - LOCALIZATIONMANAGER, - new Utilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES), + I18N, + new Utilities(I18N, APPLICATIONPROPERTIES), APPLICATIONPROPERTIES, VERSIONMETA); } diff --git a/backend/test/java/de/griefed/serverpackcreator/utilities/common/BooleanUtilitiesTest.java b/backend/test/java/de/griefed/serverpackcreator/utilities/common/BooleanUtilitiesTest.java index 7524df1cbc26d50871b546446e636de9865c8c26..6d256424ecc371d125a63d99c54b812fc7ee07c0 100644 --- a/backend/test/java/de/griefed/serverpackcreator/utilities/common/BooleanUtilitiesTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/utilities/common/BooleanUtilitiesTest.java @@ -1,20 +1,20 @@ package de.griefed.serverpackcreator.utilities.common; import de.griefed.serverpackcreator.ApplicationProperties; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class BooleanUtilitiesTest { - private final LocalizationManager LOCALIZATIONMANAGER; + private final I18n I18N; private final ApplicationProperties APPLICATIONPROPERTIES; private final BooleanUtilities BOOLEANUTILITIES; BooleanUtilitiesTest() { - this.LOCALIZATIONMANAGER = new LocalizationManager(); + this.I18N = new I18n(); this.APPLICATIONPROPERTIES = new ApplicationProperties(); - this.BOOLEANUTILITIES = new BooleanUtilities(LOCALIZATIONMANAGER, APPLICATIONPROPERTIES); + this.BOOLEANUTILITIES = new BooleanUtilities(); } @Test diff --git a/backend/test/java/de/griefed/serverpackcreator/utilities/common/WebUtilitiesTest.java b/backend/test/java/de/griefed/serverpackcreator/utilities/common/WebUtilitiesTest.java index 82a61b8403fc88e350651c9d47f5482c16f3009d..6101b4668d3760c38a42276c078bee4973fb2ccc 100644 --- a/backend/test/java/de/griefed/serverpackcreator/utilities/common/WebUtilitiesTest.java +++ b/backend/test/java/de/griefed/serverpackcreator/utilities/common/WebUtilitiesTest.java @@ -1,7 +1,7 @@ package de.griefed.serverpackcreator.utilities.common; import de.griefed.serverpackcreator.ApplicationProperties; -import de.griefed.serverpackcreator.i18n.LocalizationManager; +import de.griefed.serverpackcreator.i18n.I18n; import java.io.File; import java.net.URL; import org.apache.commons.io.FileUtils; @@ -15,7 +15,7 @@ public class WebUtilitiesTest { WebUtilitiesTest() { ApplicationProperties applicationProperties = new ApplicationProperties(); this.WEB_UTILITIES = - new WebUtilities(applicationProperties, new LocalizationManager(applicationProperties)); + new WebUtilities(applicationProperties); } @Test diff --git a/build.gradle b/build.gradle index 4e3c3410a9b1eaa94bfc3cfe8a7047c2f25f1265..f91230cbfde00d9948236fc74ac92edfa32d4d61 100644 --- a/build.gradle +++ b/build.gradle @@ -70,14 +70,14 @@ dependencies { embed 'net.lingala.zip4j:zip4j:2.11.1' embed 'com.moandjiezana.toml:toml4j:0.7.2' embed 'org.xerial:sqlite-jdbc:3.36.0.3' - embed 'org.pf4j:pf4j:3.6.0' + embed 'org.pf4j:pf4j:3.7.0' embed 'com.github.vatbub:mslinks:1.0.5' implementation 'org.jetbrains:annotations:23.0.0' - embed 'org.apache.logging.log4j:log4j-core:2.17.2' - embed 'org.apache.logging.log4j:log4j-api:2.17.2' + embed 'org.apache.logging.log4j:log4j-core:2.18.0' + embed 'org.apache.logging.log4j:log4j-api:2.18.0' embed 'org.apache.logging.log4j:log4j-slf4j-impl:2.18.0' - embed 'org.apache.logging.log4j:log4j-web:2.17.2' + embed 'org.apache.logging.log4j:log4j-web:2.18.0' embed 'org.apache.logging.log4j:log4j-jul:2.18.0' embed 'org.jgroups:jgroups:5.2.2.Final' diff --git a/frontend/package-lock.json b/frontend/package-lock.json index e1a43d274f2c044917e4a6e4a52d03dc96cf1e77..700b9c77fe14275cbc83de8b57a2374cf9868bc9 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -12,19 +12,19 @@ "@quasar/cli": "1.3.2", "@quasar/extras": "1.14.2", "axios": "0.27.2", - "core-js": "3.22.8", - "quasar": "2.7.5", - "tsparticles": "1.42.4", + "core-js": "3.23.4", + "quasar": "2.7.4", + "tsparticles": "1.43.1", "vue": "3.2.37", "vue-class-component": "8.0.0-rc.1" }, "devDependencies": { "@babel/eslint-parser": "7.18.2", "@quasar/app": "3.3.3", - "@types/node": "17.0.24", + "@types/node": "18.0.3", "eslint": "8.19.0", "eslint-config-prettier": "8.5.0", - "eslint-plugin-vue": "9.1.1", + "eslint-plugin-vue": "9.2.0", "eslint-webpack-plugin": "3.2.0" }, "engines": { @@ -2447,9 +2447,9 @@ "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==" }, "node_modules/@types/node": { - "version": "17.0.24", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.24.tgz", - "integrity": "sha512-aveCYRQbgTH9Pssp1voEP7HiuWlD2jW2BO56w+bVrJn04i61yh6mRfoKO6hEYQD9vF+W8Chkwc6j1M36uPkx4g==" + "version": "18.0.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.3.tgz", + "integrity": "sha512-HzNRZtp4eepNitP+BD6k2L6DROIDG4Q0fm4x+dwfsr6LGmROENnok75VGw40628xf+iR24WeMFcHuuBDUAzzsQ==" }, "node_modules/@types/parse-json": { "version": "4.0.0", @@ -3758,14 +3758,20 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001301", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001301.tgz", - "integrity": "sha512-csfD/GpHMqgEL3V3uIgosvh+SVIQvCh43SNu9HRbP1lnxkKm1kjDG4f32PP571JplkLjfS+mg2p1gxR7MYrrIA==", + "version": "1.0.30001364", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001364.tgz", + "integrity": "sha512-9O0xzV3wVyX0SlegIQ6knz+okhBB5pE0PC40MNdwcipjwpxoUEHL24uJ+gG42cgklPjfO5ZjZPme9FTSN3QT2Q==", "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - } + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] }, "node_modules/caw": { "version": "2.0.1", @@ -4451,9 +4457,9 @@ } }, "node_modules/core-js": { - "version": "3.22.8", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.22.8.tgz", - "integrity": "sha512-UoGQ/cfzGYIuiq6Z7vWL1HfkE9U9IZ4Ub+0XSiJTCzvbZzgPA69oDF2f+lgJ6dFFLEdjW5O6svvoKzXX23xFkA==", + "version": "3.23.4", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.23.4.tgz", + "integrity": "sha512-vjsKqRc1RyAJC3Ye2kYqgfdThb3zYnx9CrqoCcjMOENMtQPC7ZViBvlDxwYU/2z2NI/IPuiXw5mT4hWhddqjzQ==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -5836,9 +5842,9 @@ } }, "node_modules/eslint-plugin-vue": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.1.1.tgz", - "integrity": "sha512-W9n5PB1X2jzC7CK6riG0oAcxjmKrjTF6+keL1rni8n57DZeilx/Fulz+IRJK3lYseLNAygN0I62L7DvioW40Tw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.2.0.tgz", + "integrity": "sha512-W2hc+NUXoce8sZtWgZ45miQTy6jNyuSdub5aZ1IBune4JDeAyzucYX0TzkrQ1jMO52sNUDYlCIHDoaNePe0p5g==", "dev": true, "dependencies": { "eslint-utils": "^3.0.0", @@ -10746,9 +10752,9 @@ } }, "node_modules/quasar": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/quasar/-/quasar-2.7.5.tgz", - "integrity": "sha512-DWI0S+bXASfMSPrB8c/LVsXpA4dF7cBUbaJlcrM+1ioTNBHtiudma2Nhk2SDd5bzk9AYVHh5A8JCZuKqQAXt7g==", + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/quasar/-/quasar-2.7.4.tgz", + "integrity": "sha512-8OIa6azm7N6QUPjcZ5AhDCEBha5NnNqt+D1BMIteqaSqkVKFYBf+FMhUCC8R/Tc6Myz85vK7KGPn9tvaC6gXYQ==", "engines": { "node": ">= 10.18.1", "npm": ">= 6.13.4", @@ -11816,6 +11822,7 @@ "version": "0.1.8", "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==", + "deprecated": "Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility", "dev": true }, "node_modules/stackframe": { @@ -12398,9 +12405,9 @@ "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==" }, "node_modules/tsparticles": { - "version": "1.42.4", - "resolved": "https://registry.npmjs.org/tsparticles/-/tsparticles-1.42.4.tgz", - "integrity": "sha512-tfjh6hZFID+5mIdqIvAvmpGymG5kFIxB2k1fs0SIDemo7iL9qnQyvI3HankxfRtCblcwRoEYj/g5phdIhqY8vA==", + "version": "1.43.1", + "resolved": "https://registry.npmjs.org/tsparticles/-/tsparticles-1.43.1.tgz", + "integrity": "sha512-6EuHncwqzoyTlUxc11YH8LVlwVUgpYaZD0yMOeA2OvRqFZ9VQV8EjjQ6ZfXt6pfGA1ObPwU929jveFatxwTQkg==", "deprecated": "Version 2.x is the current version, v1 is obsolete now", "funding": [ { @@ -15547,9 +15554,9 @@ "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==" }, "@types/node": { - "version": "17.0.24", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.24.tgz", - "integrity": "sha512-aveCYRQbgTH9Pssp1voEP7HiuWlD2jW2BO56w+bVrJn04i61yh6mRfoKO6hEYQD9vF+W8Chkwc6j1M36uPkx4g==" + "version": "18.0.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.3.tgz", + "integrity": "sha512-HzNRZtp4eepNitP+BD6k2L6DROIDG4Q0fm4x+dwfsr6LGmROENnok75VGw40628xf+iR24WeMFcHuuBDUAzzsQ==" }, "@types/parse-json": { "version": "4.0.0", @@ -16620,9 +16627,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001301", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001301.tgz", - "integrity": "sha512-csfD/GpHMqgEL3V3uIgosvh+SVIQvCh43SNu9HRbP1lnxkKm1kjDG4f32PP571JplkLjfS+mg2p1gxR7MYrrIA==", + "version": "1.0.30001364", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001364.tgz", + "integrity": "sha512-9O0xzV3wVyX0SlegIQ6knz+okhBB5pE0PC40MNdwcipjwpxoUEHL24uJ+gG42cgklPjfO5ZjZPme9FTSN3QT2Q==", "dev": true }, "caw": { @@ -17151,9 +17158,9 @@ } }, "core-js": { - "version": "3.22.8", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.22.8.tgz", - "integrity": "sha512-UoGQ/cfzGYIuiq6Z7vWL1HfkE9U9IZ4Ub+0XSiJTCzvbZzgPA69oDF2f+lgJ6dFFLEdjW5O6svvoKzXX23xFkA==" + "version": "3.23.4", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.23.4.tgz", + "integrity": "sha512-vjsKqRc1RyAJC3Ye2kYqgfdThb3zYnx9CrqoCcjMOENMtQPC7ZViBvlDxwYU/2z2NI/IPuiXw5mT4hWhddqjzQ==" }, "core-js-compat": { "version": "3.17.3", @@ -18333,9 +18340,9 @@ "requires": {} }, "eslint-plugin-vue": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.1.1.tgz", - "integrity": "sha512-W9n5PB1X2jzC7CK6riG0oAcxjmKrjTF6+keL1rni8n57DZeilx/Fulz+IRJK3lYseLNAygN0I62L7DvioW40Tw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.2.0.tgz", + "integrity": "sha512-W2hc+NUXoce8sZtWgZ45miQTy6jNyuSdub5aZ1IBune4JDeAyzucYX0TzkrQ1jMO52sNUDYlCIHDoaNePe0p5g==", "dev": true, "requires": { "eslint-utils": "^3.0.0", @@ -21788,9 +21795,9 @@ "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==" }, "quasar": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/quasar/-/quasar-2.7.5.tgz", - "integrity": "sha512-DWI0S+bXASfMSPrB8c/LVsXpA4dF7cBUbaJlcrM+1ioTNBHtiudma2Nhk2SDd5bzk9AYVHh5A8JCZuKqQAXt7g==" + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/quasar/-/quasar-2.7.4.tgz", + "integrity": "sha512-8OIa6azm7N6QUPjcZ5AhDCEBha5NnNqt+D1BMIteqaSqkVKFYBf+FMhUCC8R/Tc6Myz85vK7KGPn9tvaC6gXYQ==" }, "query-string": { "version": "5.1.1", @@ -23032,9 +23039,9 @@ "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==" }, "tsparticles": { - "version": "1.42.4", - "resolved": "https://registry.npmjs.org/tsparticles/-/tsparticles-1.42.4.tgz", - "integrity": "sha512-tfjh6hZFID+5mIdqIvAvmpGymG5kFIxB2k1fs0SIDemo7iL9qnQyvI3HankxfRtCblcwRoEYj/g5phdIhqY8vA==" + "version": "1.43.1", + "resolved": "https://registry.npmjs.org/tsparticles/-/tsparticles-1.43.1.tgz", + "integrity": "sha512-6EuHncwqzoyTlUxc11YH8LVlwVUgpYaZD0yMOeA2OvRqFZ9VQV8EjjQ6ZfXt6pfGA1ObPwU929jveFatxwTQkg==" }, "tunnel-agent": { "version": "0.6.0", diff --git a/frontend/package.json b/frontend/package.json index 7a42fae076563f1488fad3c94652d363f45c6b28..f4f9f7ec828b8a0964f8cdff6ee67fd581dac117 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -30,21 +30,19 @@ "@quasar/cli": "1.3.2", "@quasar/extras": "1.14.2", "axios": "0.27.2", - "core-js": "3.22.8", - "tsparticles": "2.0.6", - "vue": "3.2.33", - "quasar": "2.7.5", - "tsparticles": "1.42.4", + "core-js": "3.23.4", + "quasar": "2.7.4", + "tsparticles": "1.43.1", "vue": "3.2.37", "vue-class-component": "8.0.0-rc.1" }, "devDependencies": { "@babel/eslint-parser": "7.18.2", "@quasar/app": "3.3.3", - "@types/node": "17.0.24", "eslint": "8.19.0", + "@types/node": "18.0.3", "eslint-config-prettier": "8.5.0", - "eslint-plugin-vue": "9.1.1", + "eslint-plugin-vue": "9.2.0", "eslint-webpack-plugin": "3.2.0" }, "browserslist": [ diff --git a/frontend/src/layouts/MainLayout.vue b/frontend/src/layouts/MainLayout.vue index efe694034201bbff3947041da9eef68a9d777a43..2ffacae6920df578de26395a0013f17e4c49be93 100644 --- a/frontend/src/layouts/MainLayout.vue +++ b/frontend/src/layouts/MainLayout.vue @@ -1,5 +1,4 @@ <template> - <!-- <div id="tsparticles"/>--> <q-layout view="hHh Lpr lff"> <q-header class="header" elevated reveal> <q-toolbar @@ -292,7 +291,7 @@ export default defineComponent({ "mode": ["bubble", "grab"] }, "onclick": { - "enable": true, + "enable": false, "mode": "push" }, "resize": true diff --git a/img/a_ok.png b/img/a_ok.png new file mode 100644 index 0000000000000000000000000000000000000000..6f9e695fef98d91517cfe5c84b1c2b87fdf8f938 Binary files /dev/null and b/img/a_ok.png differ diff --git a/img/fugly_artifacts.png b/img/fugly_artifacts.png new file mode 100644 index 0000000000000000000000000000000000000000..917dce05a57e473a581e2701aef10812d264cb4c Binary files /dev/null and b/img/fugly_artifacts.png differ