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));
}
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));
}
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));
}
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));
}
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);
}
Aggregations