Search in sources :

Example 1 with PluginEnableEvent

use of org.bukkit.event.server.PluginEnableEvent in project AuthMeReloaded by AuthMe.

the class ServerListenerTest method checkEnableHandling.

private void checkEnableHandling(String pluginName, Runnable verifier) {
    PluginEnableEvent event = mockEventWithPluginName(PluginEnableEvent.class, pluginName);
    serverListener.onPluginEnable(event);
    verifier.run();
    verify(permissionsManager).onPluginEnable(pluginName);
    verifyNoMoreInteractionsAndReset();
}
Also used : PluginEnableEvent(org.bukkit.event.server.PluginEnableEvent)

Example 2 with PluginEnableEvent

use of org.bukkit.event.server.PluginEnableEvent in project Bukkit by Bukkit.

the class JavaPluginLoader method enablePlugin.

public void enablePlugin(final Plugin plugin) {
    Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
    if (!plugin.isEnabled()) {
        plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());
        JavaPlugin jPlugin = (JavaPlugin) plugin;
        String pluginName = jPlugin.getDescription().getName();
        if (!loaders.containsKey(pluginName)) {
            loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
        }
        try {
            jPlugin.setEnabled(true);
        } catch (Throwable ex) {
            server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
        }
        // Perhaps abort here, rather than continue going, but as it stands,
        // an abort is not possible the way it's currently written
        server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
}
Also used : PluginEnableEvent(org.bukkit.event.server.PluginEnableEvent)

Example 3 with PluginEnableEvent

use of org.bukkit.event.server.PluginEnableEvent 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)

Aggregations

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