use of org.bukkit.event.server.PluginDisableEvent in project Bukkit by Bukkit.
the class JavaPluginLoader method disablePlugin.
public void disablePlugin(Plugin plugin) {
Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
if (plugin.isEnabled()) {
String message = String.format("Disabling %s", plugin.getDescription().getFullName());
plugin.getLogger().info(message);
server.getPluginManager().callEvent(new PluginDisableEvent(plugin));
JavaPlugin jPlugin = (JavaPlugin) plugin;
ClassLoader cloader = jPlugin.getClassLoader();
try {
jPlugin.setEnabled(false);
} catch (Throwable ex) {
server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
}
loaders.remove(jPlugin.getDescription().getName());
if (cloader instanceof PluginClassLoader) {
PluginClassLoader loader = (PluginClassLoader) cloader;
Set<String> names = loader.getClasses();
for (String name : names) {
removeClass(name);
}
}
}
}
use of org.bukkit.event.server.PluginDisableEvent in project AuthMeReloaded by AuthMe.
the class ServerListenerTest method shouldHandlePluginWithNullName.
@Test
public void shouldHandlePluginWithNullName() {
PluginEnableEvent enableEvent = mock(PluginEnableEvent.class);
given(enableEvent.getPlugin()).willReturn(null);
serverListener.onPluginEnable(enableEvent);
verifyNoMoreInteractionsAndReset();
PluginDisableEvent disableEvent = mock(PluginDisableEvent.class);
given(disableEvent.getPlugin()).willReturn(null);
serverListener.onPluginDisable(disableEvent);
verifyNoMoreInteractionsAndReset();
}
use of org.bukkit.event.server.PluginDisableEvent in project AuthMeReloaded by AuthMe.
the class ServerListenerTest method checkDisableHandling.
private void checkDisableHandling(String pluginName, Runnable verifier) {
PluginDisableEvent event = mockEventWithPluginName(PluginDisableEvent.class, pluginName);
serverListener.onPluginDisable(event);
verifier.run();
verify(permissionsManager).onPluginDisable(pluginName);
verifyNoMoreInteractionsAndReset();
}
Aggregations