gmll
Version:
A generic launcher core for building custom launchers
145 lines (144 loc) • 6.32 kB
TypeScript
import { Dir, File } from "gfsl";
import type { AssetIndex, LaunchArguments, LaunchOptions } from "../../types";
import * as launchHandler from "../internal/handlers/launch.js";
import * as metaHandler from "../internal/handlers/meta.js";
import { importModpack } from "../internal/handlers/modpacks.js";
import * as modsHandler from "../internal/handlers/mods.js";
import Version from "./version.js";
/**
* An instance is what the name entails. An instance of the game Minecraft containing Minecraft specific data.
* This information on where the game is stored and the like. The mods installed and what not.
*/
export default class Instance {
protected assets: Partial<AssetIndex>;
protected id: string;
path: string;
version: string;
name: string;
env: {
[key: string]: string;
};
ram: number;
/**This is a custom field for launcher authors. It can safely be ignored*/
meta: any;
javaPath: "default" | string;
noLegacyFix: boolean;
detach: boolean;
/**Additional arguments added for legacy versions */
static oldJVM: string[];
/**The default game arguments, don't mess with these unless you know what you are doing */
static defaultGameArguments: string[];
/**Do not mess with unless you know what you're doing. Some older versions may not launch if information from this file is missing. */
static defJVM: LaunchArguments;
constructor(opt?: LaunchOptions);
getID(): string;
/**Gets the load order of minecraft jars in jar mod loader. */
getJarModPriority: typeof modsHandler.getJarModPriority;
/**Install forge in this instance. */
installForge: typeof modsHandler.installForge;
getForgeVersions: typeof modsHandler.getForgeVersions;
/**
* Used to modify minecraft's jar file (Low level)
* @param metaPaths
* @param version
* @returns
*/
static jarMod: typeof modsHandler.jarMod;
/**An version of the wrap function that takes an object as a variable instead of the mess the base function takes. */
pack: typeof modsHandler.pack;
/**Wraps up an instance in a prepackaged format that can be easily uploaded to a server for distribution
* @param baseUrl The base URL the generated files will be stored within on your server. For example http\:\/\/yourawesomdomain.net\/path\/to\/files\/
* @param save The file GMLL will generate the final files on.
* @param name The name that should be used to identify the generated version files
* @param forge The path to a forge installation jar
* @param trimMisc Gets rid of any unnecessary miscellaneous files
* @deprecated Use {@link pack} instead
*/
wrap: typeof modsHandler.wrap;
/**
* @returns Some low level meta paths used to obtain some key files of this instance.
*/
getMetaPaths: typeof metaHandler.getMetaPaths;
/**
* Gets information about mods in this instance. This includes the loader version plus some general
* information about the mod author and mod itself. This will also provide you the icon for a set mod if it can be obtained.\
*
* Works with Legacy forge, forge, fabric, riftloader and liteloader
*/
getMods: typeof metaHandler.getMods;
/**
* Gets information about the installed resource and texture packs of this instance.
* This includes information like the pack icon, name, description, legal documents and credits.
*/
getResourcePacks: typeof metaHandler.getResourcePacks;
/**
* Gets some general information about all the world files in this instance.
* It also decodes the level.DAT file for you and returns the decoded file as a JSON file.
*
* It also decodes the player data stored in the "playerdata" and "stats" subfolder in newer versions of the game.
*/
getWorlds: typeof metaHandler.getWorlds;
/**
* This function is used to launch the game. It also runs the install script for you.
* This essentially does an integrity check.
* @param token The player login token
* @param resolution Optional information defining the game's resolution
* @returns The game's child process
*/
launch: typeof launchHandler.launch;
/**
* Runs the installer script without launching MC
* @returns The instance's version object.
* @see {@link getVersion} if you just want the instance's version
*/
install: typeof launchHandler.install;
/**
*
* @returns An object containing the version data this instance is based on
* @see {@link install} if you want to initiate that version object first!
*/
getVersion(): Promise<Version>;
getDir(): Dir;
/**Gets a list of profiles that where saved previously */
static getProfiles(): Map<string, LaunchOptions & {
get: () => Instance;
}>;
/**Gets a set profile based on the name of that profile */
static get(profile: string): Instance;
/**
* Deletes a profile based on the profileID
* @param profile
* @returns
*/
static rm(profile: string): File;
/**
* Delete the saved information for this instance.
* @returns
*/
rmSelf(): File;
/**
* Saves the instance data. Can be used to automatically get the instance again by using it's name
* @see {@link get} for more info
*/
save(): this;
/**
* This will tell GMLL to rerun some of the install scripts it normally skips upon a second "install" call.
* This won't reset worlds or rewrite dynamic files. Use this if, for instance, forge failed to install.
*/
reinstall(): void;
/**Injects a set selection of images into the asset files and sets them as the icon for this instance */
setIcon(x32?: string | File, x16?: string | File, mac?: string | File): void;
/**
* Inject custom assets into the game.
* @param key The asset key
* @param path The path to the asset file in questions...it must exist!
*/
injectAsset(key: string, path: string | File): {
hash: string;
size: number;
ignore: boolean;
};
getName(): string;
import: typeof importModpack;
static import(name: string, urlorFile: string | File, type: "curseforge" | "gmll", forge?: string | File): Promise<Instance>;
}