Class ApiWrapper
-
- All Implemented Interfaces:
public final class ApiWrapperAPI wrapper, allowing you to conveniently initialize, setup and use the different aspects of ServerPackCreator.
Griefed
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classApiWrapper.CompanionThe singleton accessor and the
api()factory that builds and optionally sets up the collaborator graph.
-
Field Summary
-
Method Summary
Modifier and Type Method Description final FilegetProperties()final RegexgetXmlJsonRegex()Matches the manifest files seeded from the jar, so setup can copy exactly those and nothing else. final BooleangetSetupWasRun()Whether setup has already run, so repeated calls are cheap. final UnitsetSetupWasRun(Boolean value)Whether setup has already run, so repeated calls are cheap. final ApiPropertiesgetApiProperties()This instances settings used across ServerPackCreator, such as the working-directories, files and other settings. final BooleangetFirstRun()Will return true if this is the first time ServerPackCreator is being run on a given host. final ObjectMappergetObjectMapper()This instances JSON-ObjectMapper used across ServerPackCreator with which this instance was initialized. final JsonUtilitiesgetJsonUtilities()This instances common JSON utilities used across ServerPackCreator. final WebUtilitiesgetWebUtilities()This instances common web utilities used across ServerPackCreator. final DocumentBuilderFactorygetDocumentBuilderFactory()This instances DocumentBuilder for working with XML-data. final XmlUtilitiesgetXmlUtilities()This instances common XML utilities used across ServerPackCreator. final UtilitiesgetUtilities()This instances collection of common utilities used across ServerPackCreator. final VersionMetagetVersionMeta()This instances version meta used for checking version-correctness of Minecraft and supported modloaders, as well as gathering information about Minecraft servers and modloader installers. final ConfigurationHandlergetConfigurationHandler()This instances ConfigurationHandler for checking a given de.griefed.serverpackcreator.api.config.PackConfig for validity, so a server pack can safely be created from it. final ApiPluginsgetApiPlugins()This instances plugin manager for ServerPackCreator-plugins, if any are installed. final ServerPackHandlergetServerPackHandler()This instances ServerPackHandler used to turn a de.griefed.serverpackcreator.api.config.PackConfig into a server pack. final ModScannergetModScanner()This instances modscanner to determine the sideness of a given Forge, Fabric, LegacyFabric or Quilt mod. final ForgeAnnotationScannergetForgeAnnotationScanner()This instances annotation scanner used to determine the sideness of Forge mods for Minecraft 1.12.2 and older. final FabricScannergetFabricScanner()This instances scanner to determine the sideness of Fabric mods. final QuiltScannergetQuiltScanner()This instances scanner to determine the sideness of Quilt mods. final TomlParsergetTomlParser()This instances toml parser to read and parse various .toml-files during mod-scanning, plugin- and extension config loading and provisioning, serverpackcreator.conf reading and more.final ForgeTomlScannergetForgeTomlScanner()This instances toml scanner to determine the sideness of Forge mods for Minecraft 1.13.x and newer. final NeoForgeTomlScannergetNeoForgeTomlScanner()This instances toml scanner to determine the sideness of NeoForge mods for Minecraft 1.20.5 and newer. final ApiWrappersetup(Boolean force)Convenience method to set up ServerPackCreator. final UnitstageOne()Stage one of starting ServerPackCreator. final UnitstageTwo()Initialize de.griefed.serverpackcreator.api.versionmeta.VersionMeta, ConfigurationHandler. final UnitstageThree()Initialize ApiPlugins, de.griefed.serverpackcreator.api.modscanning.ModScanner (consisting of TomlParser, de.griefed.serverpackcreator.api.modscanning.ForgeAnnotationScanner, de.griefed.serverpackcreator.api.modscanning.FabricScanner, de.griefed.serverpackcreator.api.modscanning.ForgeTomlScanner, de.griefed.serverpackcreator.api.modscanning.QuiltScanner), ServerPackHandler. final BooleancheckServerFilesFile(File fileToCheckFor)Check whether the specified server-files file exists and create it if it doesn't. final UnitoverwriteServerFilesFile(File fileToOverwrite)Overwrite the specified server-files file, even when it exists. -
-
Method Detail
-
getProperties
final File getProperties()
-
getXmlJsonRegex
final Regex getXmlJsonRegex()
Matches the manifest files seeded from the jar, so setup can copy exactly those and nothing else.
-
getSetupWasRun
final Boolean getSetupWasRun()
Whether setup has already run, so repeated calls are cheap.
setup(force = true)clears it.
-
setSetupWasRun
final Unit setSetupWasRun(Boolean value)
Whether setup has already run, so repeated calls are cheap.
setup(force = true)clears it.
-
getApiProperties
@Synchronized() final ApiProperties getApiProperties()
This instances settings used across ServerPackCreator, such as the working-directories, files and other settings.
- Returns:
applicationProperties used across this ServerPackCreator-instance.
-
getFirstRun
final Boolean getFirstRun()
Will return true if this is the first time ServerPackCreator is being run on a given host.
-
getObjectMapper
@Synchronized() final ObjectMapper getObjectMapper()
This instances JSON-ObjectMapper used across ServerPackCreator with which this instance was initialized. By default, the ObjectMapper used across ServerPackCreator has the following features set:
disabled: DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
enabled: DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY
enabled: JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS
- Returns:
Json-ObjectMapper to parse and read JSON.
-
getJsonUtilities
@Synchronized() final JsonUtilities getJsonUtilities()
This instances common JSON utilities used across ServerPackCreator.
- Returns:
Common JSON utilities used across ServerPackCreator.
-
getWebUtilities
@Synchronized() final WebUtilities getWebUtilities()
This instances common web utilities used across ServerPackCreator.
- Returns:
Common web utilities used across ServerPackCreator.
-
getDocumentBuilderFactory
@Synchronized() final DocumentBuilderFactory getDocumentBuilderFactory()
This instances DocumentBuilder for working with XML-data.
- Returns:
DocumentBuilder for working with XML.
-
getXmlUtilities
@Synchronized() final XmlUtilities getXmlUtilities()
This instances common XML utilities used across ServerPackCreator.
- Returns:
Common XML utilities used across ServerPackCreator.
-
getUtilities
@Synchronized() final Utilities getUtilities()
This instances collection of common utilities used across ServerPackCreator.
- Returns:
Collection of common utilities used across ServerPackCreator.
-
getVersionMeta
@Synchronized() final VersionMeta getVersionMeta()
This instances version meta used for checking version-correctness of Minecraft and supported modloaders, as well as gathering information about Minecraft servers and modloader installers.
- Returns:
Meta used for checking version-correctness of Minecraft and supported modloaders.
-
getConfigurationHandler
@Synchronized() final ConfigurationHandler getConfigurationHandler()
This instances ConfigurationHandler for checking a given de.griefed.serverpackcreator.api.config.PackConfig for validity, so a server pack can safely be created from it.
- Returns:
Handler for config checking.
-
getApiPlugins
@Synchronized() final ApiPlugins getApiPlugins()
This instances plugin manager for ServerPackCreator-plugins, if any are installed. This gives you access to the available extensions, should any be available in your instance of ServerPackCreator.
- Returns:
Plugin manager for ServerPackCreator-plugins, if any are installed.
-
getServerPackHandler
@Synchronized() final ServerPackHandler getServerPackHandler()
This instances ServerPackHandler used to turn a de.griefed.serverpackcreator.api.config.PackConfig into a server pack.
- Returns:
The ServerPackHandler with which config models can be used to create server packs.
-
getModScanner
@Synchronized() final ModScanner getModScanner()
This instances modscanner to determine the sideness of a given Forge, Fabric, LegacyFabric or Quilt mod.
- Returns:
Modscanner to determine the sideness of a given Forge, Fabric, LegacyFabric or Quilt mod.
-
getForgeAnnotationScanner
@Synchronized() final ForgeAnnotationScanner getForgeAnnotationScanner()
This instances annotation scanner used to determine the sideness of Forge mods for Minecraft 1.12.2 and older.
- Returns:
Annotation scanner used to determine the sideness of Forge mods for Minecraft 1.12.2 and older.
-
getFabricScanner
@Synchronized() final FabricScanner getFabricScanner()
This instances scanner to determine the sideness of Fabric mods.
- Returns:
Scanner to determine the sideness of Fabric mods.
-
getQuiltScanner
@Synchronized() final QuiltScanner getQuiltScanner()
This instances scanner to determine the sideness of Quilt mods.
- Returns:
Scanner to determine the sideness of Quilt mods.
-
getTomlParser
@Synchronized() final TomlParser getTomlParser()
This instances toml parser to read and parse various
.toml-files during mod-scanning, plugin- and extension config loading and provisioning, serverpackcreator.conf reading and more.- Returns:
Toml parser to read and parse
.toml-files.
-
getForgeTomlScanner
final ForgeTomlScanner getForgeTomlScanner()
This instances toml scanner to determine the sideness of Forge mods for Minecraft 1.13.x and newer.
- Returns:
Scanner to determine the sideness of Forge mods for Minecraft 1.13.x and newer.
-
getNeoForgeTomlScanner
@Synchronized() final NeoForgeTomlScanner getNeoForgeTomlScanner()
This instances toml scanner to determine the sideness of NeoForge mods for Minecraft 1.20.5 and newer.
- Returns:
Scanner to determine the sideness of Forge mods for Minecraft 1.20.5 and newer.
-
setup
@Synchronized() final ApiWrapper setup(Boolean force)
Convenience method to set up ServerPackCreator.
-
stageOne
final Unit stageOne()
Stage one of starting ServerPackCreator.
Creates and prepares the environment for ServerPackCreator to run by creating required directories and copying required files from the JAR-file to the filesystem. Some of these files can and should be edited by a given user, others however, not.
Checks the read- and write-permissions of ServerPackCreators base-directory.
Copies the
README.mdfrom the JAR to the home-directory.Copies the
HELP.mdfrom the JAR to the home-directory.Copies the
CHANGELOG.mdfrom the JAR to the home-directory.Copies the
LICENSEfrom the JAR to the home-directory.Copies the fallback version-manifests to the manifests.
Creates default directories:
server_files
work
temp
work/modpacks
server-packs (depending on the users settings, this may be anywhere on the users system)
plugins
plugins/config
Example
disabled.txt-file in plugins/disabled.txt.Creates the default
server.propertiesif it doesn't exist.Creates the default
server-icon.pngif it doesn't exist.Creates the default PowerShell and Shell script templates or overwrites them if they already exist.
Determines whether this instance of ServerPackCreator was updated from a previous version.
If an update was detected, and migrations are available for any of the steps of the update, they are executed, thus ensuring users are safe to update their instances. Writes ServerPackCreator and system information to the console and logs, important for error reporting and debugging.
-
stageThree
final Unit stageThree()
Initialize ApiPlugins, de.griefed.serverpackcreator.api.modscanning.ModScanner (consisting of TomlParser, de.griefed.serverpackcreator.api.modscanning.ForgeAnnotationScanner, de.griefed.serverpackcreator.api.modscanning.FabricScanner, de.griefed.serverpackcreator.api.modscanning.ForgeTomlScanner, de.griefed.serverpackcreator.api.modscanning.QuiltScanner), ServerPackHandler.
-
checkServerFilesFile
final Boolean checkServerFilesFile(File fileToCheckFor)
Check whether the specified server-files file exists and create it if it doesn't.
- Parameters:
fileToCheckFor- The file which is to be checked for whether it exists and if it doesn't, should be created.- Returns:
trueif the file was generated.
-
overwriteServerFilesFile
final Unit overwriteServerFilesFile(File fileToOverwrite)
Overwrite the specified server-files file, even when it exists. Used to ensure files like the default script templates are always up-to-date.
- Parameters:
fileToOverwrite- The file which is to be overwritten.
-
-
-
-