Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.plugin.java.JavaPluginLoader Class Reference
Inheritance diagram for org.bukkit.plugin.java.JavaPluginLoader:
org.bukkit.plugin.PluginLoader

Public Member Functions

 JavaPluginLoader (Server instance)
 
Plugin loadPlugin (final File file) throws InvalidPluginException
 
PluginDescriptionFile getPluginDescription (File file) throws InvalidDescriptionException
 
Pattern[] getPluginFileFilters ()
 
Map< Class<?extends Event >, Set< RegisteredListener > > createRegisteredListeners (Listener listener, final Plugin plugin)
 
void enablePlugin (final Plugin plugin)
 
void disablePlugin (Plugin plugin)
 
- Public Member Functions inherited from org.bukkit.plugin.PluginLoader
Plugin loadPlugin (File file) throws InvalidPluginException, UnknownDependencyException
 
Map< Class<?extends Event >, Set< RegisteredListener > > createRegisteredListeners (Listener listener, Plugin plugin)
 
void enablePlugin (Plugin plugin)
 

Detailed Description

Represents a Java plugin loader, allowing plugins in the form of .jar

Definition at line 47 of file JavaPluginLoader.java.

Constructor & Destructor Documentation

org.bukkit.plugin.java.JavaPluginLoader.JavaPluginLoader ( Server  instance)

This class was not meant to be constructed explicitly

Definition at line 57 of file JavaPluginLoader.java.

57  {
58  Validate.notNull(instance, "Server cannot be null");
59  server = instance;
60  }

Member Function Documentation

void org.bukkit.plugin.java.JavaPluginLoader.disablePlugin ( Plugin  plugin)

Disables the specified plugin

Attempting to disable a plugin that is not enabled will have no effect

Parameters
pluginPlugin to disable

Implements org.bukkit.plugin.PluginLoader.

Definition at line 335 of file JavaPluginLoader.java.

References org.bukkit.plugin.PluginManager.callEvent(), org.bukkit.plugin.java.JavaPlugin.getClassLoader(), org.bukkit.plugin.Plugin.getDescription(), org.bukkit.plugin.java.JavaPlugin.getDescription(), org.bukkit.plugin.PluginDescriptionFile.getFullName(), org.bukkit.plugin.Plugin.getLogger(), org.bukkit.Server.getLogger(), org.bukkit.plugin.PluginDescriptionFile.getName(), org.bukkit.Server.getPluginManager(), org.bukkit.plugin.Plugin.isEnabled(), and org.bukkit.plugin.java.JavaPlugin.setEnabled().

335  {
336  Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
337 
338  if (plugin.isEnabled()) {
339  String message = String.format("Disabling %s", plugin.getDescription().getFullName());
340  plugin.getLogger().info(message);
341 
342  server.getPluginManager().callEvent(new PluginDisableEvent(plugin));
343 
344  JavaPlugin jPlugin = (JavaPlugin) plugin;
345  ClassLoader cloader = jPlugin.getClassLoader();
346 
347  try {
348  jPlugin.setEnabled(false);
349  } catch (Throwable ex) {
350  server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
351  }
352 
353  loaders.remove(jPlugin.getDescription().getName());
354 
355  if (cloader instanceof PluginClassLoader) {
356  PluginClassLoader loader = (PluginClassLoader) cloader;
357  Set<String> names = loader.getClasses();
358 
359  for (String name : names) {
360  removeClass(name);
361  }
362  }
363  }
364  }
PluginManager getPluginManager()
Logger getLogger()
PluginDescriptionFile org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription ( File  file) throws InvalidDescriptionException

Loads a PluginDescriptionFile from the specified file

Parameters
fileFile to attempt to load from
Returns
A new PluginDescriptionFile loaded from the plugin.yml in the specified file
Exceptions
InvalidDescriptionExceptionIf the plugin description file could not be created

Implements org.bukkit.plugin.PluginLoader.

Definition at line 139 of file JavaPluginLoader.java.

139  {
140  Validate.notNull(file, "File cannot be null");
141 
142  JarFile jar = null;
143  InputStream stream = null;
144 
145  try {
146  jar = new JarFile(file);
147  JarEntry entry = jar.getJarEntry("plugin.yml");
148 
149  if (entry == null) {
150  throw new InvalidDescriptionException(new FileNotFoundException("Jar does not contain plugin.yml"));
151  }
152 
153  stream = jar.getInputStream(entry);
154 
155  return new PluginDescriptionFile(stream);
156 
157  } catch (IOException ex) {
158  throw new InvalidDescriptionException(ex);
159  } catch (YAMLException ex) {
160  throw new InvalidDescriptionException(ex);
161  } finally {
162  if (jar != null) {
163  try {
164  jar.close();
165  } catch (IOException e) {
166  }
167  }
168  if (stream != null) {
169  try {
170  stream.close();
171  } catch (IOException e) {
172  }
173  }
174  }
175  }
Pattern [] org.bukkit.plugin.java.JavaPluginLoader.getPluginFileFilters ( )

Returns a list of all filename filters expected by this PluginLoader

Returns
The filters

Implements org.bukkit.plugin.PluginLoader.

Definition at line 177 of file JavaPluginLoader.java.

177  {
178  return fileFilters.clone();
179  }

The documentation for this class was generated from the following file: