|
@@ -7,6 +7,8 @@ import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
+import java.lang.reflect.Constructor;
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
@@ -27,9 +29,13 @@ public final class CompleteConfig {
|
|
|
public static void registerExternalExtension(String modID, Class<? extends CompleteConfigExtension> extensionClass) {
|
|
|
if(!FabricLoader.getInstance().isModLoaded(modID)) return;
|
|
|
try {
|
|
|
- extensions.put(modID, extensionClass.newInstance());
|
|
|
- } catch (InstantiationException | IllegalAccessException e) {
|
|
|
- LOGGER.warn("[CompleteConfig] Failed to instantiate extension " + modID, e);
|
|
|
+ Constructor<? extends CompleteConfigExtension> constructor = extensionClass.getDeclaredConstructor();
|
|
|
+ if (!constructor.isAccessible()) {
|
|
|
+ constructor.setAccessible(true);
|
|
|
+ }
|
|
|
+ extensions.put(modID, constructor.newInstance());
|
|
|
+ } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
|
|
+ LOGGER.error("[CompleteConfig] Failed to instantiate extension " + modID, e);
|
|
|
}
|
|
|
}
|
|
|
|