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 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 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.isMultiverseAvailable(), equalTo(false));
assertThat(pluginHookService.isCombatTagPlusAvailable(), equalTo(false));
}
use of org.bukkit.plugin.PluginManager in project AuthMeReloaded by AuthMe.
the class PluginHookServiceTest method shouldHookIntoEssentialsAtInitialization.
// Note ljacqu 20160312: Cannot test with CombatTagPlus because its class is declared final
@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));
}
use of org.bukkit.plugin.PluginManager in project TotalFreedomMod by TotalFreedom.
the class Command_plugincontrol method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length == 0 || args.length > 2) {
return false;
}
final PluginManager pm = server.getPluginManager();
if (args.length == 1) {
if (args[0].equalsIgnoreCase("list")) {
for (Plugin serverPlugin : pm.getPlugins()) {
final String version = serverPlugin.getDescription().getVersion();
msg(ChatColor.GRAY + "- " + (serverPlugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + serverPlugin.getName() + ChatColor.GOLD + (version != null && !version.isEmpty() ? " v" + version : "") + " by " + StringUtils.join(serverPlugin.getDescription().getAuthors(), ", "));
}
return true;
}
return false;
}
if ("enable".equals(args[0])) {
final Plugin target = getPlugin(args[1]);
if (target == null) {
msg("Plugin not found!");
return true;
}
if (target.isEnabled()) {
msg("Plugin is already enabled.");
return true;
}
pm.enablePlugin(target);
if (!pm.isPluginEnabled(target)) {
msg("Error enabling plugin " + target.getName());
return true;
}
msg(target.getName() + " is now enabled.");
return true;
}
if ("disable".equals(args[0])) {
final Plugin target = getPlugin(args[1]);
if (target == null) {
msg("Plugin not found!");
return true;
}
if (!target.isEnabled()) {
msg("Plugin is already disabled.");
return true;
}
if (target.getName().equals(plugin.getName())) {
msg("You cannot disable " + plugin.getName());
return true;
}
pm.disablePlugin(target);
if (pm.isPluginEnabled(target)) {
msg("Error disabling plugin " + target.getName());
return true;
}
msg(target.getName() + " is now disabled.");
return true;
}
if ("reload".equals(args[0])) {
final Plugin target = getPlugin(args[1]);
if (target == null) {
msg("Plugin not found!");
return true;
}
if (target.getName().equals(plugin.getName())) {
msg("Use /tfm reload to reload instead.");
return true;
}
pm.disablePlugin(target);
pm.enablePlugin(target);
msg(target.getName() + " reloaded.");
return true;
}
return false;
}
Aggregations