summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/plugin/PluginDescriptionFile.java13
-rw-r--r--src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java9
-rw-r--r--src/main/java/org/bukkit/plugin/java/PluginClassLoader.java5
3 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
index 6469ed68..69f40968 100644
--- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
+++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
@@ -19,6 +19,7 @@ public final class PluginDescriptionFile {
private static final Yaml yaml = new Yaml(new SafeConstructor());
private String name = null;
private String main = null;
+ private String classLoaderOf = null;
private ArrayList<String> depend = null;
private ArrayList<String> softDepend = null;
private String version = null;
@@ -154,6 +155,10 @@ public final class PluginDescriptionFile {
return defaultPerm;
}
+ public String getClassLoaderOf() {
+ return classLoaderOf;
+ }
+
@SuppressWarnings("unchecked")
private void loadMap(Map<String, Object> map) throws InvalidDescriptionException {
try {
@@ -195,6 +200,10 @@ public final class PluginDescriptionFile {
}
}
+ if (map.containsKey("class-loader-of")) {
+ classLoaderOf = map.get("class-loader-of").toString();
+ }
+
if (map.containsKey("depend")) {
try {
depend = (ArrayList<String>) map.get("depend");
@@ -318,6 +327,10 @@ public final class PluginDescriptionFile {
map.put("authors", authors);
}
+ if (classLoaderOf != null) {
+ map.put("class-loader-of", classLoaderOf);
+ }
+
return map;
}
}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index b73c46b4..d12305bc 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -167,7 +167,14 @@ public class JavaPluginLoader implements PluginLoader {
URL[] urls = new URL[1];
urls[0] = file.toURI().toURL();
- loader = new PluginClassLoader(this, urls, getClass().getClassLoader());
+
+ if (description.getClassLoaderOf() != null) {
+ loader = loaders.get(description.getClassLoaderOf());
+ loader.addURL(urls[0]);
+ } else {
+ loader = new PluginClassLoader(this, urls, getClass().getClassLoader());
+ }
+
Class<?> jarClass = Class.forName(description.getMain(), true, loader);
Class<? extends JavaPlugin> plugin = jarClass.asSubclass(JavaPlugin.class);
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index f998e309..dd7bffc5 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -20,6 +20,11 @@ public class PluginClassLoader extends URLClassLoader {
}
@Override
+ public void addURL(URL url) { // Override for access level!
+ super.addURL(url);
+ }
+
+ @Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
return findClass(name, true);
}