blob: f7431ad9b327c90d8485f1ea95688f12939f239d (
plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package moe.nea.modernjava.launch;
import moe.nea.modernjava.launch.live.FCPFixTweaker;
import moe.nea.modernjava.launch.util.ClassLoaderManipulations;
import moe.nea.modernjava.launch.util.WellKnownBlackboard;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import java.net.URI;
import java.util.List;
import java.util.Map;
import static moe.nea.modernjava.launch.util.PropertyNames.HAS_RELAUNCHED;
/**
* Global entrypoint for both the FML part of the relaunched (live) and the relaunching (relaunch) runs. Execution
* begins during static initialization to be as early as possible. There aren't any security implications, but especially
* on Windows it can be problematic if two processes try to open up the same file, so we try to avoid these conflicts.
* Also, it's just a faster launch.
*/
@IFMLLoadingPlugin.Name("ModernJavaRelauncher")
public class FCPEntryPoint implements IFMLLoadingPlugin {
public static URI fileUri;
static {
try {
fileUri = new URI(FCPEntryPoint.class.getProtectionDomain().getCodeSource().getLocation().toString().split("!")[0]);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (System.getProperty(HAS_RELAUNCHED) == null) {
try {
Class.forName("moe.nea.modernjava.launch.relaunch.FCPRelauncher")
.getMethod("relaunch").invoke(null);
} catch (Throwable t) {
System.out.println("Failed to relaunch");
t.printStackTrace();
}
} else {
try {
ClassLoaderManipulations.addToParentClassLoader(fileUri.toURL());
} catch (Exception e) {
throw new RuntimeException(e);
}
List<String> tweakClasses = WellKnownBlackboard.tweakerNames();
tweakClasses.add(FCPFixTweaker.class.getName());
}
}
@Override
public String[] getASMTransformerClass() {
return new String[]{
};
}
@Override
public String getModContainerClass() {
return null;
}
@Override
public String getSetupClass() {
return null;
}
@Override
public void injectData(Map<String, Object> map) {
}
@Override
public String getAccessTransformerClass() {
return null;
}
}
|