Class ServerPackFileGatherer

  • All Implemented Interfaces:

    
    public final class ServerPackFileGatherer
    
                        

    Gatherer of all files which make up a server pack: resolves inclusion-specifications to source-destination-pairs, applies in-/exclusion-filters, delegates the mods-directory to the mod-list-compiler, and performs the copy itself. Extracted from ServerPackHandler (refactor Phase 1d); ServerPackHandler remains the facade through which consumers access these operations.

    • Constructor Detail

      • ServerPackFileGatherer

        ServerPackFileGatherer(ModListCompiler modListCompiler)
    • Method Detail

      • copyFiles

         final List<File> copyFiles(String modpackDir, ArrayList<InclusionSpecification> inclusions, List<String> clientMods, List<String> whitelist, String minecraftVersion, String destination, String modloader, Boolean overwrite)

        Copies all specified directories and mods, excluding clientside-only mods, from the modpack directory into the server pack directory. If a source/file;destination/file -combination is provided, the specified source-file is copied to the specified destination-file. One of the reasons as to why it is recommended to run a given ConfigurationModel through the ConfigurationHandler first, is because the ConfigurationHandler will resolve links to their files first before then correcting the given ConfigurationModel.

        Parameters:
        modpackDir - Files and directories are copied into the server_pack directory inside the modpack directory.
        inclusions - All directories and files therein to copy to the server pack.
        clientMods - List of clientside-only mods to exclude from the server pack.
        minecraftVersion - The Minecraft version the modpack uses.
        destination - The destination where the files should be copied to.
        modloader - The modloader used for mod sideness detection.
      • getExplicitFiles

         final List<ServerPackFile> getExplicitFiles(String source, String destination, String modpackDir, String serverPackDestination)

        Gather a list of all files from an explicit source;destination-combination. If the source is a file, a singular ServerPackFile is returned. If the source is a directory, then all files in said directory are returned.

        Parameters:
        source - source-file/directory
        destination - destination-file/directory
        modpackDir - The modpack-directory.
        serverPackDestination - The destination, normally the server pack-directory.
        Returns:

        List of ServerPackFile.

      • getSaveFiles

         final List<ServerPackFile> getSaveFiles(String clientDir, String directory, String destination)

        Recursively acquire all files and directories inside the given save-directory as a list of ServerPackFile.

        Parameters:
        clientDir - Target directory in the server pack.
        directory - The save-directory.
        destination - The destination of the server pack.
        Returns:

        List of ServerPackFile which will be included in the server pack.

      • getDirectoryFiles

         final List<ServerPackFile> getDirectoryFiles(String source, String destination)

        Recursively acquire all files and directories inside the given directory as a list of ServerPackFile.

        Parameters:
        source - The source-directory.
        destination - The server pack-directory.
        Returns:

        List of files and folders of the server pack.

      • excludeFileOrDirectory

         final Boolean excludeFileOrDirectory(String modpackDir, File fileToCheckFor, List<Regex> exclusions)

        Check whether the given file or directory should be excluded from the server pack.

        Parameters:
        modpackDir - The directory where the modpack resides in.
        fileToCheckFor - The file or directory to check whether it should be excluded from the server pack.
        exclusions - Files or directories determined by ServerPackCreator to be excluded from the server pack
        Returns:

        true if the file or directory was determined to be excluded from the server pack.

      • regexWalk

         final Unit regexWalk(File source, String destination, Regex regex, List<ServerPackFile> serverPackFiles)

        Walk through the specified directory and add a ServerPackFile for every file/folder which matches the given regex.

        Parameters:
        source - The source-directory to walk through and perform regex-matches in.
        destination - The destination-directory where a matched file should be copied to, usually the server pack directory.
        regex - Regex with which to perform matches against files in the source-directory.
        serverPackFiles - List of files to copy to the server pack to which any matched file will be added to.