From 6ec2d4bc66bdc60bcaf05f0405685090540ac934 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Fri, 24 Dec 2010 01:29:59 +0000 Subject: [PATCH] Start the Plugin interfaces --- src/org/bukkit/plugin/Plugin.java | 33 +++++++++++++++++ src/org/bukkit/plugin/PluginLoader.java | 48 +++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/org/bukkit/plugin/Plugin.java create mode 100644 src/org/bukkit/plugin/PluginLoader.java diff --git a/src/org/bukkit/plugin/Plugin.java b/src/org/bukkit/plugin/Plugin.java new file mode 100644 index 00000000..78cb7dc6 --- /dev/null +++ b/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/src/org/bukkit/plugin/PluginLoader.java b/src/org/bukkit/plugin/PluginLoader.java new file mode 100644 index 00000000..6a11406c --- /dev/null +++ b/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); +}