MCPcopy Create free account
hub / github.com/TheCyaniteProject/exit_code_java / modLoader

Method modLoader

src/main/java/exitcode/API.java:268–307  ·  view source on GitHub ↗

This adds the .class files from an addon.eca (ExitCode Addon) to the game classpath. NOT TO BE REFERENCED BY MODS LoadingScreen.setLoadingBar(1.0); LoadingScreen.setTaskText("All Done.");

()

Source from the content-addressed store, hash-verified

266 */
267
268 static void modLoader() {
269 LoadingScreen.setLoadingBar(-1.0);
270 LoadingScreen.setTaskText("Checking for addons");
271 File folder = new File(System.getProperty("user.dir"), "addons");
272 if (folder.isDirectory()) {
273 API.println("Checking for addons...");
274 if(folder.list().length > 0) {
275 if (folder.list().length < 2) {
276 API.println("1 addon found!");
277 } else {
278 API.println(String.format("%s addons found!", folder.list().length));
279 }
280
281 File[] listOfFiles = folder.listFiles();
282 Integer num = 0;
283 for (File file : listOfFiles) {
284 num++;
285 Double percent = (double)(((num * 100.0f) / folder.list().length) / 100);
286 if (file.isFile()) {
287 try {
288 LoadingScreen.setTaskText(String.format("Loading %s", file.getName()));
289 API.println(String.format("Loading %s...", file.getName()));
290 URLClassLoader child = new URLClassLoader(new URL[] {new URL("file:///" + file.getPath())});
291 Class.forName("addon.Plugin", true, child);
292 API.println(String.format("Finished loading %s!", file.getName()));
293 } catch(Exception e) {
294 API.println(e.toString());
295 Logger.error(String.format("Failed to load %s!", file.getName()));
296 }
297 LoadingScreen.setLoadingBar(percent);
298 }
299 }
300 } else {
301 API.println("No mods found");
302 }
303 } else {
304 folder.mkdir();
305 }
306 LoadingScreen.setLoadingBar(1.0);
307 }
308}

Callers 1

loadTasksMethod · 0.95

Calls 4

setLoadingBarMethod · 0.95
setTaskTextMethod · 0.95
printlnMethod · 0.95
errorMethod · 0.95

Tested by

no test coverage detected