13
0
geforkt von Mirrors/Paper

Added "class-loader-of" field to plugin.yml. Big thanks to CmdrDats for the PR.

By: Nathan Adams <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-01-15 12:54:06 +00:00
Ursprung 77c577bdf8
Commit 8377ee22f8
3 geänderte Dateien mit 26 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -19,6 +19,7 @@ public final class PluginDescriptionFile {
private static final Yaml yaml = new Yaml(new SafeConstructor()); private static final Yaml yaml = new Yaml(new SafeConstructor());
private String name = null; private String name = null;
private String main = null; private String main = null;
private String classLoaderOf = null;
private ArrayList<String> depend = null; private ArrayList<String> depend = null;
private ArrayList<String> softDepend = null; private ArrayList<String> softDepend = null;
private String version = null; private String version = null;
@ -154,6 +155,10 @@ public final class PluginDescriptionFile {
return defaultPerm; return defaultPerm;
} }
public String getClassLoaderOf() {
return classLoaderOf;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void loadMap(Map<String, Object> map) throws InvalidDescriptionException { private void loadMap(Map<String, Object> map) throws InvalidDescriptionException {
try { 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")) { if (map.containsKey("depend")) {
try { try {
depend = (ArrayList<String>) map.get("depend"); depend = (ArrayList<String>) map.get("depend");
@ -318,6 +327,10 @@ public final class PluginDescriptionFile {
map.put("authors", authors); map.put("authors", authors);
} }
if (classLoaderOf != null) {
map.put("class-loader-of", classLoaderOf);
}
return map; return map;
} }
} }

Datei anzeigen

@ -167,7 +167,14 @@ public class JavaPluginLoader implements PluginLoader {
URL[] urls = new URL[1]; URL[] urls = new URL[1];
urls[0] = file.toURI().toURL(); 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<?> jarClass = Class.forName(description.getMain(), true, loader);
Class<? extends JavaPlugin> plugin = jarClass.asSubclass(JavaPlugin.class); Class<? extends JavaPlugin> plugin = jarClass.asSubclass(JavaPlugin.class);

Datei anzeigen

@ -19,6 +19,11 @@ public class PluginClassLoader extends URLClassLoader {
this.loader = loader; this.loader = loader;
} }
@Override
public void addURL(URL url) { // Override for access level!
super.addURL(url);
}
@Override @Override
protected Class<?> findClass(String name) throws ClassNotFoundException { protected Class<?> findClass(String name) throws ClassNotFoundException {
return findClass(name, true); return findClass(name, true);