summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorNathan Adams <dinnerbone@dinnerbone.com>2012-01-15 12:54:06 +0000
committerNathan Adams <dinnerbone@dinnerbone.com>2012-01-15 12:54:06 +0000
commitbc95edd4dc77aec8698d3b3c9a43838f71e04be0 (patch)
tree277dc51a25e22088e6a93c8cdc449bf85ce0d1fc /src/main/java/org
parenta10057b54164eef24bbd99708d7b759bed29f281 (diff)
downloadbukkit-bc95edd4dc77aec8698d3b3c9a43838f71e04be0.tar
bukkit-bc95edd4dc77aec8698d3b3c9a43838f71e04be0.tar.gz
bukkit-bc95edd4dc77aec8698d3b3c9a43838f71e04be0.tar.lz
bukkit-bc95edd4dc77aec8698d3b3c9a43838f71e04be0.tar.xz
bukkit-bc95edd4dc77aec8698d3b3c9a43838f71e04be0.zip
Added "class-loader-of" field to plugin.yml. Big thanks to CmdrDats for the PR.
Diffstat (limited to 'src/main/java/org')
-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);
}