Lortseam пре 4 година
родитељ
комит
a893629b04

+ 9 - 3
src/main/java/me/lortseam/completeconfig/CompleteConfig.java

@@ -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);
         }
     }
 

+ 3 - 0
src/main/java/me/lortseam/completeconfig/extensions/clothbasicmath/ClothBasicMathExtension.java

@@ -1,6 +1,8 @@
 package me.lortseam.completeconfig.extensions.clothbasicmath;
 
 import com.google.common.collect.ImmutableList;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import me.lortseam.completeconfig.data.ColorEntry;
 import me.lortseam.completeconfig.data.entry.Transformation;
 import me.lortseam.completeconfig.extensions.CompleteConfigExtension;
@@ -11,6 +13,7 @@ import org.spongepowered.configurate.serialize.TypeSerializerCollection;
 
 import java.util.Collection;
 
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class ClothBasicMathExtension implements CompleteConfigExtension {
 
     private static final TypeSerializerCollection SERIALIZERS = TypeSerializerCollection.builder()