Be noisy when API is in a coremod. It'll never work and modders should realize that fact.
This commit is contained in:
parent
8e9feb21fa
commit
a703367553
|
@ -639,7 +639,7 @@ public class Loader
|
||||||
return "8.0.99.99";
|
return "8.0.99.99";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassLoader getModClassLoader()
|
public ModClassLoader getModClassLoader()
|
||||||
{
|
{
|
||||||
return modClassLoader;
|
return modClassLoader;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,9 @@ public class ModAPIManager {
|
||||||
|
|
||||||
public void validate(String providedAPI, String apiOwner, String apiVersion)
|
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?
|
// 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.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple delegating class loader used to load mods into the system
|
* 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 static final List<String> STANDARD_LIBRARIES = ImmutableList.of("jinput.jar", "lwjgl.jar", "lwjgl_util.jar", "rt.jar");
|
||||||
private LaunchClassLoader mainClassLoader;
|
private LaunchClassLoader mainClassLoader;
|
||||||
|
private List<File> sources;
|
||||||
|
|
||||||
public ModClassLoader(ClassLoader parent) {
|
public ModClassLoader(ClassLoader parent) {
|
||||||
super(new URL[0], null);
|
super(new URL[0], null);
|
||||||
|
@ -52,6 +55,7 @@ public class ModClassLoader extends URLClassLoader
|
||||||
{
|
{
|
||||||
URL url = modFile.toURI().toURL();
|
URL url = modFile.toURI().toURL();
|
||||||
mainClassLoader.addURL(url);
|
mainClassLoader.addURL(url);
|
||||||
|
this.sources.add(modFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -148,4 +152,20 @@ public class ModClassLoader extends URLClassLoader
|
||||||
modAPI.initTable(dataTable);
|
modAPI.initTable(dataTable);
|
||||||
return modAPI;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue