Search in sources :

Example 81 with PluginManager

use of org.bukkit.plugin.PluginManager in project Glowstone by GlowstoneMC.

the class QueryTest method testFullStats.

@Test
public void testFullStats() throws Exception {
    World world = mock(World.class);
    when(world.getName()).thenReturn("world");
    GlowPlayer p1 = mock(GlowPlayer.class);
    GlowPlayer p2 = mock(GlowPlayer.class);
    when(p1.getName()).thenReturn("barneygale");
    when(p2.getName()).thenReturn("Vivalahelvig");
    PluginManager pluginManager = mock(PluginManager.class);
    when(glowServer.getMotd()).thenReturn("A Minecraft Server");
    Mockito.doReturn(Arrays.asList(p1, p2)).when(glowServer).getOnlinePlayers();
    when(glowServer.getMaxPlayers()).thenReturn(20);
    when(glowServer.getPort()).thenReturn(25565);
    when(glowServer.getWorlds()).thenReturn(Arrays.asList(world));
    when(glowServer.getIp()).thenReturn("");
    when(glowServer.getVersion()).thenReturn("123");
    when(glowServer.getBukkitVersion()).thenReturn("xyz");
    when(glowServer.getPluginManager()).thenReturn(pluginManager);
    when(pluginManager.getPlugins()).thenReturn(new Plugin[0]);
    QueryHandler handler = new QueryHandler(server, queryPlugins);
    when(random.nextInt()).thenReturn(9513307);
    server.generateChallengeToken(address);
    testChannelRead(handler, FULL_STATS_RECV, FULL_STATS_SEND);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) QueryHandler(net.glowstone.net.query.QueryHandler) GlowPlayer(net.glowstone.entity.GlowPlayer) World(org.bukkit.World) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 82 with PluginManager

use of org.bukkit.plugin.PluginManager in project Essentials by drtshock.

the class Commandessentials method run_version.

private void run_version(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
    if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.version"))
        return;
    boolean isMismatched = false;
    boolean isVaultInstalled = false;
    final PluginManager pm = server.getPluginManager();
    final String essVer = pm.getPlugin("Essentials").getDescription().getVersion();
    sender.sendMessage("Server version: " + server.getBukkitVersion() + " " + server.getVersion());
    sender.sendMessage("EssentialsX version: " + essVer);
    for (Plugin plugin : pm.getPlugins()) {
        final PluginDescriptionFile desc = plugin.getDescription();
        String name = desc.getName();
        String version = desc.getVersion();
        if (name.startsWith("Essentials") && !name.equalsIgnoreCase("Essentials")) {
            if (!version.equalsIgnoreCase(essVer)) {
                version = "\u00a7c" + version;
                isMismatched = true;
            }
            sender.sendMessage(name.replace("Essentials", "EssentialsX") + " version: " + version);
        }
        if (versionPlugins.contains(name)) {
            sender.sendMessage(name + " version: " + version);
        }
        if (name.equals("Vault"))
            isVaultInstalled = true;
    }
    if (isMismatched) {
        sender.sendMessage(tl("versionMismatchAll"));
    }
    if (!isVaultInstalled) {
        sender.sendMessage("Vault is not installed - chat and permissions may not work.");
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) Plugin(org.bukkit.plugin.Plugin)

Example 83 with PluginManager

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

the class AuthMe method registerEventListeners.

/**
 * Registers all event listeners.
 *
 * @param injector the injector
 */
void registerEventListeners(Injector injector) {
    // Get the plugin manager instance
    PluginManager pluginManager = getServer().getPluginManager();
    // Register event listeners
    pluginManager.registerEvents(injector.getSingleton(PlayerListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(BlockListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(EntityListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(ServerListener.class), this);
    // Try to register 1.9 player listeners
    if (isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) {
        pluginManager.registerEvents(injector.getSingleton(PlayerListener19.class), this);
    }
    // Try to register 1.9 spigot player listeners
    if (isClassLoaded("org.spigotmc.event.player.PlayerSpawnLocationEvent")) {
        pluginManager.registerEvents(injector.getSingleton(PlayerListener19Spigot.class), this);
    }
    // Register listener for 1.11 events if available
    if (isClassLoaded("org.bukkit.event.entity.EntityAirChangeEvent")) {
        pluginManager.registerEvents(injector.getSingleton(PlayerListener111.class), this);
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) EntityListener(fr.xephi.authme.listener.EntityListener) PlayerListener111(fr.xephi.authme.listener.PlayerListener111) PlayerListener19(fr.xephi.authme.listener.PlayerListener19) PlayerListener19Spigot(fr.xephi.authme.listener.PlayerListener19Spigot) BlockListener(fr.xephi.authme.listener.BlockListener) PlayerListener(fr.xephi.authme.listener.PlayerListener) ServerListener(fr.xephi.authme.listener.ServerListener)

Example 84 with PluginManager

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

the class PluginHookServiceTest method shouldReturnNullForNonMvWorld.

@Test
public void shouldReturnNullForNonMvWorld() {
    // given
    World world = mock(World.class);
    MVWorldManager mvWorldManager = mock(MVWorldManager.class);
    given(mvWorldManager.isMVWorld(world)).willReturn(false);
    PluginManager pluginManager = mock(PluginManager.class);
    MultiverseCore multiverse = mock(MultiverseCore.class);
    setPluginAvailable(pluginManager, MULTIVERSE, multiverse);
    given(multiverse.getMVWorldManager()).willReturn(mvWorldManager);
    PluginHookService pluginHookService = new PluginHookService(pluginManager);
    // when
    Location spawn = pluginHookService.getMultiverseSpawn(world);
    // then
    assertThat(spawn, nullValue());
    verify(mvWorldManager).isMVWorld(world);
    verify(mvWorldManager, never()).getMVWorld(world);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) MultiverseCore(com.onarandombox.MultiverseCore.MultiverseCore) MVWorldManager(com.onarandombox.MultiverseCore.api.MVWorldManager) World(org.bukkit.World) MultiverseWorld(com.onarandombox.MultiverseCore.api.MultiverseWorld) Location(org.bukkit.Location) Test(org.junit.Test)

Example 85 with PluginManager

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

the class PluginHookServiceTest method shouldHookIntoEssentialsAtInitialization.

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

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