Warn additional mod loaders.

This commit is contained in:
shedaniel
2021-01-09 18:46:16 +08:00
parent d3a127f995
commit 12b3ffb909

View File

@@ -20,8 +20,11 @@
package me.shedaniel.architectury;
import com.google.common.collect.ImmutableMap;
import org.apache.logging.log4j.LogManager;
import org.jetbrains.annotations.ApiStatus;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ApiStatus.Internal
@@ -37,16 +40,18 @@ public class Architectury {
}
static {
String loader = null;
List<String> loader = new ArrayList<>();
for (Map.Entry<String, String> entry : MOD_LOADERS.entrySet()) {
try {
Class.forName(entry.getKey(), false, Architectury.class.getClassLoader());
loader = entry.getValue();
loader.add(entry.getValue());
break;
} catch (ClassNotFoundException ignored) {}
}
if (loader == null)
if (loader.isEmpty())
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);
}
}