Browse Source

Warn additional mod loaders.

shedaniel 4 years ago
parent
commit
12b3ffb909

+ 9 - 4
common/src/main/java/me/shedaniel/architectury/Architectury.java

@@ -20,8 +20,11 @@
 package me.shedaniel.architectury;
 package me.shedaniel.architectury;
 
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap;
+import org.apache.logging.log4j.LogManager;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.ApiStatus;
 
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 @ApiStatus.Internal
 @ApiStatus.Internal
@@ -37,16 +40,18 @@ public class Architectury {
     }
     }
     
     
     static {
     static {
-        String loader = null;
+        List<String> loader = new ArrayList<>();
         for (Map.Entry<String, String> entry : MOD_LOADERS.entrySet()) {
         for (Map.Entry<String, String> entry : MOD_LOADERS.entrySet()) {
             try {
             try {
                 Class.forName(entry.getKey(), false, Architectury.class.getClassLoader());
                 Class.forName(entry.getKey(), false, Architectury.class.getClassLoader());
-                loader = entry.getValue();
+                loader.add(entry.getValue());
                 break;
                 break;
             } catch (ClassNotFoundException ignored) {}
             } catch (ClassNotFoundException ignored) {}
         }
         }
-        if (loader == null)
+        if (loader.isEmpty())
             throw new IllegalStateException("No detected mod loader!");
             throw new IllegalStateException("No detected mod loader!");
-        MOD_LOADER = loader;
+        if (loader.size() >= 2)
+            LogManager.getLogger().error("Detected multiple mod loaders! Something is wrong on the classpath! " + String.join(", ", loader));
+        MOD_LOADER = loader.get(0);
     }
     }
 }
 }