public class Launcher
extends java.lang.Object
Launcher class is part of the Craft4J library and provides an abstraction layer
to simplify authentication, game configuration, update, and launch processes for Minecraft launchers.
This class supports Microsoft authentication (via refresh token or webview), offline authentication, version updating (vanilla and modded), and game launching using OpenLauncherLib and FlowUpdater.
| Constructor and Description |
|---|
Launcher(java.lang.String launcherName)
Constructs a new
Launcher instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
authOffline(java.lang.String username,
java.lang.String uuid)
Authenticates the launcher in offline mode using the provided username and UUID.
|
java.lang.String |
authWithRefreshToken(java.lang.String refreshToken)
Authenticates the launcher using a Microsoft refresh token.
|
java.lang.String |
authWithWebview()
Authenticates the launcher using a Microsoft webview flow.
|
void |
clearAuthInfos()
Clears the current authentication information.
|
fr.theshark34.openlauncherlib.minecraft.AuthInfos |
getAuthInfos()
Returns the current authentication information.
|
GameConfiguration |
getGameConfiguration()
Returns the current game configuration.
|
java.lang.String |
getLauncherName()
Returns the name of the launcher.
|
void |
setGameConfiguration(GameConfiguration gameConfiguration)
Sets the current game configuration to be used for updates and launching.
|
java.lang.Process |
startGame()
Launches the Minecraft game using OpenLauncherLib's NoFramework.
|
void |
update(fr.flowarg.flowupdater.download.IProgressCallback callback)
Updates the game files using FlowUpdater according to the current game configuration.
|
public Launcher(java.lang.String launcherName)
Launcher instance.launcherName - The name of the launcher instance.public java.lang.String authWithRefreshToken(java.lang.String refreshToken)
throws fr.litarvan.openauth.microsoft.MicrosoftAuthenticationException
refreshToken - The Microsoft refresh token.fr.litarvan.openauth.microsoft.MicrosoftAuthenticationException - If authentication fails.java.lang.IllegalStateException - If the launcher is already authenticated.public java.lang.String authWithWebview()
throws fr.litarvan.openauth.microsoft.MicrosoftAuthenticationException
fr.litarvan.openauth.microsoft.MicrosoftAuthenticationException - If authentication fails.java.lang.IllegalStateException - If the launcher is already authenticated.public void authOffline(java.lang.String username,
java.lang.String uuid)
username - The offline username.uuid - The user UUID.java.lang.IllegalStateException - If the launcher is already authenticated.public void update(fr.flowarg.flowupdater.download.IProgressCallback callback)
throws java.lang.Exception
callback - The progress callback used during the update.java.lang.Exception - If the update fails or configuration is missing.java.lang.IllegalStateException - If the game configuration is not set.public java.lang.Process startGame()
throws java.lang.Exception
Process of the launched game.java.lang.Exception - If the game fails to launch.java.lang.IllegalStateException - If authentication or configuration is missing.public void clearAuthInfos()
public fr.theshark34.openlauncherlib.minecraft.AuthInfos getAuthInfos()
AuthInfos object, or null if not authenticated.public void setGameConfiguration(GameConfiguration gameConfiguration)
gameConfiguration - The GameConfiguration to set.public GameConfiguration getGameConfiguration()
GameConfiguration, or null if not set.public java.lang.String getLauncherName()