Guarded against plugins throwing exceptions on enable and disable to prevent potential corruption issues on server start and stop

By: stevenh <steven.hartland@multiplay.co.uk>
This commit is contained in:
Bukkit/Spigot 2011-05-13 14:50:03 +01:00
parent 4af56e3d16
commit 94aac786c6

View file

@ -246,7 +246,11 @@ public final class SimplePluginManager implements PluginManager {
public void enablePlugin(final Plugin plugin) {
if (!plugin.isEnabled()) {
plugin.getPluginLoader().enablePlugin(plugin);
try {
plugin.getPluginLoader().enablePlugin(plugin);
} catch (Throwable ex) {
server.getLogger().log(Level.SEVERE, ex.getMessage() + " enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
}
}
}
@ -258,9 +262,13 @@ public final class SimplePluginManager implements PluginManager {
public void disablePlugin(final Plugin plugin) {
if (plugin.isEnabled()) {
plugin.getPluginLoader().disablePlugin(plugin);
server.getScheduler().cancelTasks(plugin);
server.getServicesManager().unregisterAll(plugin);
try {
plugin.getPluginLoader().disablePlugin(plugin);
server.getScheduler().cancelTasks(plugin);
server.getServicesManager().unregisterAll(plugin);
} catch (Throwable ex) {
server.getLogger().log(Level.SEVERE, ex.getMessage() + " disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
}
}
}