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