Skip to content

A library to download fortnite's game files or work with them without having to download the entire game

License

Notifications You must be signed in to change notification settings

FabianFG/FortniteDownloader

Repository files navigation

FortniteDownloader

A library to download and process Fortnite's game files

Features

  • Parse a download manifest from the Epic Games Launcher or manually by url
  • Support for both: json-serialized and binary-serialized manifests
  • Download all files from a parsed manifest individually
  • Implements the FileProvider interface from JFortniteParse with reading from Manifests. The main benefit is that only the chunks you need are downloaded
  • Preload chunks for a file that you might need later.

Usage

1. Load a manifest

There are multiple ways of loading a manifest

  • Loading a manifest from Epic Games Launcher's data
// It's recommended to reuse this as it does a login to the Epic Games Api
// and you don't need to spam their api
val launcherManifestDownloader = LauncherManifestDownloader()
// The current version information. Can be used to get the build version for example
// Use this to look for updates as it doesn't download the manifest immediately
val info = launcherManifestDownloader.getManifestInfo(Platform.Windows, Game.Fortnite)
val manifest = ManifestLoader.downloadManifest(info)
// OR if you want to download the manifest immediately
val (info, manifest) = launcherManifestDownloader.downloadManifest(Platform.Windows, Game.Fortnite)
  • Loading a manifest from a url
val url = "..."
val manifest = ManifestLoader.downloadManifest(url)
  • Loading a manifest from a file on your disk
val file = File("...")
// This is needed to determine the url of the chunks. 
// It's the same path as where you download manifests from
val cloudDir = ".../CloudDir"
val manifest = ManifestLoader.loadManifest(file, cloudDir) 
  • Loading a manifest from memory
val bytes = ByteArray()
val cloudDir = ".../CloudDir"
val manifest = Manifest.parse(bytes, cloudDir)

2. Mount the manifest

Once you got a manifest you can mount it to start reading from it

  • Create a MountedBuild
val tempFolder = File(".downloaderChunks")
// ChunkPoolCapacity = Amount of chunks kept in memory, don't put this too high
// NumThreads = Amount of threads used to read concurrently, too many might cause errors
val mountedBuild = MountedBuild(manifest, tempFolder, chunkPoolCapacity = 20, numThreads = 20)
  • Download an entire file
val fileName = "FortniteGame/Content/Paks/pakchunk0-WindowsClient.pak"
val outputFile = File("pakchunk0-WindowsClient.pak")
val success = mountedBuild.downloadEntireFile(fileName, outputFile) { readBytes, size ->
    println("Downloading $fileName: $readBytes of $size")
}
if (success)
    println("Downloaded $fileName successfully")
  • Reading into a buffer from a file
val fileName = "FortniteGame/Content/Paks/pakchunk0-WindowsClient.pak"
val output = ByteArray(2000)
val success = mountedBuild.fileRead(fileName, output, destOffset = 0, offset = 0, length = 2000)
if (success)
    println("Downloaded 2000 bytes from $fileName successfully")
  • Preloading chunks of a file
val fileName = "FortniteGame/Content/Paks/pakchunk0-WindowsClient.pak"
val success = mountedBuild.preloadChunks(fileName) { readChunks, numChunks ->
    println("Preloaded $readChunks of $numChunks chunks")
}
if (success)
    println("Preloaded chunks from $fileName successfully")

3. Create a FileProvider

With a MountedBuild you can also create a FileProvider that can be used to easily read from the game files while just downloading the chunks needed

val provider = ManifestFileProvider(
            mountedBuild,
            paksFilter = { true }, // predicate to tell if a file should be loaded or not, `it` is the file name
            localFilesFolder = File("localFiles"), // can also just be null
            versions = VersionContainer.DEFAULT, // default value uses the latest supported UE version
            concurrent = true // set to true if thread-safety is needed
        )
provider.submitKey(FGuid.mainGuid, "0x...")

After that you can just use it exactly like the DefaultFileProvider described in JFortniteParse's docs

Dependency

Maven
  • Add the repository
<repositories>
	<repository>
		<id>jitpack.io</id>
		<url>https://jitpack.io</url>
	</repository>
</repositories>
  • Add the dependency
<dependency>
	<groupId>com.github.FabianFG</groupId>
	<artifactId>FortniteDownloader</artifactId>
	<version>1.7.1</version>
</dependency>
Gradle
  • Add the repository
repositories {
	maven { url 'https://jitpack.io' }
}
  • Add the dependency
implementation 'com.github.FabianFG:FortniteDownloader:1.7.1'

Credits

Inspired and partially based on EGL2 (mainly the chunk storage and mounted build functionality / design)

About

A library to download fortnite's game files or work with them without having to download the entire game

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages