Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.plugin;
2
3import org.bukkit.event.Event;
4import org.bukkit.event.Event.Priority;
5import org.bukkit.event.Listener;
6import org.bukkit.permissions.Permissible;
7import org.bukkit.permissions.Permission;
8
9import java.io.File;
10import java.util.Set;
11
12/**
13 * Handles all plugin management from the Server
14 */
15public interface PluginManager {
16
17 /**
18 * Registers the specified plugin loader
19 *
20 * @param loader Class name of the PluginLoader to register
21 * @throws IllegalArgumentException Thrown when the given Class is not a valid PluginLoader
22 */
23 public void registerInterface(Class<? extends PluginLoader> loader) throws IllegalArgumentException;
24
25 /**
26 * Checks if the given plugin is loaded and returns it when applicable
27 * <p>
28 * Please note that the name of the plugin is case-sensitive
29 *
30 * @param name Name of the plugin to check
31 * @return Plugin if it exists, otherwise null
32 */
33 public Plugin getPlugin(String name);
34
35 /**
36 * Gets a list of all currently loaded plugins
37 *
38 * @return Array of Plugins
39 */
40 public Plugin[] getPlugins();
41
42 /**
43 * Checks if the given plugin is enabled or not
44 * <p>
45 * Please note that the name of the plugin is case-sensitive.
46 *
47 * @param name Name of the plugin to check
48 * @return true if the plugin is enabled, otherwise false
49 */
50 public boolean isPluginEnabled(String name);
51
52 /**
53 * Checks if the given plugin is enabled or not
54 *
55 * @param plugin Plugin to check
56 * @return true if the plugin is enabled, otherwise false
57 */
58 public boolean isPluginEnabled(Plugin plugin);
59
60 /**
61 * Loads the plugin in the specified file
62 * <p>
63 * File must be valid according to the current enabled Plugin interfaces
64 *
65 * @param file File containing the plugin to load
66 * @return The Plugin loaded, or null if it was invalid
67 * @throws InvalidPluginException Thrown when the specified file is not a valid plugin
68 * @throws InvalidDescriptionException Thrown when the specified file contains an invalid description
69 */
70 public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException;
71
72 /**
73 * Loads the plugins contained within the specified directory
74 *
75 * @param directory Directory to check for plugins
76 * @return A list of all plugins loaded
77 */
78 public Plugin[] loadPlugins(File directory);
79
80 /**
81 * Disables all the loaded plugins
82 */
83 public void disablePlugins();
84
85 /**
86 * Disables and removes all plugins
87 */
88 public void clearPlugins();
89
90 /**
91 * Calls a player related event with the given details
92 *
93 * @param type Type of player related event to call
94 * @param event Event details
95 */
96 public void callEvent(Event event);
97
98 /**
99 * Registers the given event to the specified listener
100 *
101 * @param type EventType to register
102 * @param listener Listener to register
103 * @param priority Priority of this event
104 * @param plugin Plugin to register
105 */
106 public void registerEvent(Event.Type type, Listener listener, Priority priority, Plugin plugin);
107
108 /**
109 * Registers the given event to the specified executor
110 *
111 * @param type EventType to register
112 * @param listener Listener to register
113 * @param executor EventExecutor to register
114 * @param priority Priority of this event
115 * @param plugin Plugin to register
116 */
117 public void registerEvent(Event.Type type, Listener listener, EventExecutor executor, Priority priority, Plugin plugin);
118
119 /**
120 * Registers a listener with all events with @EventHandler
121 *
122 * @param listener Listener to register
123 * @param plugin Plugin to register
124 * @see org.bukkit.event.EventHandler
125 */
126 public void registerEvents(Listener listener, Plugin plugin);
127
128 /**
129 * Enables the specified plugin
130 * <p>
131 * Attempting to enable a plugin that is already enabled will have no effect
132 *
133 * @param plugin Plugin to enable
134 */
135 public void enablePlugin(Plugin plugin);
136
137 /**
138 * Disables the specified plugin
139 * <p>
140 * Attempting to disable a plugin that is not enabled will have no effect
141 *
142 * @param plugin Plugin to disable
143 */
144 public void disablePlugin(Plugin plugin);
145
146 /**
147 * Gets a {@link Permission} from its fully qualified name
148 *
149 * @param name Name of the permission
150 * @return Permission, or null if none
151 */
152 public Permission getPermission(String name);
153
154 /**
155 * Adds a {@link Permission} to this plugin manager.
156 * <p>
157 * If a permission is already defined with the given name of the new permission,
158 * an exception will be thrown.
159 *
160 * @param perm Permission to add
161 * @throws IllegalArgumentException Thrown when a permission with the same name already exists
162 */
163 public void addPermission(Permission perm);
164
165 /**
166 * Removes a {@link Permission} registration from this plugin manager.
167 * <p>
168 * If the specified permission does not exist in this plugin manager, nothing will happen.
169 * <p>
170 * Removing a permission registration will <b>not</b> remove the permission from any {@link Permissible}s that have it.
171 *
172 * @param perm Permission to remove
173 */
174 public void removePermission(Permission perm);
175
176 /**
177 * Removes a {@link Permission} registration from this plugin manager.
178 * <p>
179 * If the specified permission does not exist in this plugin manager, nothing will happen.
180 * <p>
181 * Removing a permission registration will <b>not</b> remove the permission from any {@link Permissible}s that have it.
182 *
183 * @param name Permission to remove
184 */
185 public void removePermission(String name);
186
187 /**
188 * Gets the default permissions for the given op status
189 *
190 * @param op Which set of default permissions to get
191 */
192 public Set<Permission> getDefaultPermissions(boolean op);
193
194 /**
195 * Recalculates the defaults for the given {@link Permission}.
196 * <p>
197 * This will have no effect if the specified permission is not registered here.
198 *
199 * @param perm Permission to recalculate
200 */
201 public void recalculatePermissionDefaults(Permission perm);
202
203 /**
204 * Subscribes the given Permissible for information about the requested Permission, by name.
205 * <p>
206 * If the specified Permission changes in any form, the Permissible will be asked to recalculate.
207 *
208 * @param permission Permission to subscribe to
209 * @param permissible Permissible subscribing
210 */
211 public void subscribeToPermission(String permission, Permissible permissible);
212
213 /**
214 * Unsubscribes the given Permissible for information about the requested Permission, by name.
215 *
216 * @param permission Permission to unsubscribe from
217 * @param permissible Permissible subscribing
218 */
219 public void unsubscribeFromPermission(String permission, Permissible permissible);
220
221 /**
222 * Gets a set containing all subscribed {@link Permissible}s to the given permission, by name
223 *
224 * @param permission Permission to query for
225 * @return Set containing all subscribed permissions
226 */
227 public Set<Permissible> getPermissionSubscriptions(String permission);
228
229 /**
230 * Subscribes to the given Default permissions by operator status
231 * <p>
232 * If the specified defaults change in any form, the Permissible will be asked to recalculate.
233 *
234 * @param op Default list to subscribe to
235 * @param permissible Permissible subscribing
236 */
237 public void subscribeToDefaultPerms(boolean op, Permissible permissible);
238
239 /**
240 * Unsubscribes from the given Default permissions by operator status
241 *
242 * @param op Default list to unsubscribe from
243 * @param permissible Permissible subscribing
244 */
245 public void unsubscribeFromDefaultPerms(boolean op, Permissible permissible);
246
247 /**
248 * Gets a set containing all subscribed {@link Permissible}s to the given default list, by op status
249 *
250 * @param op Default list to query for
251 * @return Set containing all subscribed permissions
252 */
253 public Set<Permissible> getDefaultPermSubscriptions(boolean op);
254
255 /**
256 * Gets a set of all registered permissions.
257 * <p>
258 * This set is a copy and will not be modified live.
259 *
260 * @return Set containing all current registered permissions
261 */
262 public Set<Permission> getPermissions();
263}