diff options
author | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-06-09 14:14:21 +0100 |
---|---|---|
committer | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-06-09 14:14:21 +0100 |
commit | e80c39fa6903d053be3a3b4ed8776f23e815058a (patch) | |
tree | 2b5a6c9cbb5891ceb2b3de6580dfd21718917c23 | |
parent | 20de0ed871ebd5564c04c8119f44f299c08fe665 (diff) | |
download | bukkit-e80c39fa6903d053be3a3b4ed8776f23e815058a.tar bukkit-e80c39fa6903d053be3a3b4ed8776f23e815058a.tar.gz bukkit-e80c39fa6903d053be3a3b4ed8776f23e815058a.tar.lz bukkit-e80c39fa6903d053be3a3b4ed8776f23e815058a.tar.xz bukkit-e80c39fa6903d053be3a3b4ed8776f23e815058a.zip |
Allow for easier plugin debugging from an IDEdebugging
-rw-r--r-- | src/main/java/org/bukkit/plugin/java/PluginClassLoader.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java index 13f86338..2822751a 100644 --- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java @@ -1,14 +1,18 @@ package org.bukkit.plugin.java; import java.io.File; +import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.logging.Level; +import com.google.common.base.Throwables; import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; import org.bukkit.plugin.InvalidPluginException; import org.bukkit.plugin.PluginDescriptionFile; @@ -49,11 +53,22 @@ final class PluginClassLoader extends URLClassLoader { throw new InvalidPluginException("main class `" + description.getMain() + "' does not extend JavaPlugin", ex); } - plugin = pluginClass.newInstance(); + if (pluginClass.getClassLoader() == this) { + plugin = pluginClass.newInstance(); + } else { + loader.server.getLogger().log(Level.WARNING, "Trying to load {0} for debugging", description.getName()); + plugin = pluginClass.getConstructor( + JavaPluginLoader.class, PluginDescriptionFile.class, File.class, File.class + ).newInstance(loader, description, dataFolder, file); + } } catch (IllegalAccessException ex) { throw new InvalidPluginException("No public constructor", ex); } catch (InstantiationException ex) { throw new InvalidPluginException("Abnormal plugin type", ex); + } catch (NoSuchMethodException ex) { + throw new InvalidPluginException("Missing constructor", ex); + } catch (InvocationTargetException ex) { + throw new InvalidPluginException(ex); } } |