Search in sources :

Example 86 with PluginManager

use of org.bukkit.plugin.PluginManager in project AuthMeReloaded by AuthMe.

the class PluginHookServiceTest method shouldReturnEssentialsDataFolder.

@Test
public void shouldReturnEssentialsDataFolder() {
    // given
    Essentials ess = mock(Essentials.class);
    File essDataFolder = new File("test/data-folder");
    // Need to set the data folder with reflections because getDataFolder() is declared final
    ReflectionTestUtils.setField(JavaPlugin.class, ess, "dataFolder", essDataFolder);
    PluginManager pluginManager = mock(PluginManager.class);
    setPluginAvailable(pluginManager, ESSENTIALS, ess);
    PluginHookService pluginHookService = new PluginHookService(pluginManager);
    // when
    File dataFolder = pluginHookService.getEssentialsDataFolder();
    // then
    assertThat(dataFolder, equalTo(essDataFolder));
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Essentials(com.earth2me.essentials.Essentials) File(java.io.File) Test(org.junit.Test)

Example 87 with PluginManager

use of org.bukkit.plugin.PluginManager in project AuthMeReloaded by AuthMe.

the class PluginHookServiceTest method shouldHookIntoEssentials.

@Test
public void shouldHookIntoEssentials() {
    // given
    PluginManager pluginManager = mock(PluginManager.class);
    PluginHookService pluginHookService = new PluginHookService(pluginManager);
    setPluginAvailable(pluginManager, ESSENTIALS, Essentials.class);
    assertThat(pluginHookService.isEssentialsAvailable(), equalTo(false));
    // when
    pluginHookService.tryHookToEssentials();
    // then
    assertThat(pluginHookService.isEssentialsAvailable(), equalTo(true));
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Test(org.junit.Test)

Example 88 with PluginManager

use of org.bukkit.plugin.PluginManager in project AuthMeReloaded by AuthMe.

the class PluginHookServiceTest method shouldHookIntoCmiAtInitialization.

@Test
public void shouldHookIntoCmiAtInitialization() {
    // given
    PluginManager pluginManager = mock(PluginManager.class);
    setPluginAvailable(pluginManager, CMI, Plugin.class);
    // when
    PluginHookService pluginHookService = new PluginHookService(pluginManager);
    // then
    assertThat(pluginHookService.isCmiAvailable(), equalTo(true));
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Test(org.junit.Test)

Example 89 with PluginManager

use of org.bukkit.plugin.PluginManager in project AuthMeReloaded by AuthMe.

the class PluginHookServiceTest method shouldHandlePluginRetrievalError.

@Test
public void shouldHandlePluginRetrievalError() {
    // given
    PluginManager pluginManager = mock(PluginManager.class);
    given(pluginManager.isPluginEnabled(anyString())).willReturn(true);
    doThrow(IllegalStateException.class).when(pluginManager).getPlugin(anyString());
    // when
    PluginHookService pluginHookService = new PluginHookService(pluginManager);
    // then
    assertThat(pluginHookService.isEssentialsAvailable(), equalTo(false));
    assertThat(pluginHookService.isCmiAvailable(), equalTo(false));
    assertThat(pluginHookService.isMultiverseAvailable(), equalTo(false));
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Test(org.junit.Test)

Example 90 with PluginManager

use of org.bukkit.plugin.PluginManager in project Towny by ElgarL.

the class Towny method registerEvents.

private void registerEvents() {
    final PluginManager pluginManager = getServer().getPluginManager();
    if (!isError()) {
        // Have War Events get launched before regular events.
        pluginManager.registerEvents(townyWarBlockListener, this);
        pluginManager.registerEvents(townyWarEntityListener, this);
        // Manage player deaths and death payments
        pluginManager.registerEvents(entityMonitorListener, this);
        pluginManager.registerEvents(vehicleListener, this);
        pluginManager.registerEvents(weatherListener, this);
        pluginManager.registerEvents(townyWarCustomListener, this);
        pluginManager.registerEvents(customListener, this);
        pluginManager.registerEvents(worldListener, this);
        // Only register a physics listener if we need to.
        if (TownySettings.getRegenDelay() > 0)
            pluginManager.registerEvents(physicsListener, this);
    }
    // Always register these events.
    pluginManager.registerEvents(playerListener, this);
    pluginManager.registerEvents(blockListener, this);
    pluginManager.registerEvents(entityListener, this);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager)

Aggregations

PluginManager (org.bukkit.plugin.PluginManager)148 Plugin (org.bukkit.plugin.Plugin)33 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)20 Permission (org.bukkit.permissions.Permission)16 MetricsWrapper (com.earth2me.essentials.metrics.MetricsWrapper)14 Player (org.bukkit.entity.Player)14 Test (org.junit.Test)13 SimplePluginManager (org.bukkit.plugin.SimplePluginManager)12 Map (java.util.Map)11 File (java.io.File)9 IOException (java.io.IOException)9 World (org.bukkit.World)9 PluginCommand (org.bukkit.command.PluginCommand)9 Command (org.bukkit.command.Command)8 Listener (org.bukkit.event.Listener)8 PluginDescriptionFile (org.bukkit.plugin.PluginDescriptionFile)8 HashMap (java.util.HashMap)7 EventHandler (org.bukkit.event.EventHandler)7 ArrayList (java.util.ArrayList)6 Bukkit (org.bukkit.Bukkit)6