Search in sources :

Example 1 with Economy

use of net.milkbowl.vault.economy.Economy in project Towny by ElgarL.

the class TownyEconomyHandler method setupEconomy.

/**
	 * Find and configure a suitable economy provider
	 * 
	 * @return true if successful.
	 */
public static Boolean setupEconomy() {
    Plugin economyProvider = null;
    /*
		 * Test for native iCo5 support
		 */
    economyProvider = plugin.getServer().getPluginManager().getPlugin("iConomy");
    if (economyProvider != null) {
        /*
			 * Flag as using native iCo5 hooks
			 */
        if (economyProvider.getDescription().getVersion().matches("5.01")) {
            setVersion(String.format("%s v%s", "iConomy", economyProvider.getDescription().getVersion()));
            Type = EcoType.ICO5;
            return true;
        }
    }
    /*
		 * Attempt to hook Register
		 */
    economyProvider = plugin.getServer().getPluginManager().getPlugin("Register");
    if (economyProvider != null) {
        /*
			 * Flag as using Register hooks
			 */
        setVersion(String.format("%s v%s", "Register", economyProvider.getDescription().getVersion()));
        Type = EcoType.REGISTER;
        return true;
    }
    /*
		 * Attempt to find Vault for Economy handling
		 */
    try {
        RegisteredServiceProvider<Economy> vaultEcoProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
        if (vaultEcoProvider != null) {
            /*
				 * Flag as using Vault hooks
				 */
            vaultEconomy = vaultEcoProvider.getProvider();
            setVersion(String.format("%s v%s", "Vault", vaultEcoProvider.getPlugin().getDescription().getVersion()));
            Type = EcoType.VAULT;
            return true;
        }
    } catch (NoClassDefFoundError ex) {
    }
    /*
		 * No compatible Economy system found.
		 */
    return false;
}
Also used : Economy(net.milkbowl.vault.economy.Economy) Plugin(org.bukkit.plugin.Plugin)

Example 2 with Economy

use of net.milkbowl.vault.economy.Economy in project Jobs by GamingMesh.

the class HookEconomyTask method run.

public void run() {
    Plugin test = Bukkit.getServer().getPluginManager().getPlugin("Vault");
    if (test != null) {
        RegisteredServiceProvider<Economy> provider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
        if (provider != null) {
            Economy economy = provider.getProvider();
            if (economy != null && economy.isEnabled()) {
                Jobs.setEconomy(plugin, new VaultEconomy(economy));
                Jobs.getPluginLogger().info("[" + plugin.getDescription().getName() + "] Successfully linked with Vault.");
                return;
            }
        }
    }
    // no Vault found
    Jobs.setEconomy(plugin, new BlackholeEconomy());
    Bukkit.getServer().getLogger().severe("==================== " + plugin.getDescription().getName() + " ====================");
    Bukkit.getServer().getLogger().severe("Vault is required by this plugin for economy support!");
    Bukkit.getServer().getLogger().severe("Please install Vault first!");
    Bukkit.getServer().getLogger().severe("You can find the latest version here:");
    Bukkit.getServer().getLogger().severe("http://dev.bukkit.org/server-mods/vault/");
    Bukkit.getServer().getLogger().severe("==============================================");
}
Also used : BlackholeEconomy(com.gamingmesh.jobs.economy.BlackholeEconomy) Economy(net.milkbowl.vault.economy.Economy) VaultEconomy(com.gamingmesh.jobs.economy.VaultEconomy) VaultEconomy(com.gamingmesh.jobs.economy.VaultEconomy) BlackholeEconomy(com.gamingmesh.jobs.economy.BlackholeEconomy) Plugin(org.bukkit.plugin.Plugin)

Example 3 with Economy

use of net.milkbowl.vault.economy.Economy in project Denizen-For-Bukkit by DenizenScript.

the class Depends method setupEconomy.

private boolean setupEconomy() {
    Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Vault");
    if (plugin == null || !plugin.isEnabled()) {
        return false;
    }
    try {
        RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) {
            return false;
        }
        economy = rsp.getProvider();
    } catch (Exception e) {
    }
    return economy != null;
}
Also used : Economy(net.milkbowl.vault.economy.Economy) Plugin(org.bukkit.plugin.Plugin)

Example 4 with Economy

use of net.milkbowl.vault.economy.Economy in project Denizen-For-Bukkit by DenizenScript.

the class MoneyCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
    Element action = scriptEntry.getElement("action");
    Element quantity = scriptEntry.getElement("quantity");
    List<dPlayer> players = (List<dPlayer>) scriptEntry.getObject("players");
    dB.report(scriptEntry, getName(), aH.debugList("Player(s)", players) + action.debug() + quantity.debug());
    Economy eco = Depends.economy;
    double amt = quantity.asDouble();
    switch(Action.valueOf(action.asString().toUpperCase())) {
        case GIVE:
            for (dPlayer player : players) {
                eco.depositPlayer(player.getOfflinePlayer(), amt);
            }
            break;
        case TAKE:
            for (dPlayer player : players) {
                eco.withdrawPlayer(player.getOfflinePlayer(), amt);
            }
            break;
        case SET:
            for (dPlayer player : players) {
                double balance = eco.getBalance(player.getOfflinePlayer());
                if (amt > balance) {
                    eco.depositPlayer(player.getOfflinePlayer(), amt - balance);
                } else {
                    eco.withdrawPlayer(player.getOfflinePlayer(), balance - amt);
                }
            }
    }
}
Also used : Economy(net.milkbowl.vault.economy.Economy) Element(net.aufdemrand.denizencore.objects.Element) net.aufdemrand.denizen.objects.dPlayer(net.aufdemrand.denizen.objects.dPlayer) List(java.util.List) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList)

Aggregations

Economy (net.milkbowl.vault.economy.Economy)4 Plugin (org.bukkit.plugin.Plugin)3 BlackholeEconomy (com.gamingmesh.jobs.economy.BlackholeEconomy)1 VaultEconomy (com.gamingmesh.jobs.economy.VaultEconomy)1 List (java.util.List)1 net.aufdemrand.denizen.objects.dPlayer (net.aufdemrand.denizen.objects.dPlayer)1 Element (net.aufdemrand.denizencore.objects.Element)1 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)1