Search in sources :

Example 1 with PluginDisableEvent

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);
            }
        }
    }
}
Also used : PluginDisableEvent(org.bukkit.event.server.PluginDisableEvent)

Example 2 with PluginDisableEvent

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();
}
Also used : PluginEnableEvent(org.bukkit.event.server.PluginEnableEvent) PluginDisableEvent(org.bukkit.event.server.PluginDisableEvent) Test(org.junit.Test)

Example 3 with PluginDisableEvent

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();
}
Also used : PluginDisableEvent(org.bukkit.event.server.PluginDisableEvent)

Aggregations

PluginDisableEvent (org.bukkit.event.server.PluginDisableEvent)3 PluginEnableEvent (org.bukkit.event.server.PluginEnableEvent)1 Test (org.junit.Test)1