Add mavenCentral in your repositories:
repositories {
mavenCentral()
}
And add VarLib in your dependencies:
dependencies {
implementation 'fr.varchar-dev:varlib:VERSION'
}
<dependency>
<groupId>fr.varchar-dev</groupId>
<artifactId>varlib</artifactId>
<version>VERSION</version>
</dependency>
Create new object AuthenticateResponse with username and password:
AuthenticateResponse authenticateResponse = Authenticator.authenticate(username, password);
Create new object RefreshResponse with accessToken and clientToken:
RefreshResponse refreshResponse = Authenticator.refresh(accessToken, clientToken);
Create new object GameAuthenticator:
GameAuthenticator gameAuthenticator = new GameAuthenticator(authenticateResponse.getSelectedProfile().getName(), authenticateResponse.getAccessToken(), authenticateResponse.getSelectedProfile().getId());
AbstractGameLauncherBuilder launcherBuilder = new GameLauncherVanillaBuilder(folder)
.setVersion("1.12")
.setVersionType(VersionType.VERSION_1_8_HIGHER)
.setFolderType(folderType)
.setGameAuthenticator(gameAuthenticator);
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
launcherBuilder.build().launch();
Create new object Logger with yourServerName:
Logger logger = new Logger("yourServerName");
launcherBuilder.setLogger(logger);
logger.log("message");
Warning: the import for Color's class is fr.varchar.varlib.util.logger.Color;
!
logger.log("message", Color.RED);
logger.logError("yourError");
launcherBuilder.addVMArgument("YourArg");
The library run the game with java
command, you can change the Java path like this
launcherBuilder.setJavaPath("YourPath");
You can join our Discord!