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