Unknit refactor: Extract arg replacement methods
parent
8f578dcd4a
commit
501c20ffdb
|
@ -31,11 +31,25 @@ public abstract class MixinMinecraftMain {
|
|||
}
|
||||
}
|
||||
|
||||
private static void replaceVersion(List<String> arguments) {
|
||||
replace(arguments, "--version", "1.18.1");
|
||||
replace(arguments, "--versionType", "release");
|
||||
}
|
||||
|
||||
private static void replaceSession(List<String> arguments, Session session) {
|
||||
replace(arguments, "--accessToken", session.getAccessToken());
|
||||
|
||||
arguments.add("--username");
|
||||
arguments.add(session.getUsername());
|
||||
|
||||
arguments.add("--uuid");
|
||||
arguments.add(session.getUuid());
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "main", at = @At("HEAD"), argsOnly = true, remap = false)
|
||||
private static String[] setArgs(String[] args) {
|
||||
List<String> arguments = new ArrayList<>(Arrays.asList(args));
|
||||
replace(arguments, "--version", "1.18.1");
|
||||
replace(arguments, "--versionType", "release");
|
||||
replaceVersion(arguments);
|
||||
|
||||
try {
|
||||
String authFile = System.getenv("LOGIN_FILE");
|
||||
|
@ -44,13 +58,7 @@ public abstract class MixinMinecraftMain {
|
|||
List<String> loginDetails = Files.readAllLines(Paths.get(authFile));
|
||||
if (loginDetails.size() >= 2) {
|
||||
Session session = getAuthenticatedSession(loginDetails.get(0), loginDetails.get(1));
|
||||
replace(arguments, "--accessToken", session.getAccessToken());
|
||||
|
||||
arguments.add("--username");
|
||||
arguments.add(session.getUsername());
|
||||
|
||||
arguments.add("--uuid");
|
||||
arguments.add(session.getUuid());
|
||||
replaceSession(arguments, session);
|
||||
}
|
||||
} catch (AuthenticationException | IOException ignored) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue