Skip to content

Commit

Permalink
auto init classes
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Nov 9, 2024
1 parent 2e10dbb commit 2341ccc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ dependencies {
}

api "codechicken:codechickenlib:3.2.3.358"
// api "gregtech:gregtech:2.8.10-beta", { transitive false }

// compiles all mods, and selectively enables mods being debugged
mod_dependencies.entrySet().forEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -148,6 +150,14 @@ protected void loadClassScripts(GroovyScriptEngine engine, Binding binding, Set<
}
// the superclass of class files is Object
if (clazz.getSuperclass() != Script.class && shouldRunFile(classFile)) {
try {
// $getLookup is present on all groovy created classes
// call it cause the class to be initialised
Method m = clazz.getMethod("$getLookup");
m.invoke(null);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
GroovyLog.get().errorMC("Error initialising class '{}'", clazz.getName());
}
executedClasses.add(classFile);
}
}
Expand Down

0 comments on commit 2341ccc

Please sign in to comment.