summaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-11 17:40:13 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-11 17:40:13 +0200
commit7074b8e7ea7673249dcfc90cf9d2fd70b773711f (patch)
tree7d370ce3640db70b8f30f4da6086aa2c8ec504e9 /src/main/java/cc/polyfrost
parent20b0882182c6212da7da6bb3386ca345e73bae34 (diff)
downloadOneConfigLoader-7074b8e7ea7673249dcfc90cf9d2fd70b773711f.tar.gz
OneConfigLoader-7074b8e7ea7673249dcfc90cf9d2fd70b773711f.tar.bz2
OneConfigLoader-7074b8e7ea7673249dcfc90cf9d2fd70b773711f.zip
back to transformer
Diffstat (limited to 'src/main/java/cc/polyfrost')
-rw-r--r--src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java42
1 files changed, 7 insertions, 35 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java b/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java
index 25f8071..3015008 100644
--- a/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java
+++ b/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java
@@ -24,8 +24,7 @@ import java.util.Map;
public class OneConfigLoader implements IFMLLoadingPlugin {
- private final Object transformer;
- private final Class<?> clazz;
+ private final IFMLLoadingPlugin transformer;
public OneConfigLoader() {
File oneConfigDir = new File(Launch.minecraftHome, "OneConfig");
@@ -80,8 +79,7 @@ public class OneConfigLoader implements IFMLLoadingPlugin {
addToClasspath(oneConfigFile);
}
try {
- clazz = Launch.classLoader.findClass("cc.polyfrost.oneconfig.internal.plugin.LoadingPlugin");
- transformer = clazz.newInstance();
+ transformer = ((IFMLLoadingPlugin) Launch.classLoader.findClass("cc.polyfrost.oneconfig.internal.plugin.LoadingPlugin").newInstance());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
@@ -172,52 +170,26 @@ public class OneConfigLoader implements IFMLLoadingPlugin {
@Override
public String[] getASMTransformerClass() {
- try {
- return transformer == null ? new String[]{} : (String[]) clazz.getDeclaredMethod("getASMTransformerClass").invoke(transformer);
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- e.printStackTrace();
- }
- return new String[]{};
+ return transformer == null ? new String[]{} : transformer.getASMTransformerClass();
}
@Override
public String getModContainerClass() {
- try {
- return transformer == null ? null : (String) clazz.getDeclaredMethod("getModContainerClass").invoke(transformer);
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- e.printStackTrace();
- }
- return null;
+ return transformer == null ? null : transformer.getModContainerClass();
}
@Override
public String getSetupClass() {
- try {
- return transformer == null ? null : (String) clazz.getDeclaredMethod("getSetupClass").invoke(transformer);
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- e.printStackTrace();
- }
- return null;
+ return transformer == null ? null : transformer.getSetupClass();
}
@Override
public void injectData(Map<String, Object> data) {
- try {
- if (transformer != null) {
- clazz.getDeclaredMethod("injectData", Map.class).invoke(transformer, data);
- }
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- e.printStackTrace();
- }
+ if (transformer != null) transformer.injectData(data);
}
@Override
public String getAccessTransformerClass() {
- try {
- return transformer == null ? null : (String) clazz.getDeclaredMethod("getAccessTransformerClass").invoke(transformer);
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- e.printStackTrace();
- }
- return null;
+ return transformer == null ? null : transformer.getAccessTransformerClass();
}
}