Fix issue with slf4j loading

This commit is contained in:
Luck 2017-12-29 16:52:11 +00:00
parent bff9715e7f
commit 9bb1ba12b2
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 3 additions and 16 deletions

View File

@ -38,7 +38,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* A fake classloader instance which sits in-front of a PluginClassLoader, which * A fake classloader instance which sits in-front of a PluginClassLoader, and
* attempts to load classes from it's own sources before allowing the PCL to load * attempts to load classes from it's own sources before allowing the PCL to load
* the class. * the class.
* *

View File

@ -103,14 +103,10 @@ public class DependencyManager {
dependencies.add(Dependency.JEDIS); dependencies.add(Dependency.JEDIS);
} }
// don't load slf4j if it's already present // don't load slf4j or configurate dependencies on sponge, as they're already present
if (classExists("org.slf4j.Logger") && classExists("org.slf4j.LoggerFactory")) { if (plugin.getServerType() == PlatformType.SPONGE) {
dependencies.remove(Dependency.SLF4J_API); dependencies.remove(Dependency.SLF4J_API);
dependencies.remove(Dependency.SLF4J_SIMPLE); dependencies.remove(Dependency.SLF4J_SIMPLE);
}
// don't load configurate dependencies on sponge
if (plugin.getServerType() == PlatformType.SPONGE) {
dependencies.remove(Dependency.CONFIGURATE_CORE); dependencies.remove(Dependency.CONFIGURATE_CORE);
dependencies.remove(Dependency.CONFIGURATE_GSON); dependencies.remove(Dependency.CONFIGURATE_GSON);
dependencies.remove(Dependency.CONFIGURATE_YAML); dependencies.remove(Dependency.CONFIGURATE_YAML);
@ -195,15 +191,6 @@ public class DependencyManager {
} }
} }
private static boolean classExists(String className) {
try {
Class.forName(className);
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
public static void loadUrlIntoClassLoader(URL url, ClassLoader classLoader) { public static void loadUrlIntoClassLoader(URL url, ClassLoader classLoader) {
if (classLoader instanceof URLClassLoader) { if (classLoader instanceof URLClassLoader) {
try { try {