Class ApiWrapper

  • All Implemented Interfaces:

    
    public final class ApiWrapper
    
                        

    API wrapper, allowing you to conveniently initialize, setup and use the different aspects of ServerPackCreator.

    Author:

    Griefed

    • Constructor Detail

    • Method Detail

      • 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.

      • 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.

      • getWebUtilities

        @Synchronized() final WebUtilities getWebUtilities()

        This instances common web utilities used across ServerPackCreator.

        Returns:

        Common web utilities used across ServerPackCreator.

      • 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.

      • 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.

      • 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.

      • 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.

      • 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.md from the JAR to the home-directory.

        • Copies the HELP.md from the JAR to the home-directory.

        • Copies the CHANGELOG.md from the JAR to the home-directory.

        • Copies the LICENSE from 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.properties if it doesn't exist.

        • Creates the default server-icon.png if 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.

      • 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:

        true if 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.