Class ApiProperties
-
- All Implemented Interfaces:
@Plugin(name = "ServerPackCreatorConfigFactory", category = "Core") public final class ApiProperties extends ConfigurationFactoryBase settings of ServerPackCreator, such as working directories, default list of clientside-only mods, default list of directories to include in a server pack, script templates, java paths and much more.
Griefed
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classApiProperties.CustomXMLConfigurationCustom XmlConfiguration to pass our custom log4j2.xml config to log4j.
Set up the XML configuration with the passed context and config source. For the config source being used, ApiProperties.getConfiguration where multiple attempts at creating a new private val log by lazy { cachedLoggerOf(this.javaClass) } using our own log4j2.xml are made before the default log4j setup is used.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ApiProperties(File propertiesFile)
-
Method Summary
-
Methods inherited from class org.apache.logging.log4j.core.config.ConfigurationFactory
getConfiguration, getConfiguration, getConfiguration, getDefaultPrefix, getInputFromString, getTestPrefix, getVersion, isActive -
Methods inherited from class de.griefed.serverpackcreator.api.ApiProperties
getSupportedTypes -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ApiProperties
ApiProperties(File propertiesFile)
- Parameters:
propertiesFile- serverpackcreator.properties-file containing settings and configurations to load the API with.
-
-
Method Detail
-
getGenerationConfig
final GenerationConfig getGenerationConfig()
-
getNetworkConfig
final NetworkConfig getNetworkConfig()
-
getFallbackDirectoriesInclusion
final TreeSet<String> getFallbackDirectoriesInclusion()
-
getFallbackDirectoriesExclusion
final TreeSet<String> getFallbackDirectoriesExclusion()
-
getFallbackZipExclusions
final TreeSet<String> getFallbackZipExclusions()
-
getFallbackPostInstallCleanupFiles
final TreeSet<String> getFallbackPostInstallCleanupFiles()
-
getFallbackPreInstallCleanupFiles
final TreeSet<String> getFallbackPreInstallCleanupFiles()
-
getFallbackAikarsFlags
final String getFallbackAikarsFlags()
-
getFallbackUpdateURL
final String getFallbackUpdateURL()
-
getFallbackExclusionFilter
final ExclusionFilter getFallbackExclusionFilter()
-
getFallbackOverwriteEnabled
final Boolean getFallbackOverwriteEnabled()
-
getFallbackJavaScriptAutoupdateEnabled
final Boolean getFallbackJavaScriptAutoupdateEnabled()
-
getFallbackCheckingForPreReleasesEnabled
final Boolean getFallbackCheckingForPreReleasesEnabled()
-
getFallbackZipFileExclusionEnabled
final Boolean getFallbackZipFileExclusionEnabled()
-
getFallbackServerPackCleanupEnabled
final Boolean getFallbackServerPackCleanupEnabled()
-
getFallbackMinecraftPreReleasesAvailabilityEnabled
final Boolean getFallbackMinecraftPreReleasesAvailabilityEnabled()
-
getFallbackAutoExcludingModsEnabled
final Boolean getFallbackAutoExcludingModsEnabled()
-
getFallbackCleanupSchedule
final String getFallbackCleanupSchedule()
-
getFallbackVersionSchedule
final String getFallbackVersionSchedule()
-
getFallbackDatabaseCleanupSchedule
final String getFallbackDatabaseCleanupSchedule()
-
getFallbackUpdateServerPack
final Boolean getFallbackUpdateServerPack()
-
getI18n4kConfig
final I18n4kConfigDefault getI18n4kConfig()
-
getUpdateConfig
final UpdateConfig getUpdateConfig()
-
getI18nConfig
final I18nConfig getI18nConfig()
-
getLoggingConfig
final LoggingConfig getLoggingConfig()
-
getClientsideMods
final TreeSet<String> getClientsideMods()
-
getModsWhitelist
final TreeSet<String> getModsWhitelist()
-
getClientsideModsRegex
final TreeSet<String> getClientsideModsRegex()
-
getModsWhitelistRegex
final TreeSet<String> getModsWhitelistRegex()
-
getNetworkConnectTimeout
final Integer getNetworkConnectTimeout()
-
setNetworkConnectTimeout
final Unit setNetworkConnectTimeout(Integer value)
-
getNetworkReadTimeout
final Integer getNetworkReadTimeout()
-
setNetworkReadTimeout
final Unit setNetworkReadTimeout(Integer value)
-
getNetworkDownloadReadTimeout
final Integer getNetworkDownloadReadTimeout()
-
setNetworkDownloadReadTimeout
final Unit setNetworkDownloadReadTimeout(Integer value)
-
getSupportedModloaders
final Array<String> getSupportedModloaders()
-
getApiVersion
final String getApiVersion()
-
getDevBuild
final Boolean getDevBuild()
-
getPreRelease
final Boolean getPreRelease()
-
getConfigVersion
final String getConfigVersion()
-
getFirstRun
final Boolean getFirstRun()
-
getLogLevel
final String getLogLevel()
-
setLogLevel
final Unit setLogLevel(String value)
-
getDirectoriesToInclude
final TreeSet<String> getDirectoriesToInclude()
-
setDirectoriesToInclude
final Unit setDirectoriesToInclude(TreeSet<String> value)
-
getDirectoriesToExclude
final TreeSet<String> getDirectoriesToExclude()
-
setDirectoriesToExclude
final Unit setDirectoriesToExclude(TreeSet<String> value)
-
getPostInstallCleanupFiles
final TreeSet<String> getPostInstallCleanupFiles()
-
setPostInstallCleanupFiles
final Unit setPostInstallCleanupFiles(TreeSet<String> value)
-
getPreInstallCleanupFiles
final TreeSet<String> getPreInstallCleanupFiles()
-
setPreInstallCleanupFiles
final Unit setPreInstallCleanupFiles(TreeSet<String> value)
-
getZipArchiveExclusions
final TreeSet<String> getZipArchiveExclusions()
-
setZipArchiveExclusions
final Unit setZipArchiveExclusions(TreeSet<String> value)
-
getJavaConfig
final JavaConfig getJavaConfig()
-
getJavaPaths
final HashMap<String, String> getJavaPaths()
-
setJavaPaths
final Unit setJavaPaths(HashMap<String, String> value)
-
getScriptTemplates
final TreeSet<File> getScriptTemplates()
-
setScriptTemplates
final Unit setScriptTemplates(TreeSet<File> value)
-
getStartScriptTemplates
final HashMap<String, String> getStartScriptTemplates()
-
setStartScriptTemplates
final Unit setStartScriptTemplates(HashMap<String, String> value)
-
getJavaScriptTemplates
final HashMap<String, String> getJavaScriptTemplates()
-
setJavaScriptTemplates
final Unit setJavaScriptTemplates(HashMap<String, String> value)
-
getUpdateUrl
final URL getUpdateUrl()
-
setUpdateUrl
final Unit setUpdateUrl(URL value)
-
getExclusionFilter
final ExclusionFilter getExclusionFilter()
-
setExclusionFilter
final Unit setExclusionFilter(ExclusionFilter value)
-
isCheckingForPreReleasesEnabled
final Boolean isCheckingForPreReleasesEnabled()
-
setCheckingForPreReleasesEnabled
final Unit setCheckingForPreReleasesEnabled(Boolean value)
-
isZipFileExclusionEnabled
final Boolean isZipFileExclusionEnabled()
-
setZipFileExclusionEnabled
final Unit setZipFileExclusionEnabled(Boolean value)
-
isAutoExcludingModsEnabled
final Boolean isAutoExcludingModsEnabled()
-
setAutoExcludingModsEnabled
final Unit setAutoExcludingModsEnabled(Boolean value)
-
isServerPacksOverwriteEnabled
final Boolean isServerPacksOverwriteEnabled()
-
setServerPacksOverwriteEnabled
final Unit setServerPacksOverwriteEnabled(Boolean value)
-
isServerPackCleanupEnabled
final Boolean isServerPackCleanupEnabled()
-
setServerPackCleanupEnabled
final Unit setServerPackCleanupEnabled(Boolean value)
-
isMinecraftPreReleasesAvailabilityEnabled
final Boolean isMinecraftPreReleasesAvailabilityEnabled()
-
setMinecraftPreReleasesAvailabilityEnabled
final Unit setMinecraftPreReleasesAvailabilityEnabled(Boolean value)
-
isUpdatingServerPacksEnabled
final Boolean isUpdatingServerPacksEnabled()
-
setUpdatingServerPacksEnabled
final Unit setUpdatingServerPacksEnabled(Boolean value)
-
isJavaScriptAutoupdateEnabled
final Boolean isJavaScriptAutoupdateEnabled()
-
setJavaScriptAutoupdateEnabled
final Unit setJavaScriptAutoupdateEnabled(Boolean value)
-
getAikarsFlags
final String getAikarsFlags()
-
setAikarsFlags
final Unit setAikarsFlags(String value)
-
getWebserviceConfig
final WebserviceConfig getWebserviceConfig()
-
getDatabaseUri
final String getDatabaseUri()
-
setDatabaseUri
final Unit setDatabaseUri(String value)
-
getLanguage
final Locale getLanguage()
-
setLanguage
final Unit setLanguage(Locale value)
-
getHasteBinServerUrl
final String getHasteBinServerUrl()
-
setHasteBinServerUrl
final Unit setHasteBinServerUrl(String value)
-
getJavaPath
final String getJavaPath()
-
setJavaPath
final Unit setJavaPath(String value)
-
getWebserviceCleanupSchedule
final String getWebserviceCleanupSchedule()
-
setWebserviceCleanupSchedule
final Unit setWebserviceCleanupSchedule(String value)
-
getWebserviceVersionSchedule
final String getWebserviceVersionSchedule()
-
setWebserviceVersionSchedule
final Unit setWebserviceVersionSchedule(String value)
-
getWebserviceDatabaseCleanupSchedule
final String getWebserviceDatabaseCleanupSchedule()
-
setWebserviceDatabaseCleanupSchedule
final Unit setWebserviceDatabaseCleanupSchedule(String value)
-
getPathsConfig
final PathsConfig getPathsConfig()
-
getScriptTemplatesConfig
final ScriptTemplatesConfig getScriptTemplatesConfig()
-
getHomeDirectory
final File getHomeDirectory()
-
setHomeDirectory
final Unit setHomeDirectory(File value)
-
getServerPackCreatorPropertiesFile
final File getServerPackCreatorPropertiesFile()
-
getOverridesPropertiesFile
final File getOverridesPropertiesFile()
-
getDefaultConfig
final File getDefaultConfig()
-
getConfigsDirectory
final File getConfigsDirectory()
-
getTomcatBaseDirectory
final File getTomcatBaseDirectory()
-
setTomcatBaseDirectory
final Unit setTomcatBaseDirectory(File value)
-
getServerPacksDirectory
final File getServerPacksDirectory()
-
setServerPacksDirectory
final Unit setServerPacksDirectory(File value)
-
getLogsDirectory
final File getLogsDirectory()
-
getTomcatLogsDirectory
final File getTomcatLogsDirectory()
-
setTomcatLogsDirectory
final Unit setTomcatLogsDirectory(File value)
-
getManifestsDirectory
final File getManifestsDirectory()
-
getFabricIntermediariesManifest
final File getFabricIntermediariesManifest()
-
getLegacyFabricGameManifest
final File getLegacyFabricGameManifest()
-
getLegacyFabricLoaderManifest
final File getLegacyFabricLoaderManifest()
-
getLegacyFabricInstallerManifest
final File getLegacyFabricInstallerManifest()
-
getFabricInstallerManifest
final File getFabricInstallerManifest()
-
getQuiltVersionManifest
final File getQuiltVersionManifest()
-
getQuiltInstallerManifest
final File getQuiltInstallerManifest()
-
getForgeVersionManifest
final File getForgeVersionManifest()
-
getOldNeoForgeVersionManifest
final File getOldNeoForgeVersionManifest()
-
getNewNeoForgeVersionManifest
final File getNewNeoForgeVersionManifest()
-
getFabricVersionManifest
final File getFabricVersionManifest()
-
getMinecraftServerManifestsDirectory
final File getMinecraftServerManifestsDirectory()
-
getMinecraftVersionManifest
final File getMinecraftVersionManifest()
-
getWorkDirectory
final File getWorkDirectory()
-
getInstallerCacheDirectory
final File getInstallerCacheDirectory()
-
getTempDirectory
final File getTempDirectory()
-
getModpacksDirectory
final File getModpacksDirectory()
-
getServerFilesDirectory
final File getServerFilesDirectory()
-
getDefaultShellScriptTemplate
final File getDefaultShellScriptTemplate()
-
getDefaultFishScriptTemplate
final File getDefaultFishScriptTemplate()
-
getDefaultPowerShellScriptTemplate
final File getDefaultPowerShellScriptTemplate()
-
getDefaultBatchScriptTemplate
final File getDefaultBatchScriptTemplate()
-
getDefaultJavaShellScriptTemplate
final File getDefaultJavaShellScriptTemplate()
-
getDefaultJavaFishScriptTemplate
final File getDefaultJavaFishScriptTemplate()
-
getDefaultJavaPowerShellScriptTemplate
final File getDefaultJavaPowerShellScriptTemplate()
-
getDefaultJavaBatchScriptTemplate
final File getDefaultJavaBatchScriptTemplate()
-
getPropertiesDirectory
final File getPropertiesDirectory()
-
getIconsDirectory
final File getIconsDirectory()
-
getDefaultServerProperties
final File getDefaultServerProperties()
-
getDefaultServerIcon
final File getDefaultServerIcon()
-
getDefaultVariablesTemplate
final File getDefaultVariablesTemplate()
-
getPluginsDirectory
final File getPluginsDirectory()
-
getPluginsConfigsDirectory
final File getPluginsConfigsDirectory()
-
getFallbackUpdated
final Boolean getFallbackUpdated()
-
getInstallLocationXml
final File getInstallLocationXml()
-
getLog4jXml
final File getLog4jXml()
-
getJarFolder
final File getJarFolder()
The folder containing the ServerPackCreator.exe or JAR-file.
- Returns:
Folder containing the ServerPackCreator.exe or JAR-file.
-
isExe
final Boolean isExe()
Whether a .exe or JAR-file was used for running ServerPackCreator.
- Returns:
trueif a .exe was/is used.
-
getJarFile
final File getJarFile()
The .exe or JAR-file of ServerPackCreator.
- Returns:
The .exe or JAR-file of ServerPackCreator.
-
getJarName
final String getJarName()
The name of the .exe or JAR-file.
- Returns:
The name of the .exe or JAR-file.
-
getJavaVersion
final String getJavaVersion()
The Java version used to run ServerPackCreator.
- Returns:
Java version.
-
getOSArch
final String getOSArch()
Architecture of the operating system on which ServerPackCreator is running on.
- Returns:
Arch.
-
getOSName
final String getOSName()
The name of the operating system on which ServerPackCreator is running on.
- Returns:
OS name.
-
getOSVersion
final String getOSVersion()
The version of the OS on which ServerPackCreator is running on.
- Returns:
Version of the OS.
-
getPreference
final Optional<String> getPreference(String pref, String def)
Read one value from SPC's
Preferencesnode, or def when unset.Landmine: which node that is depends on
resolvePreferencesNode— a host claiming its own node (the grinder daemon, every test JVM) reads and writes a different store than the default installation, deliberately.
-
storePreference
final Unit storePreference(String pref, String value)
Write one value into SPC's
Preferencesnode. Same node caveat as getPreference.
-
defaultScriptTemplates
@Deprecated(message = "Deprecated as of 6.0.0", replaceWith = @ReplaceWith(expression = "defaultStartScriptTemplates()")) final List<File> defaultScriptTemplates()
Default list of script templates used by ServerPackCreator.
-
defaultStartScriptTemplates
final HashMap<String, String> defaultStartScriptTemplates()
Default map of start-script templates: sh, ps1, bat.
-
defaultJavaScriptTemplates
final HashMap<String, String> defaultJavaScriptTemplates()
Default map of java-install-script templates: sh, ps1.
-
javaPath
final Optional<String> javaPath(Integer javaVersion)
Get the path to the specified Java executable/binary, wrapped in an Optional for your convenience.
-
javaPath
final Optional<String> javaPath(String javaVersion)
Get the path to the specified Java executable/binary, wrapped in an Optional for your convenience.
-
defaultWebserviceDatabase
final String defaultWebserviceDatabase()
The default webservice database-URI, for resetting the configuration to factory-state.
-
defaultTomcatBaseDirectory
final File defaultTomcatBaseDirectory()
The default Tomcat base-directory: the home-directory.
-
defaultServerPacksDirectory
final File defaultServerPacksDirectory()
The default server-packs directory: server-packs inside the home-directory.
-
defaultTomcatLogsDirectory
final File defaultTomcatLogsDirectory()
The default Tomcat logs-directory: logs inside the home-directory.
-
loadOverrides
final Unit loadOverrides(File properties)
Loads the overrides-properties directly into the store, replacing already-loaded values.
-
loadProperties
final Unit loadProperties(Boolean saveProps)
Load properties using the default file path. Only call this method on an already initialized ApiProperties-object.
-
loadProperties
final Unit loadProperties(File propertiesFile, Boolean saveProps)
Reload from a specific properties-file.
- Parameters:
propertiesFile- The properties-file with which to loadProperties the settings and configuration.
-
acquireJavaPath
final String acquireJavaPath(String pathToJava)
Check the given path to a Java installation for validity and return it, if it is valid. Invalid paths yield the automatically acquired system-Java.
-
saveProperties
final Unit saveProperties(File propertiesFile)
Store the ApplicationProperties to disk, overwriting the existing one.
- Parameters:
propertiesFile- The file to store the properties to.
-
javaAvailable
final Boolean javaAvailable()
Whether a viable path to a Java executable or binary has been configured for ServerPackCreator.
-
changeLocale
final Unit changeLocale(Locale locale)
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.
- Parameters:
locale- The locale the user specified when they ran serverpackcreator with -lang -your_locale.
-
clientSideMods
final List<String> clientSideMods()
Acquire the default fallback list of clientside-only mods. If
de.griefed.serverpackcreator.serverpack.autodiscovery.filteris set to ExclusionFilter.REGEX, a regex fallback list is returned.- Returns:
The fallback list of clientside-only mods.
-
whitelistedMods
final List<String> whitelistedMods()
Acquire the default fallback list of whitelisted mods. If
de.griefed.serverpackcreator.serverpack.autodiscovery.filteris set to ExclusionFilter.REGEX, a regex fallback list is returned.- Returns:
The fallback list of whitelisted mods.
-
updateFallback
final Boolean updateFallback()
Update the fallback clientside-only mod-list and whitelist from the configured update-URL.
- Returns:
trueif either fallback-list was updated.
-
storeCustomProperty
final String storeCustomProperty(String property, String value)
Store a custom property in the serverpackcreator.properties-file. Beware that every property you add receives a prefix, to prevent clashes with any other properties.
Said prefix consists of
custom.property.followed by the property you specified coming in last.Say you have a value in the property
saved, then the resulting property in the serverpackcreator.properties would be:custom.property.saved
-
retrieveCustomProperty
final String retrieveCustomProperty(String property)
Retrieve a custom property in the serverpackcreator.properties-file. Beware that every property you retrieve this way contains a prefix, to prevent clashes with any other properties.
Said prefix consists of
custom.property.followed by the property you specified coming in last.Say you have a property
saved, then the resulting property in the serverpackcreator.properties would be:custom.property.saved
-
setOldVersion
final Unit setOldVersion(String version)
Set the old version of ServerPackCreator used to perform necessary migrations between the old and the current version.
- Parameters:
version- Old version used before upgrading to the current version.
-
oldVersion
final String oldVersion()
Get the old version of ServerPackCreator used to perform necessary migrations between the old and the current version.
- Returns:
Old version used before updating. Empty if this is the first run of ServerPackCreator.
-
clearPropertyFileList
final Unit clearPropertyFileList()
Forget every properties file the store has loaded from.
PropertyStorewrites to all tracked files on every save, so a file loaded once keeps being rewritten for the life of the process — which is how a daemon started from a checkout dropped a settings file into the repository root. Call this when a host wants its saves confined to the file it just pointed SPC at.
-
getSupportedTypes
Array<String> getSupportedTypes()
-
getConfiguration
Configuration getConfiguration(LoggerContext loggerContext, ConfigurationSource source)
Depending on whether this is the first run of ServerPackCreator on a users machine, the default log4j2 configuration may be present at different locations. The default one is the config inside the home-directory of SPC, of which we will try to set up our logging with. If said file fails for whatever reason, we will try to use a config inside the directory from which SPC was executed. Should that fail, too, the config from the classpath is used, to ensure we always have default configs available. Should that fail, too, though, log4j is set up with its own default settings.
- Parameters:
loggerContext- logger context passed from log4j itselfsource- configuration source passed from log4j itself.- Returns:
Custom configuration with proper logs-directory set.
-
getSeparator
final static String getSeparator()
-
resolvePreferencesNode
@JvmOverloads() final static String resolvePreferencesNode(String property, String environment)
Decide which
Preferencesnode to store settings in: the PREFERENCES_NODE_PROPERTY system property first, then the PREFERENCES_NODE_ENV environment variable, else DEFAULT_PREFERENCES_NODE.Why this is overridable at all: the node is per-user and machine-wide, and
PathsConfig.homeDirectoryre-reads it on every access while writing back what it resolved. With a single hard-coded node, any SPC process could relocate any other running process's home directory — a test suite moved a live grinder daemon's home into its own scratch directory and then deleted it, and equally, running the suites moved the developer's own GUI home. Giving each host its own node makes that impossible.A blank override falls back to the default rather than being honoured:
userRoot().node("")is the root node, shared with every other Java application on the account.- Parameters:
property- The system-property value (injectable for tests).environment- The environment-variable value (injectable for tests).
-
resolvePreferencesNode
@JvmOverloads() final static String resolvePreferencesNode(String property)
Decide which
Preferencesnode to store settings in: the PREFERENCES_NODE_PROPERTY system property first, then the PREFERENCES_NODE_ENV environment variable, else DEFAULT_PREFERENCES_NODE.Why this is overridable at all: the node is per-user and machine-wide, and
PathsConfig.homeDirectoryre-reads it on every access while writing back what it resolved. With a single hard-coded node, any SPC process could relocate any other running process's home directory — a test suite moved a live grinder daemon's home into its own scratch directory and then deleted it, and equally, running the suites moved the developer's own GUI home. Giving each host its own node makes that impossible.A blank override falls back to the default rather than being honoured:
userRoot().node("")is the root node, shared with every other Java application on the account.- Parameters:
property- The system-property value (injectable for tests).
-
resolvePreferencesNode
@JvmOverloads() final static String resolvePreferencesNode()
Decide which
Preferencesnode to store settings in: the PREFERENCES_NODE_PROPERTY system property first, then the PREFERENCES_NODE_ENV environment variable, else DEFAULT_PREFERENCES_NODE.Why this is overridable at all: the node is per-user and machine-wide, and
PathsConfig.homeDirectoryre-reads it on every access while writing back what it resolved. With a single hard-coded node, any SPC process could relocate any other running process's home directory — a test suite moved a live grinder daemon's home into its own scratch directory and then deleted it, and equally, running the suites moved the developer's own GUI home. Giving each host its own node makes that impossible.A blank override falls back to the default rather than being honoured:
userRoot().node("")is the root node, shared with every other Java application on the account.
-
-
-
-