mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Be noisy when API is in a coremod. It'll never work and modders should realize that fact.
This commit is contained in:
1 parent
8e9feb21fa
commit
a703367553
3 files changed
+24
-1
No files matched your search
@@ -639,7 +639,7 @@ public class Loader
|
||||
return "8.0.99.99";
|
||||
}
|
||||
|
||||
public ClassLoader getModClassLoader()
|
||||
public ModClassLoader getModClassLoader()
|
||||
{
|
||||
return modClassLoader;
|
||||
}
|
||||
|
||||
@@ -90,6 +90,9 @@ public class ModAPIManager {
|
||||
|
||||
public void validate(String providedAPI, String apiOwner, String apiVersion)
|
||||
{
|
||||
if (Loader.instance().getModClassLoader().containsSource(this.getSource())) {
|
||||
FMLLog.bigWarning("The API %s from source %s is loaded from an incompatible classloader. THIS WILL NOT WORK!", providedAPI, this.getSource().getAbsolutePath());
|
||||
}
|
||||
// TODO Compare this annotation data to the one we first found. Maybe barf if there is inconsistency?
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -30,6 +31,7 @@ import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* A simple delegating class loader used to load mods into the system
|
||||
@@ -42,6 +44,7 @@ public class ModClassLoader extends URLClassLoader
|
||||
{
|
||||
private static final List<String> STANDARD_LIBRARIES = ImmutableList.of("jinput.jar", "lwjgl.jar", "lwjgl_util.jar", "rt.jar");
|
||||
private LaunchClassLoader mainClassLoader;
|
||||
private List<File> sources;
|
||||
|
||||
public ModClassLoader(ClassLoader parent) {
|
||||
super(new URL[0], null);
|
||||
@@ -52,6 +55,7 @@ public class ModClassLoader extends URLClassLoader
|
||||
{
|
||||
URL url = modFile.toURI().toURL();
|
||||
mainClassLoader.addURL(url);
|
||||
this.sources.add(modFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,4 +152,20 @@ public class ModClassLoader extends URLClassLoader
|
||||
modAPI.initTable(dataTable);
|
||||
return modAPI;
|
||||
}
|
||||
|
||||
List<URL> parentURLs = null;
|
||||
public boolean containsSource(File source)
|
||||
{
|
||||
if (parentURLs == null) {
|
||||
parentURLs = Arrays.asList(mainClassLoader.getURLs());
|
||||
}
|
||||
try
|
||||
{
|
||||
return parentURLs.contains(source.toURI().toURL());
|
||||
} catch (MalformedURLException e)
|
||||
{
|
||||
// shouldn't happen
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user