From be4a764932c5346e3612db83c86eed6bcb57e5ed Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 1 Feb 2013 21:40:32 +1100 Subject: [PATCH] Hopefully properly load class depenending on classes from other plugins. --- .../bungee/api/plugin/PluginClassloader.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginClassloader.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginClassloader.java index a4493bb9..dc371228 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginClassloader.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginClassloader.java @@ -17,17 +17,31 @@ public class PluginClassloader extends URLClassLoader } @Override - protected Class findClass(String name) throws ClassNotFoundException + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - for (PluginClassloader loader : allLoaders) + return loadClass0(name, resolve, true); + } + + private Class loadClass0(String name, boolean resolve, boolean checkOther) throws ClassNotFoundException + { + try { - if (loader != this) + return super.loadClass(name, resolve); + } catch (ClassNotFoundException ex) + { + } + if (checkOther) + { + for (PluginClassloader loader : allLoaders) { - try - { - return loader.loadClass(name); - } catch (ClassNotFoundException ex) + if (loader != this) { + try + { + return loader.loadClass0(name, resolve, false); + } catch (ClassNotFoundException ex) + { + } } } }