-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDefaultLaunchHandlerService.java
48 lines (39 loc) · 1.55 KB
/
DefaultLaunchHandlerService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Copyright (c) Forge Development LLC
* SPDX-License-Identifier: LGPL-3.0-only
*/
package cpw.mods.modlauncher;
import cpw.mods.modlauncher.api.*;
import java.lang.reflect.*;
import java.nio.file.*;
/**
* This has not worked in years
*/
@Deprecated(forRemoval = true, since = "10.1")
public class DefaultLaunchHandlerService implements ILaunchHandlerService {
public static final String LAUNCH_PROPERTY = "minecraft.client.jar";
public static final String LAUNCH_PATH_STRING = System.getProperty(LAUNCH_PROPERTY);
@Override
public String name() {
return "minecraft";
}
@Override
public void configureTransformationClassLoader(final ITransformingClassLoaderBuilder builder) {
if (LAUNCH_PATH_STRING == null) {
throw new IllegalStateException("Missing "+ LAUNCH_PROPERTY +" environment property. Update your launcher!");
}
builder.addTransformationPath(FileSystems.getDefault().getPath(LAUNCH_PATH_STRING));
}
@Override
public ServiceRunner launchService(String[] arguments, ModuleLayer gameLayer) {
return () -> {
final Class<?> mcClass = Class.forName(gameLayer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main");
final Method mcClassMethod = mcClass.getMethod("main", String[].class);
mcClassMethod.invoke(null, (Object) arguments);
};
}
@Override
public NamedPath[] getPaths() {
return new NamedPath[] {new NamedPath("launch",FileSystems.getDefault().getPath(LAUNCH_PATH_STRING))};
}
}