Search in sources :

Example 1 with Essentials

use of com.earth2me.essentials.Essentials in project AuthMeReloaded by AuthMe.

the class PluginHookServiceTest method shouldSetSocialSpyStatus.

@Test
public void shouldSetSocialSpyStatus() {
    // given
    Player player = mock(Player.class);
    Essentials ess = mock(Essentials.class);
    User user = mock(User.class);
    given(ess.getUser(player)).willReturn(user);
    PluginManager pluginManager = mock(PluginManager.class);
    setPluginAvailable(pluginManager, ESSENTIALS, ess);
    PluginHookService pluginHookService = new PluginHookService(pluginManager);
    // when
    pluginHookService.setEssentialsSocialSpyStatus(player, true);
    // then
    verify(ess).getUser(player);
    verify(user).setSocialSpyEnabled(true);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Player(org.bukkit.entity.Player) User(com.earth2me.essentials.User) Essentials(com.earth2me.essentials.Essentials) Test(org.junit.Test)

Example 2 with Essentials

use of com.earth2me.essentials.Essentials in project Towny by ElgarL.

the class Towny method checkPlugins.

private void checkPlugins() {
    List<String> using = new ArrayList<String>();
    Plugin test;
    if (TownySettings.isUsingPermissions()) {
        test = getServer().getPluginManager().getPlugin("GroupManager");
        if (test != null) {
            // groupManager = (GroupManager)test;
            this.getTownyUniverse().setPermissionSource(new GroupManagerSource(this, test));
            using.add(String.format("%s v%s", "GroupManager", test.getDescription().getVersion()));
        } else {
            test = getServer().getPluginManager().getPlugin("PermissionsEx");
            if (test != null) {
                // permissions = (PermissionsEX)test;
                getTownyUniverse().setPermissionSource(new PEXSource(this, test));
                using.add(String.format("%s v%s", "PermissionsEX", test.getDescription().getVersion()));
            } else {
                test = getServer().getPluginManager().getPlugin("bPermissions");
                if (test != null) {
                    // permissions = (Permissions)test;
                    getTownyUniverse().setPermissionSource(new bPermsSource(this, test));
                    using.add(String.format("%s v%s", "bPermissions", test.getDescription().getVersion()));
                } else {
                    test = getServer().getPluginManager().getPlugin("Permissions");
                    if (test != null) {
                        // permissions = (Permissions)test;
                        getTownyUniverse().setPermissionSource(new Perms3Source(this, test));
                        using.add(String.format("%s v%s", "Permissions", test.getDescription().getVersion()));
                    } else {
                        // Try Vault
                        test = getServer().getPluginManager().getPlugin("Vault");
                        if (test != null) {
                            net.milkbowl.vault.chat.Chat chat = getServer().getServicesManager().load(net.milkbowl.vault.chat.Chat.class);
                            if (chat == null) {
                                // No Chat implementation
                                test = null;
                            // Fall back to BukkitPermissions below
                            } else {
                                getTownyUniverse().setPermissionSource(new VaultPermSource(this, chat));
                                using.add(String.format("%s v%s", "Vault", test.getDescription().getVersion()));
                            }
                        }
                        if (test == null) {
                            getTownyUniverse().setPermissionSource(new BukkitPermSource(this));
                            using.add("BukkitPermissions");
                        }
                    }
                }
            }
        }
    } else {
        // Not using Permissions
        getTownyUniverse().setPermissionSource(new NullPermSource(this));
    }
    if (TownySettings.isUsingEconomy()) {
        if (TownyEconomyHandler.setupEconomy())
            using.add(TownyEconomyHandler.getVersion());
        else
            TownyMessaging.sendErrorMsg("No compatible Economy plugins found. You need iConomy 5.01, or the vault/Register.jar with any of the supported eco systems.");
    }
    test = getServer().getPluginManager().getPlugin("Essentials");
    if (test == null)
        TownySettings.setUsingEssentials(false);
    else if (TownySettings.isUsingEssentials()) {
        this.essentials = (Essentials) test;
        using.add(String.format("%s v%s", "Essentials", test.getDescription().getVersion()));
    }
    test = getServer().getPluginManager().getPlugin("Questioner");
    if (test == null)
        TownySettings.setUsingQuestioner(false);
    else if (TownySettings.isUsingQuestioner())
        using.add(String.format("%s v%s", "Questioner", test.getDescription().getVersion()));
    /*
		 * Test for Citizens2 so we can avoid removing their NPC's
		 */
    test = getServer().getPluginManager().getPlugin("Citizens");
    if (test != null) {
        citizens2 = test.getDescription().getVersion().startsWith("2");
    }
    if (using.size() > 0)
        TownyLogger.log.info("[Towny] Using: " + StringMgmt.join(using, ", "));
}
Also used : Essentials(com.earth2me.essentials.Essentials) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin)

Example 3 with Essentials

use of com.earth2me.essentials.Essentials 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)

Aggregations

Essentials (com.earth2me.essentials.Essentials)3 PluginManager (org.bukkit.plugin.PluginManager)2 Test (org.junit.Test)2 User (com.earth2me.essentials.User)1 File (java.io.File)1 Player (org.bukkit.entity.Player)1 Plugin (org.bukkit.plugin.Plugin)1 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)1