Skip to content

Pierre-development/VarLib

Repository files navigation

VarLib

Made with Java Uses git
Discord
Uses git
Stars License

Java Library for Minecraft authenticating and launching.

Installation

With Gradle

Add mavenCentral in your repositories:

repositories {
    mavenCentral()
}

And add VarLib in your dependencies:

dependencies {
    implementation 'fr.varchar-dev:varlib:VERSION'
}

With Maven

<dependency>
    <groupId>fr.varchar-dev</groupId>
    <artifactId>varlib</artifactId>
    <version>VERSION</version>
</dependency>

Authentication

Authenticate

Create new object AuthenticateResponse with username and password:

AuthenticateResponse authenticateResponse = Authenticator.authenticate(username, password);

Refresh

Create new object RefreshResponse with accessToken and clientToken:

RefreshResponse refreshResponse = Authenticator.refresh(accessToken, clientToken);

Add information to launch

Create new object GameAuthenticator:

GameAuthenticator gameAuthenticator = new GameAuthenticator(authenticateResponse.getSelectedProfile().getName(), authenticateResponse.getAccessToken(), authenticateResponse.getSelectedProfile().getId());

Launch

With Minecraft Vanilla

AbstractGameLauncherBuilder launcherBuilder = new GameLauncherVanillaBuilder(folder)
     .setVersion("1.12")
     .setVersionType(VersionType.VERSION_1_8_HIGHER)
     .setFolderType(folderType)
     .setGameAuthenticator(gameAuthenticator);

With Minecraft Forge

AbstractGameLauncherBuilder gamelauncher = new GameLauncherForgeBuilder(folder, installerJsonFile)
     .setVersion("1.16")
     .setVersionType(VersionType.VERSION_1_13_HIGHER)
     .setFolderType(folderType)
     .setGameAuthenticator(gameAuthenticator);

if your version equal 1.13 or higher, you have to specify your forge json installer like 1.16.5-forge-36.1.0.json

Launch

launcherBuilder.build().launch();

Logger

Init

Create new object Logger with yourServerName:

Logger logger = new Logger("yourServerName");

Add the logger to builder

launcherBuilder.setLogger(logger);

Log

logger.log("message");

Log with color

Warning: the import for Color's class is fr.varchar.varlib.util.logger.Color;!

logger.log("message", Color.RED);

Error

logger.logError("yourError");

Optional

Add VM arguments

launcherBuilder.addVMArgument("YourArg");

Change the Java path

The library run the game with java command, you can change the Java path like this

launcherBuilder.setJavaPath("YourPath");

Discord

You can join our Discord!

License

VarLib | MIT License

About

Java Library for Minecraft authenticating and launching

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages