-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLitlaunch.txt
202 lines (169 loc) · 6.86 KB
/
Litlaunch.txt
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* Copyright (c) Codetoil 2022
*/
package io.github.codetoil.litlaunch.minecraft;
public abstract class LitLaunch {
public static final String NAME = "LitLaunch";
@Deprecated
public static final String VERSIONF = "0.0.5+build.0";
public static final String MODID = "litlaunch";
public static final ChainableMap<String, Object> EMPTY = new ChainableMap<>();
public static String VERSION = VERSIONF;
private static ICommonProxy ccproxy;
private static Boolean verbose;
private static double timeInit;
private static Command.Side side;
private static Path GamePath;
public static double getTimeInit() {
return timeInit;
}
public static void setVerbose(boolean pVerbose) {
if (verbose == null) {
verbose = pVerbose;
}
}
public static IGetLitLaunchFields getFrontEnd() {
return io.github.codetoil.litlaunch.api.LitLaunch.getLitLaunchFields();
}
public static IMinecraftServer getGetFields() {
return io.github.codetoil.litlaunch.api.LitLaunch.getMinecraftFields();
}
public static void setGetFields(IMinecraftServer getFields) throws IllegalAccessException {
io.github.codetoil.litlaunch.api.LitLaunch.getInstance().setMinecraftFields(getFields);
}
public static PreformMinecraftAction getDoThing() {
return io.github.codetoil.litlaunch.api.LitLaunch.getPreformMinecraftAction();
}
public static void setDoThing(PreformMinecraftAction pDoThing) throws IllegalAccessException {
io.github.codetoil.litlaunch.api.LitLaunch.getInstance().setPreformMinecraftAction(pDoThing);
}
public static Command.Side getSide() {
return side;
}
public static void setSide(Command.Side side) {
if (LitLaunch.side == null) {
LitLaunch.side = side;
}
}
public static void bootstrap(Object logger, ClassLoader classloader, INativeLaunch launch, ILogger iLogger) throws Throwable {
//Inserting the logger to the logger wrapper!
setLOGGER(iLogger);
getLOGGER().setInternalLogger(logger);
//main bootstrap
info("Preforming LitLaunch Bootstrap!");
// Required to make it so that time is readable in a specific way
// It is time 0 in the clock timer thing, the origin for measuring time.
// Change in time = (clock time final - time origin) - (clock time initial - time origin)
// time origin could be 0, but I rather it not be...
timeInit = getTimeInSeconds();
info("Setting up API");
IGetLitLaunchFields frontEnd = new GetLitLaunchFields();
IConstructorMap constructors = new LitConstructorMap();
io.github.codetoil.litlaunch.api.LitLaunch.getInstance().setLitLaunchFields(frontEnd);
io.github.codetoil.litlaunch.api.LitLaunch.getInstance().setConstructorMap(constructors);
LitEvent.init();
LitEventHandler.init();
info("Initializing Proxies");
try {
if (launch.setProxy()) {
debug("Set Proxies");
} else {
error("Proxies not set!");
}
} catch (Throwable e) {
e.printStackTrace();
}
getCCproxy().setGamePath();
info("Locating config file!");
File litlaunchCFG = getGamePath().resolve("config/litlaunch.cfg").toFile();
info("Reading config file for mods and settings...");
ConfigFile.readConfig(litlaunchCFG);
debug("verbose: " + isVerbose());
if (isVerbose()) {
warn("Warning: You have decided for LitLaunch to be verbose! You will see lots of debug messages. You can disable this in the config file.");
}
info("Setting classloader!");
io.github.codetoil.litlaunch.api.LitLaunch.getLitLaunchFields().classLoader().setClassLoader(classloader);
info("Finding and validating mods!");
ModFinder.locateMods(LitLaunch.getGamePath().resolve("mods_litlaunch"));
ModFinder.locateMods(LitLaunch.getGamePath().resolve("mods"));
ModFinder.validateMods();
info("Now Garbage Collecting!");
System.gc();
info("Done! Now sending construction event!");
if (io.github.codetoil.litlaunch.api.LitLaunch.getLitLaunchFields().isVerbose()) {
try {
new EventPrinter();
} catch (IOException e) {
e.printStackTrace();
}
}
LitEventHandler.COMMON.post(new LitEvent(LitLaunch.class, LitEvent.TYPE.CONSTRUCTION, EMPTY));
getCCproxy().construction();
}
public static double getTimeInSeconds() {
return ((double) System.currentTimeMillis()) / 1000.0 - timeInit;
}
public static ILogger getLOGGER() {
return io.github.codetoil.litlaunch.api.LitLaunch.getLogger();
}
public static void setLOGGER(ILogger pILogger) throws IllegalAccessException {
io.github.codetoil.litlaunch.api.LitLaunch.getInstance().setLogger(pILogger);
}
public static void info(Object object) {
getLOGGER().info(object);
}
public static void debug(Object object) {
getLOGGER().debug(object);
}
public static void error(Object object) {
getLOGGER().error(object);
}
public static ICommonProxy getCCproxy() {
return ccproxy;
}
public static void setCcproxy(ICommonProxy ccproxy) {
if (LitLaunch.ccproxy == null) {
LitLaunch.ccproxy = ccproxy;
} else {
info("CCProxy ALREADY SET");
}
}
public static Path getGamePath() {
return GamePath;
}
public static void setGamePath(Path pGamePath) {
GamePath = pGamePath;
}
public static Boolean isVerbose() {
return verbose != null && verbose;
}
public static void warn(Object object) {
getLOGGER().warn(object);
}
public static void preInit() {
LitEventHandler.COMMON.post(new LitEvent(LitLaunch.class, ILitEvent.TYPE.PREINIT, EMPTY));
getCCproxy().preInit();
}
public static void init() {
LitEventHandler.COMMON.post(new LitEvent(LitLaunch.class, ILitEvent.TYPE.INIT, EMPTY));
LitEventHandler.COMMON.post(new LitEvent(LitLaunch.class, ILitEvent.TYPE.TESTSPAM, EMPTY), true);
getCCproxy().init();
}
public static void postInit() {
LitEventHandler.COMMON.post(new LitEvent(LitLaunch.class, ILitEvent.TYPE.POSTINIT, EMPTY));
getCCproxy().postInit();
}
public static void serverLoad() {
LitEventHandler.COMMON.post(new LitEvent(LitLaunch.class, ILitEvent.TYPE.SERVERLOAD, EMPTY));
getCCproxy().serverLoad();
}
public static void fatal(Object object) {
getLOGGER().fatal(object);
}
public static void verbose(Object object) {
getLOGGER().verbose(object);
}
public static void trace(Object object) {
getLOGGER().trace(object);
}