From e3d491491a6fb9ca285e3c2e27facbee39ac8776 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 24 Dec 2010 13:06:44 +0000 Subject: [PATCH] Few additions to Plugin for retrieving the Server and PluginLoader responsible for the plugin By: Dinnerbone --- paper-api/src/org/bukkit/plugin/Plugin.java | 33 +++++++++++++++++++ .../src/org/bukkit/plugin/PluginManager.java | 3 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/paper-api/src/org/bukkit/plugin/Plugin.java b/paper-api/src/org/bukkit/plugin/Plugin.java index 78cb7dc633..ba781ce261 100644 --- a/paper-api/src/org/bukkit/plugin/Plugin.java +++ b/paper-api/src/org/bukkit/plugin/Plugin.java @@ -1,11 +1,44 @@ package org.bukkit.plugin; +import org.bukkit.Server; + /** * Represents a plugin */ public abstract class Plugin { private boolean isEnabled = false; + private final PluginLoader loader; + private final Server server; + + /** + * Constructs a new plugin instance + * + * @param pluginLoader PluginLoader that is responsible for this plugin + * @param instance Server instance that is running this plugin + */ + protected Plugin(PluginLoader pluginLoader, Server instance) { + loader = pluginLoader; + server = instance; + } + + /** + * Gets the associated PluginLoader responsible for this plugin + * + * @return PluginLoader that controls this plugin + */ + protected final PluginLoader getPluginLoader() { + return loader; + } + + /** + * Returns the Server instance currently running this plugin + * + * @return Server running this plugin + */ + public final Server getServer() { + return server; + } /** * Returns a value indicating whether or not this plugin is currently enabled diff --git a/paper-api/src/org/bukkit/plugin/PluginManager.java b/paper-api/src/org/bukkit/plugin/PluginManager.java index 1185440731..de710414cf 100644 --- a/paper-api/src/org/bukkit/plugin/PluginManager.java +++ b/paper-api/src/org/bukkit/plugin/PluginManager.java @@ -26,8 +26,9 @@ public final class PluginManager { * Registers the specified plugin loader * * @param loader Class name of the PluginLoader to register + * @throws IllegalArgumentException Thrown when the given Class is not a valid PluginLoader */ - public void RegisterInterface(Class loader) { + public void RegisterInterface(Class loader) throws IllegalArgumentException { PluginLoader instance; if (PluginLoader.class.isAssignableFrom(loader)) {