Code Monkey home page Code Monkey logo

flowupdater's Introduction

version discord-shield

FlowUpdater

Check the Wiki to know how to use FlowUpdater and more information.

Usage

Vanilla

First, create a new VanillaVersion, specify arguments. Then build the version :

VanillaVersion version = new VanillaVersionBuilder().withName("1.15.2").withSnapshot(false).withVersionType(VersionType.VANILLA).build();

You have to put the version you want as parameter, you can set a snapshot if you want or latest. If you have specified "latest" to the version name, and that the version is a snapshot, replace false by true.

Then, instantiate a new FlowUpdater with FlowUpdaterBuilder#withXArguments#withAnotherArguemtn#build. Check the code for more information. The most of FlowUpdater objects are buildable: Build a new UpdaterOptions object: I'm enabling the re-extracting of natives at each update.

UpdaterOptions options = new UpdaterOptionsBuilder().withReExtractNatives(true).build();
FlowUpdater updater = new FlowUpdaterBuilder().withVersion(version).withUpdaterOptions(options).withLogger(someCustomLogger).build();

Don't forget to add a progress callback if you want to make a progress bar !

Finally, call the update function :

updater.update(new File("/your/path/"));

Replace false by true if you want to download the server Jar (useful for server installation program).

Forge

(You need to setup a vanilla updater !)

First, in your vanilla version builder, change the version type to VersionType.FORGE. Next, make a List of Mod objects.

List<Mod> mods = new ArrayList<>();
mods.add(new Mod("OneMod.jar", "sha1ofmod", 85120, "https://link/of/mod.jar"));
mods.add(new Mod("AnotherMod.jar", "sha1ofanothermod", 86120, "https://link/of/another/mod.jar"));

You can get a list of mods by providing a json link too : List<Mod> mods = Mod.getModsFromJson("https://url.com/launcher/mods.json");.

You can get mods from CurseForge too:

List<CurseFileInfos> modInfos = new ArrayList<>();
// project ID and file ID
modInfos.add(new CurseFileInfos(238222, 2988823));

You can get a list of curse mods by providing a json link too : List<CurseFileInfos> mods = CurseFileInfos.getFilesFromJson("https://url.com/launcher/cursemods.json");.

Then, build a forge version. For example, I will build a NewForgeVersion.

AbstractForgeVersion forgeVersion = new ForgeVersionBuilder(ForgeVersionBuilder.ForgeVersionType.NEW)
            .withForgeVersion("31.2.29")
            .withVanillaVersion(version)
            .withLogger(logger)
            .withProgressCallback(callback)
            .withCurseMods(modInfos)
            .withOptifine(new OptifineInfo("1.16.3_HD_U_G3", false)) // installing optifine for 1.16.3, false = not a preview
            .withUseFileDeleter(new ModFileDeleter(true, "jei.jar")) // delete bad mods, don't remove the file jei.jar if it's present in the dir.
            .withNoGui(true) // only for new forge version: true -> don't show the forge installer gui. false -> show the forge installer gui.
            .build();

Finally, set the Forge version corresponding to the wanted Forge version :

.withForgeVersion(forgeVersion);

That's all!

MCP

(You need to setup a vanilla updater !) In your vanilla version builder, change the version type to VersionType.MCP. Finally, set to vanilla version builder a MCP version :

.withMCP(new MCP("clientURL", "name", "clientSha1", "author", "serverURL", "serverSha1", 1215, 20525));

If you set an empty/null string in url and sha1 and 0 in size, the updater will use the default minecraft jar. Example on client-only mcp downloading :

.withMCP(new MCP("https://mighya.eu/resources/Client.jar", "f2c219e485831af2bae9464eebbe4765128c6ad6", "", "", 23005862, 210052));

You can get a MCP object instance by providing a json link too : .withMCP(MCP.getMCPFromJson("https://url.com/launcher/mcp.json"));. Nothing else to add :).

Fabric

(You need to setup a vanilla updater !)

First, in your vanilla version builder, change the version type to VersionType.FABRIC. Next, make a List of Mod objects.

List<Mod> mods = new ArrayList<>();
mods.add(new Mod("OneMod.jar", "sha1ofmod", 85120, "https://link/of/mod.jar"));
mods.add(new Mod("AnotherMod.jar", "sha1ofanothermod", 86120, "https://link/of/another/mod.jar"));

You can get a list of mods by providing a json link too : List<Mod> mods = Mod.getModsFromJson("https://url.com/launcher/mods.json");.

You can get mods from CurseForge too:

List<CurseFileInfos> modInfos = new ArrayList<>();
// project ID and file ID
modInfos.add(new CurseFileInfos(238222, 2988823));

You can get a list of curse mods by providing a json link too : List<CurseFileInfos> mods = CurseFileInfos.getFilesFromJson("https://url.com/launcher/cursemods.json");.

Then, build a Fabric version.

FabricVersion fabricVersion = new FabricVersionBuilder()
            .withFabricVersion("0.10.8")
            .withVanillaVersion(version)
            .withLogger(logger)
            .withProgressCallback(callback)
            .withCurseMods(modInfos)
            .withUseFileDeleter(new ModFileDeleter(true, "sodium.jar")) // delete bad mods ; doesn't remove the file sodium.jar if it's present in the dir.
            .build();

Finally, set the Fabric version corresponding to the wanted Fabric version :

.withFabricVersion(forgeVersion);

That's all!

External Files

With FlowUpdater, you can download other files in your update dir! In your FlowUpdaterBuilder, precise an array list of ExternalFile (can be get by ExternalFile#getExternalFilesFromJson).

About json files...

All json files can be generated by the FlowUpdaterJsonCreator !

Post executions

With FlowUpdater, you can execute some actions after update, like patch a file, kill a process, launch a process, review a config etc... In your FlowUpdaterBuilder, precise a list of Runnable.

And all it's done !

flowupdater's People

Contributors

flowarg avatar antoineok avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.