Skip to content
Snippets Groups Projects
Commit d3ee454a authored by Griefed's avatar Griefed :joystick:
Browse files

Merge branch 'develop' into 'main'

Merge develop into main

See merge request !263
parents aa2b7a16 30c9033a
No related branches found
No related tags found
1 merge request!263Merge develop into main
Showing
with 805 additions and 2228 deletions
<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" />
......
<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" />
......
<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" />
......
......@@ -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;
}
/**
......
......@@ -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{"
......
......@@ -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.
......
......@@ -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
*/
......
......@@ -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.
*
......
......@@ -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.
......
......@@ -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.
*
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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()
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment