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