3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

Some classloader/dependency versioning fix ups

Dieser Commit ist enthalten in:
Andrew Steinborn 2021-05-16 00:33:03 -04:00
Ursprung a155f91dfd
Commit a6d4ad6950
4 geänderte Dateien mit 14 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -343,7 +343,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
}
}
logger.info("Loaded {} plugins", pluginManager.plugins().size());
logger.info("Loaded {} plugin(s)", pluginManager.plugins().size() - 1);
}
public Bootstrap createBootstrap(@Nullable EventLoopGroup group, SocketAddress target) {

Datei anzeigen

@ -36,8 +36,8 @@ public class PluginClassLoader extends URLClassLoader {
private final PluginDescription description;
public PluginClassLoader(URL[] urls, PluginDescription description) {
super(urls);
public PluginClassLoader(URL[] urls, ClassLoader parent, PluginDescription description) {
super(urls, parent);
this.description = description;
}
@ -60,14 +60,18 @@ public class PluginClassLoader extends URLClassLoader {
}
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
return loadClass0(name, resolve, true);
protected Class<?> findClass(String name) throws ClassNotFoundException {
return findClass0(name, true);
}
private Class<?> loadClass0(String name, boolean resolve, boolean checkOther)
private Class<?> findClass0(String name, boolean checkOther)
throws ClassNotFoundException {
if (name.startsWith("com.velocitypowered")) {
throw new ClassNotFoundException();
}
try {
return super.loadClass(name, resolve);
return super.findClass(name);
} catch (ClassNotFoundException ignored) {
// Ignored: we'll try others
}
@ -76,7 +80,7 @@ public class PluginClassLoader extends URLClassLoader {
for (PluginClassLoader loader : loaders) {
if (loader != this) {
try {
return loader.loadClass0(name, resolve, false);
return loader.findClass0(name, false);
} catch (ClassNotFoundException ignored) {
// We're trying others, safe to ignore
}

Datei anzeigen

@ -136,7 +136,7 @@ public class VelocityPluginManager implements PluginManager {
Semver dependencyCandidateVersion = new Semver(
dependencyContainer.description().version(), SemverType.NPM);
if (!dependencyCandidateVersion.satisfies(requiredRange)) {
if (dependency.optional()) {
if (!dependency.optional()) {
logger.error(
"Can't load plugin {} due to incompatible dependency {} {} (you have {})",
candidate.id(), dependency.id(), requiredRange,

Datei anzeigen

@ -92,7 +92,7 @@ public class JavaPluginLoader implements PluginLoader {
PluginClassLoader loader = this.classLoaders.computeIfAbsent(pluginJarUri, (uri) -> {
PluginClassLoader classLoader = AccessController.doPrivileged(
(PrivilegedAction<PluginClassLoader>) () -> new PluginClassLoader(new URL[]{pluginJarUrl},
source));
JavaPluginLoader.class.getClassLoader(), source));
classLoader.addToClassloaders();
return classLoader;
});