diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index bdecbea2dc..8fd726bd9a 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import org.apache.commons.lang.Validate; import org.bukkit.Server; import org.bukkit.Warning.WarningState; import org.bukkit.command.Command; @@ -405,4 +406,59 @@ public abstract class JavaPlugin extends PluginBase { public String toString() { return description.getFullName(); } + + /** + * This method provides fast access to the plugin that has {@link + * #getProvidingPlugin(Class) provided} the given plugin class, which is + * usually the plugin that implemented it. + *
+ * An exception to this would be if plugin's jar that contained the class
+ * does not extend the class, where the intended plugin would have
+ * resided in a different jar / classloader.
+ *
+ * @param clazz the class desired
+ * @return the plugin that provides and implements said class, or null
+ * if called from an inconsistent static initialization block
+ * @throws IllegalArgumentException if clazz is null
+ * @throws IllegalArgumentException if clazz does not extend {@link
+ * JavaPlugin}
+ * @throws IllegalArgumentException if clazz was not provided by a
+ * plugin, for example, if called with
+ * JavaPlugin.getPlugin(JavaPlugin.class)
+ * @throws ClassCastException if plugin that provided the class does not
+ * extend the class
+ */
+ public static