From 1df4f74b79a7688929fa0a369f8857f7e5a8db8a Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 24 Dec 2010 01:29:59 +0000 Subject: [PATCH] Start the Plugin interfaces By: Dinnerbone --- paper-api/src/org/bukkit/plugin/Plugin.java | 33 +++++++++++++ .../src/org/bukkit/plugin/PluginLoader.java | 48 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 paper-api/src/org/bukkit/plugin/Plugin.java create mode 100644 paper-api/src/org/bukkit/plugin/PluginLoader.java diff --git a/paper-api/src/org/bukkit/plugin/Plugin.java b/paper-api/src/org/bukkit/plugin/Plugin.java new file mode 100644 index 0000000000..78cb7dc633 --- /dev/null +++ b/paper-api/src/org/bukkit/plugin/Plugin.java @@ -0,0 +1,33 @@ + +package org.bukkit.plugin; + +/** + * Represents a plugin + */ +public abstract class Plugin { + private boolean isEnabled = false; + + /** + * Returns a value indicating whether or not this plugin is currently enabled + * + * @return true if this plugin is enabled, otherwise false + */ + public final boolean isEnabled() { + return isEnabled; + } + + /** + * Called when this plugin is enabled + */ + protected abstract void onEnable(); + + /** + * Called when this plugin is disabled + */ + protected abstract void onDisable(); + + /** + * Called when this plugin is first initialized + */ + protected abstract void onInitialize(); +} diff --git a/paper-api/src/org/bukkit/plugin/PluginLoader.java b/paper-api/src/org/bukkit/plugin/PluginLoader.java new file mode 100644 index 0000000000..6a11406ce2 --- /dev/null +++ b/paper-api/src/org/bukkit/plugin/PluginLoader.java @@ -0,0 +1,48 @@ + +package org.bukkit.plugin; + +import java.io.File; + +/** + * Represents a plugin loader, which provides access and management for all plugins + * currently loaded on a server instance + */ +public interface PluginLoader { + /** + * Checks if the given plugin is loaded and returns it when applicable + * + * Please note that the name of the plugin is case-sensitive + * + * @param name Name of the plugin to check + * @return Plugin if it exists, otherwise null + */ + public Plugin getPlugin(String name); + /** + * Checks if the given plugin is enabled or not + * + * Please note that the name of the plugin is case-sensitive. + * + * @param name Name of the plugin to check + * @return true if the plugin is enabled, otherwise false + */ + public boolean isPluginEnabled(String name); + + /** + * Checks if the given plugin is enabled or not + * + * @param plugin Plugin to check + * @return true if the plugin is enabled, otherwise false + */ + public boolean isPluginEnabled(Plugin plugin); + + /** + * Loads the plugin contained in the specified file + * + * File must be a .jar and contain a valid plugin.yaml file + * + * @param file File to attempt to load + * @return Plugin that was contained in the specified file, or null if + * unsuccessful + */ + public Plugin loadPlugin(File file); +}