Finish removal of native support for abandoned economy plugins.

- All economy plugins removed as libs.
  - None of them are actively developed, many abandoned in 2011.
- Removal of Register hook.
  - Register was last updated by the Towny team, many years ago, it is
no longer used by any modern server.
  - Remove VaultEco class, unused after removal of Register
compatibilty.
This commit is contained in:
Llm Dl 2021-10-03 15:45:13 -05:00 committed by Morgan
parent 52df9d3287
commit 1996cfadc0
45 changed files with 1 additions and 6435 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

184
pom.xml
View File

@ -15,9 +15,7 @@
<version>${api.version}.3</version> <version>${api.version}.3</version>
<name>Vault</name> <name>Vault</name>
<url>https://dev.bukkit.org/projects/vault</url> <url>https://dev.bukkit.org/projects/vault</url>
<description>Vault is a Permissions &amp; Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves. <description>Vault is a Chat, Permissions &amp; Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.</description>
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, KPerms, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon, and OverPermissions</description>
@ -87,14 +85,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<artifactId>bstats-bukkit</artifactId> <artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version> <version>3.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.gmail.bleedobsidian.miconomy</groupId>
<artifactId>MiConomy</artifactId>
<version>1.0</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/MiConomy.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>de.hydrox.bukkit</groupId> <groupId>de.hydrox.bukkit</groupId>
<artifactId>DroxPerms</artifactId> <artifactId>DroxPerms</artifactId>
@ -103,14 +93,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/DroxPerms.jar</systemPath> <systemPath>${project.basedir}/lib/DroxPerms.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>me.coniin.plugins.minefaconomy</groupId>
<artifactId>MineFaConomy</artifactId>
<version>0.2</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Minefaconomy.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>net.krinsoft</groupId> <groupId>net.krinsoft</groupId>
<artifactId>Privileges</artifactId> <artifactId>Privileges</artifactId>
@ -119,38 +101,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/Privileges.jar</systemPath> <systemPath>${project.basedir}/lib/Privileges.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>is.currency</groupId>
<artifactId>Currency</artifactId>
<version>0.61</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/CurrencyCore.jar</systemPath>
</dependency>
<dependency>
<groupId>me.igwb.GoldenChest</groupId>
<artifactId>GoldenChestEconomy</artifactId>
<version>1.0.0</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/GoldenChestEconomy.jar</systemPath>
</dependency>
<dependency>
<groupId>com.flobi.GoldIsMoney2</groupId>
<artifactId>GoldIsMoney</artifactId>
<version>2.0.0</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/GoldIsMoney2.jar</systemPath>
</dependency>
<dependency>
<groupId>cosine.boseconomy.BOSEconomy</groupId>
<artifactId>BOSEconomy</artifactId>
<version>0.7.3.1a</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/BOSEconomy.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>de.bananaco.permissions.Permissions</groupId> <groupId>de.bananaco.permissions.Permissions</groupId>
<artifactId>bPermissions</artifactId> <artifactId>bPermissions</artifactId>
@ -167,22 +117,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/Xperms.jar</systemPath> <systemPath>${project.basedir}/lib/Xperms.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>ca.agnate.EconXP.EconXP</groupId>
<artifactId>EconXP</artifactId>
<version>0.4.1</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/EconXP.jar</systemPath>
</dependency>
<dependency>
<groupId>com.earth2me.essentials.Essentials</groupId>
<artifactId>Essentials</artifactId>
<version>2.9.2</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Essentials.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>org.anjocaido.groupmanager.GroupManager</groupId> <groupId>org.anjocaido.groupmanager.GroupManager</groupId>
<artifactId>GroupManager</artifactId> <artifactId>GroupManager</artifactId>
@ -191,22 +125,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/EssentialsGroupManager.jar</systemPath> <systemPath>${project.basedir}/lib/EssentialsGroupManager.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>me.ethan.eWallet.ECO</groupId>
<artifactId>eWallet</artifactId>
<version>1.0</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/eWallet.jar</systemPath>
</dependency>
<dependency>
<groupId>boardinggamer.mcmoney</groupId>
<artifactId>McMoney</artifactId>
<version>1.2</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/McMoney.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>net.TheDgtl.iChat.iChat</groupId> <groupId>net.TheDgtl.iChat.iChat</groupId>
<artifactId>iChat</artifactId> <artifactId>iChat</artifactId>
@ -215,22 +133,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/iChat.jar</systemPath> <systemPath>${project.basedir}/lib/iChat.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>com.iCo6.iConomy</groupId>
<artifactId>iConomy</artifactId>
<version>6.0.9b</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/iConomy6.jar</systemPath>
</dependency>
<dependency>
<groupId>com.gmail.mirelatrue.xpbank.XPBank</groupId>
<artifactId>XPBank</artifactId>
<version>0.9</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/XPBank.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>net.D3GN.MiracleM4n.mChat.mChat</groupId> <groupId>net.D3GN.MiracleM4n.mChat.mChat</groupId>
<artifactId>mChat</artifactId> <artifactId>mChat</artifactId>
@ -247,22 +149,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/mChatSuite.jar</systemPath> <systemPath>${project.basedir}/lib/mChatSuite.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>me.mjolnir.mineconomy.MineConomy</groupId>
<artifactId>MineConomy</artifactId>
<version>1.6</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/MineConomy.jar</systemPath>
</dependency>
<dependency>
<groupId>me.ashtheking.currency.Currency</groupId>
<artifactId>MultiCurrency</artifactId>
<version>0.1</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/MultiCurrency.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>com.nijikokun.bukkit.Permissions.Permissions</groupId> <groupId>com.nijikokun.bukkit.Permissions.Permissions</groupId>
<artifactId>Permissions</artifactId> <artifactId>Permissions</artifactId>
@ -303,34 +189,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/Starburst.jar</systemPath> <systemPath>${project.basedir}/lib/Starburst.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>com.nijikokun.register</groupId>
<artifactId>Register</artifactId>
<version>1.5</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Register.jar</systemPath>
</dependency>
<dependency>
<groupId>me.greatman.Craftconomy</groupId>
<artifactId>Craftconomy</artifactId>
<version>2.3.5</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Craftconomy.jar</systemPath>
</dependency>
<dependency>
<groupId>com.greatmancode</groupId>
<artifactId>craftconomy3</artifactId>
<version>3.2.2-SNAPSHOT</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>net.crystalyx.bukkit.simplyperms</groupId> <groupId>net.crystalyx.bukkit.simplyperms</groupId>
<artifactId>SimplyPerms</artifactId> <artifactId>SimplyPerms</artifactId>
@ -339,22 +197,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/SimplyPerms.jar</systemPath> <systemPath>${project.basedir}/lib/SimplyPerms.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>Gringotts</groupId>
<artifactId>Gringotts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Gringotts.jar</systemPath>
</dependency>
<dependency>
<groupId>com.gravypod.Dosh</groupId>
<artifactId>Dosh</artifactId>
<version>1.0</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Dosh.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>com.github.zathrus_writer.commandsex</groupId> <groupId>com.github.zathrus_writer.commandsex</groupId>
<artifactId>CommandsEX</artifactId> <artifactId>CommandsEX</artifactId>
@ -363,14 +205,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/CommandsEX.jar</systemPath> <systemPath>${project.basedir}/lib/CommandsEX.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>com.github.omwah</groupId>
<artifactId>SDFEconomy</artifactId>
<version>0.2.2</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/SDFEconomy-0.2.2.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>net.ae97</groupId> <groupId>net.ae97</groupId>
<artifactId>TotalPermissions</artifactId> <artifactId>TotalPermissions</artifactId>
@ -387,14 +221,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/rscPermissions.jar</systemPath> <systemPath>${project.basedir}/lib/rscPermissions.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>net.teamalpha.taecon</groupId>
<artifactId>TAEcon</artifactId>
<version>0.1</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/TAEcon.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>KPerms</groupId> <groupId>KPerms</groupId>
<artifactId>KPerms</artifactId> <artifactId>KPerms</artifactId>
@ -403,14 +229,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/KPerms.jar</systemPath> <systemPath>${project.basedir}/lib/KPerms.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>co.uk.silvania.cities.digicoin</groupId>
<artifactId>DigiCoin</artifactId>
<version>0.1</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/lib/DigiCoin.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>com.overmc</groupId> <groupId>com.overmc</groupId>
<artifactId>overpermissions</artifactId> <artifactId>overpermissions</artifactId>

View File

@ -17,8 +17,6 @@ package net.milkbowl.vault;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.Collection; import java.util.Collection;
@ -39,26 +37,6 @@ import net.milkbowl.vault.chat.plugins.Chat_mChat;
import net.milkbowl.vault.chat.plugins.Chat_mChatSuite; import net.milkbowl.vault.chat.plugins.Chat_mChatSuite;
import net.milkbowl.vault.chat.plugins.Chat_rscPermissions; import net.milkbowl.vault.chat.plugins.Chat_rscPermissions;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.plugins.Economy_BOSE7;
import net.milkbowl.vault.economy.plugins.Economy_CommandsEX;
import net.milkbowl.vault.economy.plugins.Economy_Craftconomy3;
import net.milkbowl.vault.economy.plugins.Economy_CurrencyCore;
import net.milkbowl.vault.economy.plugins.Economy_DigiCoin;
import net.milkbowl.vault.economy.plugins.Economy_Dosh;
import net.milkbowl.vault.economy.plugins.Economy_EconXP;
import net.milkbowl.vault.economy.plugins.Economy_Essentials;
import net.milkbowl.vault.economy.plugins.Economy_GoldIsMoney2;
import net.milkbowl.vault.economy.plugins.Economy_GoldenChestEconomy;
import net.milkbowl.vault.economy.plugins.Economy_Gringotts;
import net.milkbowl.vault.economy.plugins.Economy_McMoney;
import net.milkbowl.vault.economy.plugins.Economy_MineConomy;
import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency;
import net.milkbowl.vault.economy.plugins.Economy_TAEcon;
import net.milkbowl.vault.economy.plugins.Economy_XPBank;
import net.milkbowl.vault.economy.plugins.Economy_eWallet;
import net.milkbowl.vault.economy.plugins.Economy_iConomy6;
import net.milkbowl.vault.economy.plugins.Economy_SDFEconomy;
import net.milkbowl.vault.economy.plugins.Economy_Minefaconomy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import net.milkbowl.vault.permission.plugins.Permission_DroxPerms; import net.milkbowl.vault.permission.plugins.Permission_DroxPerms;
import net.milkbowl.vault.permission.plugins.Permission_GroupManager; import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
@ -88,7 +66,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
@ -99,10 +76,7 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
import com.nijikokun.register.payment.Methods;
import net.milkbowl.vault.chat.plugins.Chat_TotalPermissions; import net.milkbowl.vault.chat.plugins.Chat_TotalPermissions;
import net.milkbowl.vault.economy.plugins.Economy_MiConomy;
public class Vault extends JavaPlugin { public class Vault extends JavaPlugin {
@ -135,7 +109,6 @@ public class Vault extends JavaPlugin {
getConfig().options().copyDefaults(true); getConfig().options().copyDefaults(true);
saveConfig(); saveConfig();
// Load Vault Addons // Load Vault Addons
loadEconomy();
loadPermission(); loadPermission();
loadChat(); loadChat();
@ -233,74 +206,6 @@ public class Vault extends JavaPlugin {
hookChat("TotalPermissions", Chat_TotalPermissions.class, ServicePriority.Normal, "net.ar97.totalpermissions.TotalPermissions"); hookChat("TotalPermissions", Chat_TotalPermissions.class, ServicePriority.Normal, "net.ar97.totalpermissions.TotalPermissions");
} }
/**
* Attempts to load Economy Addons
*/
private void loadEconomy() {
// Try to load MiConomy
hookEconomy("MiConomy", Economy_MiConomy.class, ServicePriority.Normal, "com.gmail.bleedobsidian.miconomy.Main");
// Try to load MiFaConomy
hookEconomy("MineFaConomy", Economy_Minefaconomy.class, ServicePriority.Normal, "me.coniin.plugins.minefaconomy.Minefaconomy");
// Try to load MultiCurrency
hookEconomy("MultiCurrency", Economy_MultiCurrency.class, ServicePriority.Normal, "me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList");
// Try to load MineConomy
hookEconomy("MineConomy", Economy_MineConomy.class, ServicePriority.Normal, "me.mjolnir.mineconomy.MineConomy");
// Try to load McMoney
hookEconomy("McMoney", Economy_McMoney.class, ServicePriority.Normal, "boardinggamer.mcmoney.McMoneyAPI");
// Try to load Craftconomy3
hookEconomy("CraftConomy3", Economy_Craftconomy3.class, ServicePriority.Normal, "com.greatmancode.craftconomy3.tools.interfaces.BukkitLoader");
// Try to load eWallet
hookEconomy("eWallet", Economy_eWallet.class, ServicePriority.Normal, "me.ethan.eWallet.ECO");
// Try to load BOSEconomy 7
hookEconomy("BOSEconomy7", Economy_BOSE7.class, ServicePriority.Normal, "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandHandler");
// Try to load CurrencyCore
hookEconomy("CurrencyCore", Economy_CurrencyCore.class, ServicePriority.Normal, "is.currency.Currency");
// Try to load Gringotts
hookEconomy("Gringotts", Economy_Gringotts.class, ServicePriority.Normal, "org.gestern.gringotts.Gringotts");
// Try to load Essentials Economy
hookEconomy("Essentials Economy", Economy_Essentials.class, ServicePriority.Low, "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException");
// Try to load iConomy 6
hookEconomy("iConomy 6", Economy_iConomy6.class, ServicePriority.High, "com.iCo6.iConomy");
// Try to load EconXP
hookEconomy("EconXP", Economy_EconXP.class, ServicePriority.Normal, "ca.agnate.EconXP.EconXP");
// Try to load GoldIsMoney2
hookEconomy("GoldIsMoney2", Economy_GoldIsMoney2.class, ServicePriority.Normal, "com.flobi.GoldIsMoney2.GoldIsMoney");
// Try to load GoldenChestEconomy
hookEconomy("GoldenChestEconomy", Economy_GoldenChestEconomy.class, ServicePriority.Normal, "me.igwb.GoldenChest.GoldenChestEconomy");
// Try to load Dosh
hookEconomy("Dosh", Economy_Dosh.class, ServicePriority.Normal, "com.gravypod.Dosh.Dosh");
// Try to load CommandsEX Economy
hookEconomy("CommandsEX", Economy_CommandsEX.class, ServicePriority.Normal, "com.github.zathrus_writer.commandsex.api.EconomyAPI");
// Try to load SDFEconomy Economy
hookEconomy("SDFEconomy", Economy_SDFEconomy.class, ServicePriority.Normal, "com.github.omwah.SDFEconomy.SDFEconomy");
// Try to load XPBank
hookEconomy("XPBank", Economy_XPBank.class, ServicePriority.Normal, "com.gmail.mirelatrue.xpbank.XPBank");
// Try to load TAEcon
hookEconomy("TAEcon", Economy_TAEcon.class, ServicePriority.Normal, "net.teamalpha.taecon.TAEcon");
// Try to load DigiCoin
hookEconomy("DigiCoin", Economy_DigiCoin.class, ServicePriority.Normal, "co.uk.silvania.cities.digicoin.DigiCoin");
}
/** /**
* Attempts to load Permission Addons * Attempts to load Permission Addons
*/ */
@ -369,18 +274,6 @@ public class Vault extends JavaPlugin {
} }
} }
private void hookEconomy (String name, Class<? extends Economy> hookClass, ServicePriority priority, String...packages) {
try {
if (packagesExists(packages)) {
Economy econ = hookClass.getConstructor(Plugin.class).newInstance(this);
sm.register(Economy.class, econ, this, priority);
log.info(String.format("[Economy] %s found: %s", name, econ.isEnabled() ? "Loaded" : "Waiting"));
}
} catch (Exception e) {
log.severe(String.format("[Economy] There was an error hooking %s - check to make sure you're using a compatible version!", name));
}
}
private void hookPermission (String name, Class<? extends Permission> hookClass, ServicePriority priority, String...packages) { private void hookPermission (String name, Class<? extends Permission> hookClass, ServicePriority priority, String...packages) {
try { try {
if (packagesExists(packages)) { if (packagesExists(packages)) {
@ -627,32 +520,5 @@ public class Vault extends JavaPlugin {
} }
} }
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (event.getPlugin().getDescription().getName().equals("Register") && packagesExists("com.nijikokun.register.payment.Methods")) {
if (!Methods.hasMethod()) {
try {
Method m = Methods.class.getMethod("addMethod", Methods.class);
m.setAccessible(true);
m.invoke(null, "Vault", new net.milkbowl.vault.VaultEco());
if (!Methods.setPreferred("Vault")) {
log.info("Unable to hook register");
} else {
log.info("[Vault] - Successfully injected Vault methods into Register.");
}
} catch (SecurityException e) {
log.info("Unable to hook register");
} catch (NoSuchMethodException e) {
log.info("Unable to hook register");
} catch (IllegalArgumentException e) {
log.info("Unable to hook register");
} catch (IllegalAccessException e) {
log.info("Unable to hook register");
} catch (InvocationTargetException e) {
log.info("Unable to hook register");
}
}
}
}
} }
} }

View File

@ -1,243 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import com.nijikokun.register.payment.Method;
@SuppressWarnings("deprecation")
public class VaultEco implements Method {
private Vault vault;
private Economy economy;
public Vault getPlugin() {
return this.vault;
}
@Override
public boolean createAccount(String name, Double amount) {
if(!this.economy.createBank(name, "").transactionSuccess()) {
return false;
}
return this.economy.bankDeposit(name, amount).transactionSuccess();
}
public String getName() {
return this.vault.getDescription().getName();
}
public String getVersion() {
return this.vault.getDescription().getVersion();
}
public int fractionalDigits() {
return this.economy.fractionalDigits();
}
public String format(double amount) {
return this.economy.format(amount);
}
public boolean hasBanks() {
return this.economy.hasBankSupport();
}
public boolean hasBank(String bank) {
return this.economy.getBanks().contains(bank);
}
public boolean hasAccount(String name) {
return this.economy.hasAccount(name);
}
public boolean hasBankAccount(String bank, String name) {
return this.economy.isBankOwner(bank, name).transactionSuccess() || this.economy.isBankMember(bank, name).transactionSuccess();
}
public boolean createAccount(String name) {
return this.economy.createPlayerAccount(name);
}
public MethodAccount getAccount(String name) {
if(!hasAccount(name)) {
return null;
}
return new VaultAccount(name, this.economy);
}
public MethodBankAccount getBankAccount(String bank, String name) {
if(!hasBankAccount(bank, name)) {
return null;
}
return new VaultBankAccount(bank, economy);
}
public boolean isCompatible(Plugin plugin) {
return plugin instanceof Vault;
}
public void setPlugin(Plugin plugin) {
this.vault = (Vault) plugin;
RegisteredServiceProvider<Economy> economyProvider = this.vault.getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider != null) {
this.economy = economyProvider.getProvider();
}
}
public class VaultAccount implements MethodAccount {
private final String name;
private final Economy economy;
public VaultAccount(String name, Economy economy) {
this.name = name;
this.economy = economy;
}
public double balance() {
return this.economy.getBalance(this.name);
}
public boolean set(double amount) {
if(!this.economy.withdrawPlayer(this.name, this.balance()).transactionSuccess()) {
return false;
}
if(amount == 0) {
return true;
}
return this.economy.depositPlayer(this.name, amount).transactionSuccess();
}
public boolean add(double amount) {
return this.economy.depositPlayer(this.name, amount).transactionSuccess();
}
public boolean subtract(double amount) {
return this.economy.withdrawPlayer(this.name, amount).transactionSuccess();
}
public boolean multiply(double amount) {
double balance = this.balance();
return this.set(balance * amount);
}
public boolean divide(double amount) {
double balance = this.balance();
return this.set(balance / amount);
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public boolean isNegative() {
return (this.balance() < 0);
}
public boolean remove() {
return this.set(0.0);
}
}
public class VaultBankAccount implements MethodBankAccount {
private final String bank;
private final Economy economy;
public VaultBankAccount(String bank, Economy economy) {
this.bank = bank;
this.economy = economy;
}
public String getBankName() {
return this.bank;
}
public int getBankId() {
return -1;
}
public double balance() {
return this.economy.bankBalance(this.bank).balance;
}
public boolean set(double amount) {
if(!this.economy.bankWithdraw(this.bank, this.balance()).transactionSuccess()) {
return false;
}
if(amount == 0) {
return true;
}
return this.economy.bankDeposit(this.bank, amount).transactionSuccess();
}
public boolean add(double amount) {
return this.economy.bankDeposit(this.bank, amount).transactionSuccess();
}
public boolean subtract(double amount) {
return this.economy.bankWithdraw(this.bank, amount).transactionSuccess();
}
public boolean multiply(double amount) {
double balance = this.balance();
return this.set(balance * amount);
}
public boolean divide(double amount) {
double balance = this.balance();
return this.set(balance / amount);
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public boolean isNegative() {
return (this.balance() < 0);
}
public boolean remove() {
return this.set(0.0);
}
}
}

View File

@ -1,305 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import cosine.boseconomy.BOSEconomy;
public class Economy_BOSE7 extends AbstractEconomy {
private final Logger log;
private final String name = "BOSEconomy";
private Plugin plugin = null;
private BOSEconomy economy = null;
public Economy_BOSE7(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin bose = plugin.getServer().getPluginManager().getPlugin("BOSEconomy");
if (bose != null && bose.isEnabled() && bose.getDescription().getVersion().startsWith("0.7")) {
economy = (BOSEconomy) bose;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public double getBalance(String playerName) {
final double balance;
balance = economy.getPlayerMoneyDouble(playerName);
final double fBalance = balance;
return fBalance;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Cannot withdraw negative funds");
}
if (!has(playerName, amount)) {
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Insufficient funds");
}
double balance = economy.getPlayerMoneyDouble(playerName);
if (economy.setPlayerMoney(playerName, balance - amount, false)) {
balance = economy.getPlayerMoneyDouble(playerName);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Error withdrawing funds");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Cannot deposit negative funds");
}
double balance = economy.getPlayerMoneyDouble(playerName);
if (economy.setPlayerMoney(playerName, balance + amount, false)) {
balance = economy.getPlayerMoneyDouble(playerName);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Error depositing funds");
}
}
@Override
public String currencyNamePlural() {
return economy.getMoneyNamePlural();
}
@Override
public String currencyNameSingular() {
return economy.getMoneyName();
}
public class EconomyServerListener implements Listener {
Economy_BOSE7 economy = null;
public EconomyServerListener(Economy_BOSE7 economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin bose = event.getPlugin();
if (bose.getDescription().getName().equals("BOSEconomy") && bose.getDescription().getVersion().startsWith("0.7")) {
economy.economy = (BOSEconomy) bose;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("BOSEconomy") && event.getPlugin().getDescription().getVersion().startsWith("0.7")) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public String format(double amount) {
return economy.getMoneyFormatted(amount);
}
@Override
public EconomyResponse createBank(String name, String player) {
boolean success = economy.addBankOwner(name, player, false);
if (success) {
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
}
@Override
public EconomyResponse deleteBank(String name) {
boolean success = economy.removeBank(name);
if (success) {
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to remove that bank account.");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (!economy.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
double bankMoney = economy.getBankMoneyDouble(name);
if (bankMoney < amount) {
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
} else {
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
EconomyResponse er = bankHas(name, amount);
if (!er.transactionSuccess()) {
return er;
} else {
economy.addBankMoney(name, -amount, true);
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!");
else {
economy.addBankMoney(name, amount, true);
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankOwner(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank owner!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
if (!economy.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
} else if (economy.isBankMember(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!");
}
}
@Override
public EconomyResponse bankBalance(String name) {
if (!economy.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
double bankMoney = economy.getBankMoneyDouble(name);
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
}
@Override
public List<String> getBanks() {
return economy.getBankList();
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean hasBankSupport() {
return true;
}
@Override
public boolean hasAccount(String playerName) {
return economy.playerRegistered(playerName, false);
}
@Override
public boolean createPlayerAccount(String playerName) {
if (economy.playerRegistered(playerName, false)) {
return false;
}
return economy.registerPlayer(playerName);
}
@Override
public int fractionalDigits() {
return economy.getFractionalDigits();
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,234 +0,0 @@
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import com.github.zathrus_writer.commandsex.CommandsEX;
import com.github.zathrus_writer.commandsex.api.economy.Economy;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
public class Economy_CommandsEX extends AbstractEconomy {
private final Logger log;
private final String name = "CommandsEX Economy";
private Plugin plugin = null;
private CommandsEX economy = null;
public Economy_CommandsEX(Plugin plugin){
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
if (economy == null) {
Plugin commandsex = plugin.getServer().getPluginManager().getPlugin("CommandsEX");
if (commandsex != null && commandsex.isEnabled()) {
economy = (CommandsEX) commandsex;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_CommandsEX economy = null;
public EconomyServerListener(Economy_CommandsEX economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin cex = event.getPlugin();
if (cex.getDescription().getName().equals("CommandsEX")) {
economy.economy = (CommandsEX) cex;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("CommandsEX")) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
if (economy == null){
return false;
} else {
return Economy.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public int fractionalDigits() {
return 2;
}
@Override
public String format(double amount) {
return Economy.getCurrencySymbol() + amount;
}
@Override
public String currencyNamePlural() {
return Economy.getCurrencyPlural();
}
@Override
public String currencyNameSingular() {
return Economy.getCurrencySingular();
}
@Override
public boolean hasAccount(String playerName) {
return Economy.hasAccount(playerName);
}
@Override
public double getBalance(String playerName) {
return Economy.getBalance(playerName);
}
@Override
public boolean has(String playerName, double amount) {
return Economy.has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
ResponseType rt;
String message;
if (Economy.has(playerName, amount)){
Economy.withdraw(playerName, amount);
rt = ResponseType.SUCCESS;
message = null;
} else {
rt = ResponseType.FAILURE;
message = "Not enough money";
}
return new EconomyResponse(amount, Economy.getBalance(playerName), rt, message);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
Economy.deposit(playerName, amount);
return new EconomyResponse(amount, Economy.getBalance(playerName), ResponseType.SUCCESS, "Successfully deposited");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean createPlayerAccount(String playerName) {
if (Economy.hasAccount(playerName)){
return false;
} else {
Economy.createAccount(playerName);
return true;
}
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,319 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import com.greatmancode.craftconomy3.Cause;
import com.greatmancode.craftconomy3.Common;
import com.greatmancode.craftconomy3.account.Account;
import com.greatmancode.craftconomy3.groups.WorldGroupsManager;
import com.greatmancode.craftconomy3.tools.interfaces.BukkitLoader;
public class Economy_Craftconomy3 extends AbstractEconomy {
private final Logger log;
private final String name = "Craftconomy3";
private Plugin plugin = null;
protected BukkitLoader economy = null;
public Economy_Craftconomy3(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin ec = plugin.getServer().getPluginManager().getPlugin("Craftconomy3");
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.greatmancode.craftconomy3.BukkitLoader")) {
economy = (BukkitLoader) ec;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_Craftconomy3 economy = null;
public EconomyServerListener(Economy_Craftconomy3 economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin ec = event.getPlugin();
if (ec.getDescription().getName().equals("Craftconomy3") && ec.getClass().getName().equals("com.greatmancode.craftconomy3.tools.interfaces.BukkitLoader")) {
economy.economy = (BukkitLoader) ec;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("Craftconomy3")) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
return Common.getInstance().format(null, Common.getInstance().getCurrencyManager().getDefaultCurrency(), amount);
}
@Override
public String currencyNameSingular() {
return Common.getInstance().getCurrencyManager().getDefaultCurrency().getName();
}
@Override
public String currencyNamePlural() {
return Common.getInstance().getCurrencyManager().getDefaultCurrency().getPlural();
}
@Override
public double getBalance(String playerName) {
return getBalance(playerName, WorldGroupsManager.DEFAULT_GROUP_NAME);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
return withdrawPlayer(playerName, WorldGroupsManager.DEFAULT_GROUP_NAME, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
return depositPlayer(playerName, WorldGroupsManager.DEFAULT_GROUP_NAME, amount);
}
@Override
public boolean has(String playerName, double amount) {
return has(playerName, WorldGroupsManager.DEFAULT_GROUP_NAME, amount);
}
@Override
public EconomyResponse createBank(String name, String player) {
boolean success = false;
if (!Common.getInstance().getAccountManager().exist(name, true)) {
Common.getInstance().getAccountManager().getAccount(name,true).getAccountACL().set(player, true, true, true, true, true);
success = true;
}
if (success) {
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account. It already exists!");
}
@Override
public EconomyResponse deleteBank(String name) {
boolean success = Common.getInstance().getAccountManager().delete(name, true);
if (success) {
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to delete that bank account.");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (Common.getInstance().getAccountManager().exist(name, true)) {
Account account = Common.getInstance().getAccountManager().getAccount(name, true);
if (account.hasEnough(amount, Common.getInstance().getServerCaller().getDefaultWorld(), Common.getInstance().getCurrencyManager().getDefaultCurrency().getName())) {
return new EconomyResponse(0, bankBalance(name).balance, ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, bankBalance(name).balance, ResponseType.FAILURE, "The bank does not have enough money!");
}
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
EconomyResponse er = bankHas(name, amount);
if (!er.transactionSuccess()) {
return er;
} else {
if (Common.getInstance().getAccountManager().exist(name, true)) {
return new EconomyResponse(0, Common.getInstance().getAccountManager().getAccount(name, true).withdraw(amount,WorldGroupsManager.DEFAULT_GROUP_NAME, Common.getInstance().getCurrencyManager().getDefaultBankCurrency().getName(), Cause.VAULT, null), ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
}
if (Common.getInstance().getAccountManager().exist(name, true)) {
return new EconomyResponse(0, Common.getInstance().getAccountManager().getAccount(name, true).deposit(amount,WorldGroupsManager.DEFAULT_GROUP_NAME, Common.getInstance().getCurrencyManager().getDefaultBankCurrency().getName(), Cause.VAULT, null), ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
if (Common.getInstance().getAccountManager().exist(name, true)) {
if (Common.getInstance().getAccountManager().getAccount(name, true).getAccountACL().isOwner(playerName)) {
return new EconomyResponse(0, bankBalance(name).balance, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not the owner of the bank!");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
// Basicly here if the user have access to deposit & withdraw he's a member
EconomyResponse er = isBankOwner(name, playerName);
if (er.transactionSuccess()) {
return er;
} else {
if (Common.getInstance().getAccountManager().exist(name, true)) {
Account account = Common.getInstance().getAccountManager().getAccount(name, true);
if (account.getAccountACL().canDeposit(playerName) && account.getAccountACL().canWithdraw(playerName)) {
return new EconomyResponse(0, bankBalance(name).balance, ResponseType.SUCCESS, "");
}
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not a member of the bank!");
}
}
@Override
public EconomyResponse bankBalance(String name) {
if (Common.getInstance().getAccountManager().exist(name, true)) {
return new EconomyResponse(0, Common.getInstance().getAccountManager().getAccount(name, true).getBalance(WorldGroupsManager.DEFAULT_GROUP_NAME, Common.getInstance().getCurrencyManager().getDefaultBankCurrency().getName()), ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
@Override
public List<String> getBanks() {
return Common.getInstance().getAccountManager().getAllAccounts(true);
}
@Override
public boolean hasBankSupport() {
return true;
}
@Override
public boolean hasAccount(String playerName) {
return Common.getInstance().getAccountManager().exist(playerName, false);
}
@Override
public boolean createPlayerAccount(String playerName) {
if (Common.getInstance().getAccountManager().exist(playerName, false)) {
return false;
}
Common.getInstance().getAccountManager().getAccount(playerName, false);
return true;
}
@Override
public int fractionalDigits() {
return -1;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return Common.getInstance().getAccountManager().getAccount(playerName, false).getBalance(world, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName());
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return Common.getInstance().getAccountManager().getAccount(playerName, false).hasEnough(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName());
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Cannot withdraw negative funds");
}
double balance;
Account account = Common.getInstance().getAccountManager().getAccount(playerName, false);
if (account.hasEnough(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName())) {
balance = account.withdraw(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName(), Cause.VAULT, null);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Cannot desposit negative funds");
}
Account account = Common.getInstance().getAccountManager().getAccount(playerName, false);
double balance = account.deposit(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName(), Cause.VAULT, null);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,305 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import is.currency.Currency;
import is.currency.syst.AccountContext;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
public class Economy_CurrencyCore extends AbstractEconomy {
private Currency currency;
private final Logger log;
private final Plugin plugin;
private final String name = "CurrencyCore";
public Economy_CurrencyCore(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if(currency == null) {
Plugin currencyPlugin = plugin.getServer().getPluginManager().getPlugin("CurrencyCore");
if(currencyPlugin != null && currencyPlugin.getClass().getName().equals("is.currency.Currency")) {
this.currency = (Currency) currencyPlugin;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
private Economy_CurrencyCore economy = null;
public EconomyServerListener(Economy_CurrencyCore economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if(this.economy.currency == null) {
Plugin currencyPlugin = event.getPlugin();
if(currencyPlugin.getDescription().getName().equals("CurrencyCore") && currencyPlugin.getClass().getName().equals("is.currency.Currency")) {
this.economy.currency = (Currency) currencyPlugin;
log.info(String.format("[Economy] %s hooked.", this.economy.getName()));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (this.economy.currency != null) {
if (event.getPlugin().getDescription().getName().equals("CurrencyCore")) {
this.economy.currency = null;
log.info(String.format("[Economy] %s unhooked.", this.economy.getName()));
}
}
}
}
@Override
public boolean isEnabled() {
return currency != null;
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
return this.currency.getFormatHelper().format(amount);
}
@Override
public String currencyNamePlural() {
return currency.getCurrencyConfig().getCurrencyMajor().get(1);
}
@Override
public String currencyNameSingular() {
return currency.getCurrencyConfig().getCurrencyMajor().get(0);
}
@Override
public double getBalance(String playerName) {
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
if (account == null) {
return 0.0;
}
return account.getBalance();
}
@Override
public boolean has(String playerName, double amount) {
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
if (account == null) {
return false;
} else {
return account.hasBalance(amount);
}
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
if (account == null) {
return new EconomyResponse(0.0, 0.0, ResponseType.FAILURE, "That account does not exist");
} else if (!account.hasBalance(amount)) {
return new EconomyResponse(0.0, account.getBalance(), ResponseType.FAILURE, "Insufficient funds");
} else {
account.subtractBalance(amount);
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
}
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
if (account == null) {
return new EconomyResponse(0.0, 0.0, ResponseType.FAILURE, "That account does not exist");
}
account.addBalance(amount);
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse createBank(String name, String player) {
if (this.currency.getAccountManager().hasAccount(name)) {
return new EconomyResponse(0, currency.getAccountManager().getAccount(name).getBalance(), ResponseType.FAILURE, "That account already exists.");
}
this.currency.getAccountManager().createAccount(name);
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse deleteBank(String name) {
if (this.currency.getAccountManager().hasAccount(name)) {
this.currency.getAccountManager().deleteAccount(name);
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
}
@Override
public EconomyResponse bankBalance(String name) {
AccountContext account = this.currency.getAccountManager().getAccount(name);
if (account == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exists.");
}
return new EconomyResponse(0, account.getBalance(), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
AccountContext account = this.currency.getAccountManager().getAccount(name);
if (account == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
} else if (!account.hasBalance(amount)) {
return new EconomyResponse(0, account.getBalance(), ResponseType.FAILURE, "That account does not have enough!");
} else {
return new EconomyResponse(0, account.getBalance(), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
AccountContext account = this.currency.getAccountManager().getAccount(name);
if (account == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
} else if (!account.hasBalance(amount)) {
return new EconomyResponse(0, account.getBalance(), ResponseType.FAILURE, "That account does not have enough!");
} else {
account.subtractBalance(amount);
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
}
AccountContext account = this.currency.getAccountManager().getAccount(name);
if (account == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
} else {
account.addBalance(amount);
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Currency does not support Bank members.");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Currency does not support Bank members.");
}
@Override
public List<String> getBanks() {
return this.currency.getAccountManager().getAccountList();
}
@Override
public boolean hasBankSupport() {
return true;
}
@Override
public boolean hasAccount(String playerName) {
return this.currency.getAccountManager().getAccount(playerName) != null;
}
@Override
public boolean createPlayerAccount(String playerName) {
if (this.currency.getAccountManager().getAccount(playerName) != null) {
return false;
}
this.currency.getAccountManager().createAccount(playerName);
return true;
}
@Override
public int fractionalDigits() {
return -1;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,251 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import co.uk.silvania.cities.digicoin.DigiCoin;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
public class Economy_DigiCoin extends AbstractEconomy {
private final Logger log;
private final String name = "DigiCoin";
private Plugin plugin = null;
private DigiCoin economy = null;
public Economy_DigiCoin(Plugin plugin){
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
if (economy == null) {
Plugin digicoin = plugin.getServer().getPluginManager().getPlugin(name);
if (digicoin != null && digicoin.isEnabled()) {
economy = (DigiCoin) digicoin;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_DigiCoin economy = null;
public EconomyServerListener(Economy_DigiCoin economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin digicoin = event.getPlugin();
if (digicoin.getDescription().getName().equals(economy.name)) {
economy.economy = (DigiCoin) digicoin;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals(economy.name)) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
return economy != null;
}
@Override
public String getName() {
return name;
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public int fractionalDigits() {
return -1;
}
@Override
public String format(double amount) {
if (amount == 1.0) {
return String.format("%d %s", amount, currencyNameSingular());
} else {
return String.format("%d %s", amount, currencyNamePlural());
}
}
@Override
public String currencyNamePlural() {
return "coins";
}
@Override
public String currencyNameSingular() {
return "coin";
}
@Override
public boolean hasAccount(String playerName) {
return true;
}
@Override
public double getBalance(String playerName) {
return economy.getBalance(playerName);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
ResponseType rt;
String message;
if (economy.removeBalance(playerName, amount)) {
rt = ResponseType.SUCCESS;
message = null;
} else {
rt = ResponseType.FAILURE;
message = "Not enough money.";
}
return new EconomyResponse(amount, getBalance(playerName), rt, message);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
ResponseType rt;
String message;
if (economy.addBalance(playerName, amount)) {
rt = ResponseType.SUCCESS;
message = null;
} else {
rt = ResponseType.FAILURE;
message = "Failed to deposit balance.";
}
return new EconomyResponse(amount, getBalance(playerName), rt, message);
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean createPlayerAccount(String playerName) {
return false;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return true;
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return false;
}
}

View File

@ -1,195 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import org.bukkit.plugin.Plugin;
import com.gravypod.Dosh.Dosh;
import com.gravypod.Dosh.MoneyUtils;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
public class Economy_Dosh extends AbstractEconomy {
Plugin plugin;
Dosh doshPlugin;
DoshAPIHandler apiHandle;
public Economy_Dosh(Plugin _plugin) {
plugin = _plugin;
if (plugin.getServer().getPluginManager().isPluginEnabled("Dosh")) {
doshPlugin = (Dosh) plugin.getServer().getPluginManager().getPlugin("Dosh");
apiHandle = new DoshAPIHandler();
} else {
return;
}
}
@Override
public boolean isEnabled() {
return apiHandle != null;
}
@Override
public String getName() {
return "Dosh";
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public int fractionalDigits() {
return 0;
}
@Override
public String format(double amount) {
return null;
}
@Override
public String currencyNamePlural() {
return Dosh.getSettings().moneyName + "s";
}
@Override
public String currencyNameSingular() {
return Dosh.getSettings().moneyName;
}
@Override
public boolean hasAccount(String playerName) {
return true;
}
@Override
public double getBalance(String playerName) {
return DoshAPIHandler.getUserBal(playerName);
}
@Override
public boolean has(String playerName, double amount) {
return (getBalance(playerName) - amount) > 0;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (DoshAPIHandler.subtractMoney(playerName, amount)) {
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.SUCCESS, "Worked!");
}
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.FAILURE, "Didnt work!");
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
DoshAPIHandler.addUserBal(playerName, amount);
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.SUCCESS, "It worked!");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return null;
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return null;
}
@Override
public List<String> getBanks() {
return null;
}
@Override
public boolean createPlayerAccount(String playerName) {
return false;
}
public class DoshAPIHandler extends MoneyUtils {}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,277 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import ca.agnate.EconXP.EconXP;
public class Economy_EconXP extends AbstractEconomy {
private final Logger log;
private final String name = "EconXP";
private Plugin plugin = null;
private EconXP econ = null;
public Economy_EconXP(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
log.log(Level.WARNING, "EconXP is an integer only economy, you may notice inconsistencies with accounts if you do not setup your other econ using plugins accordingly!");
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("EconXP");
if (econ != null && econ.isEnabled()) {
this.econ = (EconXP) econ;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_EconXP economy = null;
public EconomyServerListener(Economy_EconXP economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = event.getPlugin();
if (eco.getDescription().getName().equals("EconXP")) {
economy.econ = (EconXP) eco;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("EconXP")) {
economy.econ = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
return this.econ != null;
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
amount = Math.ceil(amount);
return String.format("%d %s", (int)amount, "experience");
}
@Override
public String currencyNamePlural() {
return "experience";
}
@Override
public String currencyNameSingular() {
return "experience";
}
@Override
public double getBalance(String playerName) {
OfflinePlayer player = econ.getPlayer(playerName);
if ( player == null ) { return 0; }
return econ.getExp(player);
}
@Override
public boolean has(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
if ( player == null ) { return false; }
return econ.hasExp(player, (int) Math.ceil(amount) );
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
if ( player == null ) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player does not exist");
}
double balance = econ.getExp(player);
amount = Math.ceil(amount);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
if ( econ.hasExp(player, (int) amount) == false ) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
econ.removeExp(player, (int) amount);
double finalBalance = econ.getExp(player);
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
if ( player == null ) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player does not exist");
}
double balance = econ.getExp(player);
amount = Math.ceil(amount);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
econ.addExp(player, (int) amount );
balance = econ.getExp(player);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public boolean hasAccount(String playerName) {
return econ.getPlayer(playerName) != null;
}
@Override
public boolean createPlayerAccount(String playerName) {
return false;
}
@Override
public int fractionalDigits() {
return 0;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,332 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.api.NoLoanPermittedException;
import com.earth2me.essentials.api.UserDoesNotExistException;
public class Economy_Essentials extends AbstractEconomy {
private final String name = "Essentials Economy";
private final Logger log;
private Plugin plugin = null;
private Essentials ess = null;
public Economy_Essentials(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (ess == null) {
Plugin essentials = plugin.getServer().getPluginManager().getPlugin("Essentials");
if (essentials != null && essentials.isEnabled()) {
ess = (Essentials) essentials;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
@Override
public boolean isEnabled() {
if (ess == null) {
return false;
} else {
return ess.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public double getBalance(String playerName) {
double balance;
try {
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
} catch (UserDoesNotExistException e) {
createPlayerAccount(playerName);
balance = 0;
}
return balance;
}
@Override
public boolean createPlayerAccount(String playerName) {
if (hasAccount(playerName)) {
return false;
}
return com.earth2me.essentials.api.Economy.createNPC(playerName);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (playerName == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player name can not be null.");
}
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
try {
com.earth2me.essentials.api.Economy.subtract(playerName, amount);
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
type = EconomyResponse.ResponseType.SUCCESS;
} catch (UserDoesNotExistException e) {
if (createPlayerAccount(playerName)) {
return withdrawPlayer(playerName, amount);
} else {
amount = 0;
balance = 0;
type = EconomyResponse.ResponseType.FAILURE;
errorMessage = "User does not exist";
}
} catch (NoLoanPermittedException e) {
try {
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
amount = 0;
type = EconomyResponse.ResponseType.FAILURE;
errorMessage = "Loan was not permitted";
} catch (UserDoesNotExistException e1) {
amount = 0;
balance = 0;
type = EconomyResponse.ResponseType.FAILURE;
errorMessage = "User does not exist";
}
}
return new EconomyResponse(amount, balance, type, errorMessage);
}
public EconomyResponse tryDepositPlayer(String playerName, double amount, int tries) {
if (playerName == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player name can not be null.");
}
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
}
if (tries <= 0) {
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "Failed to deposit amount.");
}
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
try {
com.earth2me.essentials.api.Economy.add(playerName, amount);
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
type = ResponseType.SUCCESS;
} catch (UserDoesNotExistException e) {
if (createPlayerAccount(playerName)) {
return tryDepositPlayer(playerName, amount, tries--);
} else {
amount = 0;
balance = 0;
type = ResponseType.FAILURE;
errorMessage = "User does not exist";
}
} catch (NoLoanPermittedException e) {
try {
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
amount = 0;
type = ResponseType.FAILURE;
errorMessage = "Loan was not permitted";
} catch (UserDoesNotExistException e1) {
balance = 0;
amount = 0;
type = ResponseType.FAILURE;
errorMessage = "Loan was not permitted";
}
}
return new EconomyResponse(amount, balance, type, errorMessage);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
return tryDepositPlayer(playerName, amount, 2);
}
public class EconomyServerListener implements Listener {
Economy_Essentials economy = null;
public EconomyServerListener(Economy_Essentials economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.ess == null) {
Plugin essentials = event.getPlugin();
if (essentials.getDescription().getName().equals("Essentials")) {
economy.ess = (Essentials) essentials;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.ess != null) {
if (event.getPlugin().getDescription().getName().equals("Essentials")) {
economy.ess = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public String format(double amount) {
return com.earth2me.essentials.api.Economy.format(amount);
}
@Override
public String currencyNameSingular() {
return "";
}
@Override
public String currencyNamePlural() {
return "";
}
@Override
public boolean has(String playerName, double amount) {
try {
return com.earth2me.essentials.api.Economy.hasEnough(playerName, amount);
} catch (UserDoesNotExistException e) {
return false;
}
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public boolean hasAccount(String playerName) {
return com.earth2me.essentials.api.Economy.playerExists(playerName);
}
@Override
public int fractionalDigits() {
return -1;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,316 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import com.flobi.GoldIsMoney2.GoldIsMoney;
public class Economy_GoldIsMoney2 extends AbstractEconomy {
private final Logger log;
private final String name = "GoldIsMoney";
private Plugin plugin = null;
protected GoldIsMoney economy = null;
public Economy_GoldIsMoney2(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin ec = plugin.getServer().getPluginManager().getPlugin("GoldIsMoney");
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.flobi.GoldIsMoney2.GoldIsMoney")) {
economy = (GoldIsMoney) ec;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean hasBankSupport() {
return GoldIsMoney.hasBankSupport();
}
@Override
public int fractionalDigits() {
return GoldIsMoney.fractionalDigits();
}
@Override
public String format(double amount) {
return GoldIsMoney.format(amount);
}
@Override
public String currencyNamePlural() {
return GoldIsMoney.currencyNamePlural();
}
@Override
public String currencyNameSingular() {
return GoldIsMoney.currencyNameSingular();
}
@Override
public boolean hasAccount(String playerName) {
return GoldIsMoney.hasAccount(playerName);
}
@Override
public double getBalance(String playerName) {
return GoldIsMoney.getBalance(playerName);
}
@Override
public boolean has(String playerName, double amount) {
return GoldIsMoney.has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds!");
}
if (!GoldIsMoney.hasAccount(playerName)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player does not have an account!");
}
if (!GoldIsMoney.has(playerName, amount)) {
return new EconomyResponse(0, GoldIsMoney.getBalance(playerName), ResponseType.FAILURE, "Insufficient funds");
}
if (!GoldIsMoney.withdrawPlayer(playerName, amount)) {
return new EconomyResponse(0, GoldIsMoney.getBalance(playerName), ResponseType.FAILURE, "Unable to withdraw funds!");
}
return new EconomyResponse(amount, GoldIsMoney.getBalance(playerName), ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds!");
}
if (!GoldIsMoney.hasAccount(playerName)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player does not have an account!");
}
if (!GoldIsMoney.depositPlayer(playerName, amount)) {
return new EconomyResponse(0, GoldIsMoney.getBalance(playerName), ResponseType.FAILURE, "Unable to deposit funds!");
}
return new EconomyResponse(amount, GoldIsMoney.getBalance(playerName), ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse createBank(String name, String player) {
if (!GoldIsMoney.hasBankSupport()) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
}
if (!GoldIsMoney.createBank(name, player)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create bank account.");
}
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse deleteBank(String name) {
if (!GoldIsMoney.hasBankSupport()) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
}
if (!GoldIsMoney.deleteBank(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to remove bank account.");
}
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse bankBalance(String name) {
if (!GoldIsMoney.hasBankSupport()) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
}
if (!GoldIsMoney.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (!GoldIsMoney.hasBankSupport()) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
}
if (!GoldIsMoney.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
if (GoldIsMoney.bankHas(name, amount)) {
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.FAILURE, "The bank does not have enough money!");
}
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
if (!GoldIsMoney.hasBankSupport()) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
}
if (!GoldIsMoney.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
if (!GoldIsMoney.bankHas(name, amount)) {
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.FAILURE, "The bank does not have enough money!");
}
if (!GoldIsMoney.bankWithdraw(name, amount)) {
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.FAILURE, "Unable to withdraw from that bank account!");
}
return new EconomyResponse(amount, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (!GoldIsMoney.hasBankSupport()) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
}
if (!GoldIsMoney.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
if (!GoldIsMoney.bankDeposit(name, amount)) {
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.FAILURE, "Unable to deposit to that bank account!");
}
return new EconomyResponse(amount, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
if (!GoldIsMoney.hasBankSupport()) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
}
if (!GoldIsMoney.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
if (!GoldIsMoney.isBankOwner(name, playerName)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player does not own that bank!");
}
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
if (!GoldIsMoney.hasBankSupport()) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
}
if (!GoldIsMoney.bankExists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
if (!GoldIsMoney.isBankMember(name, playerName)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a member of that bank!");
}
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
}
@Override
public List<String> getBanks() {
return GoldIsMoney.getBanks();
}
@Override
public boolean createPlayerAccount(String playerName) {
return GoldIsMoney.createPlayerAccount(playerName);
}
public class EconomyServerListener implements Listener {
Economy_GoldIsMoney2 economy = null;
public EconomyServerListener(Economy_GoldIsMoney2 economy_GoldIsMoney2) {
this.economy = economy_GoldIsMoney2;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin ec = event.getPlugin();
if (ec.getClass().getName().equals("com.flobi.GoldIsMoney2.GoldIsMoney")) {
economy.economy = (GoldIsMoney) ec;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("GoldIsMoney")) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,248 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import me.igwb.GoldenChest.GoldenChestEconomy;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
public class Economy_GoldenChestEconomy extends AbstractEconomy {
private final Logger log;
private final String name = "GoldenChestEconomy";
private Plugin plugin = null;
private GoldenChestEconomy economy = null;
public Economy_GoldenChestEconomy (Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin ec = plugin.getServer().getPluginManager().getPlugin("GoldenChestEconomy");
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("me.igwb.GoldenChest.GoldenChestEconomy")) {
economy = (GoldenChestEconomy) ec;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_GoldenChestEconomy economy = null;
public EconomyServerListener(Economy_GoldenChestEconomy economy_GoldenChestEconomy) {
this.economy = economy_GoldenChestEconomy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin ec = event.getPlugin();
if (ec.getDescription().getName().equals("GoldenChestEconomy") && ec.getClass().getName().equals("me.igwb.GoldenChest.GoldenChestEconomy")) {
economy.economy = (GoldenChestEconomy) ec;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("GoldenChestEconomy")) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public int fractionalDigits() {
return economy.getVaultConnector().fractionalDigits();
}
@Override
public String format(double amount) {
return economy.getVaultConnector().format(amount);
}
@Override
public String currencyNamePlural() {
return economy.getVaultConnector().currencyNamePlural();
}
@Override
public String currencyNameSingular() {
return economy.getVaultConnector().currencyNameSingular();
}
@Override
public boolean hasAccount(String playerName) {
return economy.getVaultConnector().hasAccount(playerName);
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return economy.getVaultConnector().hasAccount(playerName, worldName);
}
@Override
public double getBalance(String playerName) {
return economy.getVaultConnector().getBalance(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return economy.getVaultConnector().getBalance(playerName, world);
}
@Override
public boolean has(String playerName, double amount) {
return economy.getVaultConnector().has(playerName, amount);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return economy.getVaultConnector().has(playerName, worldName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
if (has(playerName, amount)) {
economy.getVaultConnector().withdrawPlayer(playerName, amount);
return new EconomyResponse(amount, getBalance(playerName), ResponseType.SUCCESS, null);
} else {
return new EconomyResponse(0, getBalance(playerName), ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName,
double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
}
economy.getVaultConnector().depositPlayer(playerName, amount);
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName,
double amount) {
return depositPlayer(playerName, amount);
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
}
@Override
public List<String> getBanks() {
return null;
}
@Override
public boolean createPlayerAccount(String playerName) {
return economy.getVaultConnector().createPlayerAccount(playerName);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return economy.getVaultConnector().createPlayerAccount(playerName, worldName);
}
}

View File

@ -1,272 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import org.gestern.gringotts.Account;
import org.gestern.gringotts.AccountHolder;
import org.gestern.gringotts.Gringotts;
public class Economy_Gringotts extends AbstractEconomy {
private final Logger log;
private final String name = "Gringotts";
private Plugin plugin = null;
private Gringotts gringotts = null;
public Economy_Gringotts(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (gringotts == null) {
Plugin grngts = plugin.getServer().getPluginManager().getPlugin("Gringotts");
if (grngts != null && grngts.isEnabled()) {
gringotts = (Gringotts) grngts;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_Gringotts economy = null;
public EconomyServerListener(Economy_Gringotts economy_Gringotts) {
this.economy = economy_Gringotts;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.gringotts == null) {
Plugin grngts = event.getPlugin();
if (grngts.getDescription().getName().equals("Gringotts")) {
economy.gringotts = (Gringotts) grngts;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.gringotts != null) {
if (event.getPlugin().getDescription().getName().equals("Gringotts")) {
economy.gringotts = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled(){
return gringotts != null && gringotts.isEnabled();
}
@Override
public String getName() {
return name;
}
@Override
public boolean hasBankSupport(){
return false;
}
@Override
public int fractionalDigits(){
return 2;
}
@Override
public String format(double amount) {
return Double.toString(amount);
}
@Override
public String currencyNamePlural(){
return org.gestern.gringotts.Configuration.config.currencyNamePlural;
}
@Override
public String currencyNameSingular(){
return org.gestern.gringotts.Configuration.config.currencyNameSingular;
}
@Override
public boolean hasAccount(String playerName) {
AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName);
if (owner == null) {
return false;
}
return gringotts.accounting.getAccount(owner) != null;
}
@Override
public double getBalance(String playerName){
AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName);
if (owner == null) {
return 0;
}
Account account = gringotts.accounting.getAccount(owner);
return account.balance();
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if( amount < 0 ) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw a negative amount.");
}
AccountHolder accountHolder = gringotts.accountHolderFactory.getAccount(playerName);
if (accountHolder == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, playerName + " is not a valid account holder.");
}
Account account = gringotts.accounting.getAccount( accountHolder );
if(account.balance() >= amount && account.remove(amount)) {
//We has mulah!
return new EconomyResponse(amount, account.balance(), ResponseType.SUCCESS, null);
} else {
//Not enough money to withdraw this much.
return new EconomyResponse(0, account.balance(), ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount){
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
}
AccountHolder accountHolder = gringotts.accountHolderFactory.getAccount(playerName);
if (accountHolder == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, playerName + " is not a valid account holder.");
}
Account account = gringotts.accounting.getAccount( accountHolder );
if (account.add(amount)) {
return new EconomyResponse( amount, account.balance(), ResponseType.SUCCESS, null);
} else {
return new EconomyResponse( 0, account.balance(), ResponseType.FAILURE, "Not enough capacity to store that amount!");
}
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean createPlayerAccount(String playerName) {
return hasAccount(playerName);
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,248 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import boardinggamer.mcmoney.McMoneyAPI;
public class Economy_McMoney extends AbstractEconomy {
private final Logger log;
private final String name = "McMoney";
private Plugin plugin = null;
private McMoneyAPI economy = null;
public Economy_McMoney(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("McMoney");
if (econ != null && econ.isEnabled()) {
economy = McMoneyAPI.getInstance();
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
return economy != null;
}
@Override
public double getBalance(String playerName) {
return economy.getMoney(playerName);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance = economy.getMoney(playerName);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
} else if (balance - amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
economy.removeMoney(playerName, amount);
return new EconomyResponse(amount, economy.getMoney(playerName), ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance = economy.getMoney(playerName);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
}
economy.addMoney(playerName, amount);
return new EconomyResponse(amount, economy.getMoney(playerName), ResponseType.SUCCESS, "");
}
@Override
public String currencyNamePlural() {
return economy.moneyNamePlural();
}
@Override
public String currencyNameSingular() {
return economy.moneyNameSingle();
}
public class EconomyServerListener implements Listener {
Economy_McMoney economy = null;
public EconomyServerListener(Economy_McMoney economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin eco = event.getPlugin();
if (eco.getDescription().getName().equals("McMoney")) {
economy.economy = McMoneyAPI.getInstance();
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("McMoney")) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public String format(double amount) {
amount = Math.ceil(amount);
if (amount == 1) {
return String.format("%d %s", (int)amount, currencyNameSingular());
} else {
return String.format("%d %s", (int)amount, currencyNamePlural());
}
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public boolean hasAccount(String playerName) {
return economy.playerExists(playerName);
}
@Override
public boolean createPlayerAccount(String playerName) {
if (!hasAccount(playerName)) {
economy.setMoney(playerName, 0.0);
return true;
}
return false;
}
@Override
public int fractionalDigits() {
return -1;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,370 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import com.gmail.bleedobsidian.miconomy.Main;
import com.gmail.bleedobsidian.miconomy.MiConomy;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
public class Economy_MiConomy extends AbstractEconomy {
private final Logger log;
private final String name = "MiConomy";
private Plugin plugin;
private MiConomy economy;
private Main miConomy;
public Economy_MiConomy(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (miConomy == null) {
Plugin miConomyPlugin = plugin.getServer().getPluginManager().getPlugin("MiConomy");
if (miConomy != null) {
miConomy = (Main) miConomyPlugin;
economy = miConomy.getInstance();
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
@Override
public boolean isEnabled() {
if(miConomy == null) {
return false;
} else {
return miConomy.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean hasBankSupport() {
return true;
}
@Override
public int fractionalDigits() {
return 2;
}
@Override
public String format(double amount) {
return economy.getFormattedValue(amount);
}
@Override
public String currencyNamePlural() {
return miConomy.getPluginConfig().MoneyNamePlural;
}
@Override
public String currencyNameSingular() {
return miConomy.getPluginConfig().MoneyName;
}
@Override
public boolean hasAccount(String playerName) {
List<World> worlds = plugin.getServer().getWorlds();
return hasAccount(playerName, worlds.get(0).getName());
}
@Override
public boolean hasAccount(String playerName, String worldName) {
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
World world = plugin.getServer().getWorld(worldName);
return economy.isAccountCreated(player, world);
}
@Override
public double getBalance(String playerName) {
List<World> worlds = plugin.getServer().getWorlds();
return getBalance(playerName, worlds.get(0).getName());
}
@Override
public double getBalance(String playerName, String worldName) {
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
World world = plugin.getServer().getWorld(worldName);
return economy.getAccountBalance(player, world);
}
@Override
public boolean has(String playerName, double amount) {
List<World> worlds = plugin.getServer().getWorlds();
return has(playerName, worlds.get(0).getName(), amount);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
World world = plugin.getServer().getWorld(worldName);
double playerBalance = economy.getAccountBalance(player, world);
if(playerBalance >= amount) {
return true;
} else {
return false;
}
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
List<World> worlds = plugin.getServer().getWorlds();
return withdrawPlayer(playerName, worlds.get(0).getName(), amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
World world = plugin.getServer().getWorld(worldName);
double balance = economy.getAccountBalance(player, world);
if(getBalance(playerName, worldName) < amount) {
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "Insufficient funds");
} else {
if(economy.removeAccountBalance(player, amount, world)) {
balance = economy.getAccountBalance(player, world);
return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "Failed to remove funds from account");
}
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
List<World> worlds = plugin.getServer().getWorlds();
return depositPlayer(playerName, worlds.get(0).getName(), amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
World world = plugin.getServer().getWorld(worldName);
double balance = economy.getAccountBalance(player, world);
if(economy.addAccountBalance(player, amount, world)) {
balance = economy.getAccountBalance(player, world);
return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "Failed to add funds to account");
}
}
@Override
public EconomyResponse createBank(String name, String player) {
OfflinePlayer owner = plugin.getServer().getOfflinePlayer(player);
ArrayList<OfflinePlayer> owners = new ArrayList<OfflinePlayer>();
owners.add(owner);
if(!economy.isBankCreated(name)) {
economy.createBank(name, owners, new ArrayList<String>(), false);
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "A bank with this name already exists");
}
}
@Override
public EconomyResponse deleteBank(String name) {
if(economy.isBankCreated(name)) {
economy.deleteBank(name);
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
}
}
@Override
public EconomyResponse bankBalance(String name) {
if(economy.isBankCreated(name)) {
double balance = economy.getBankBalance(name);
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
}
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if(economy.isBankCreated(name)) {
double balance = economy.getBankBalance(name);
if(balance >= amount) {
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "The bank does not have enough money!");
}
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
}
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
if(economy.isBankCreated(name)) {
economy.removeBankBalance(name, amount);
double balance = economy.getBankBalance(name);
return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
}
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if(economy.isBankCreated(name)) {
economy.addBankBalance(name, amount);
double balance = economy.getBankBalance(name);
return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
}
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
OfflinePlayer owner = plugin.getServer().getOfflinePlayer(playerName);
if(economy.isBankCreated(name)) {
if(economy.isPlayerBankOwner(name, owner)) {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "The player is not a bank owner");
}
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
}
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
OfflinePlayer owner = plugin.getServer().getOfflinePlayer(playerName);
if(economy.isBankCreated(name)) {
if(economy.isPlayerBankMember(name, owner)) {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "The player is not a bank member");
}
} else {
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
}
}
@Override
public List<String> getBanks() {
return economy.getBanks();
}
@Override
public boolean createPlayerAccount(String playerName) {
List<World> worlds = plugin.getServer().getWorlds();
return createPlayerAccount(playerName, worlds.get(0).getName());
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
World world = plugin.getServer().getWorld(worldName);
if(!economy.isAccountCreated(player, world)) {
economy.createAccount(player, 0, world);
return true;
} else {
return false;
}
}
public class EconomyServerListener implements Listener {
Economy_MiConomy economy = null;
public EconomyServerListener(Economy_MiConomy economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin miConomyPlugin = event.getPlugin();
if (miConomyPlugin.getDescription().getName().equals("MiConomy")) {
economy.miConomy = (Main) miConomyPlugin;
economy.economy = miConomy.getInstance();
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("MiConomy")) {
economy.miConomy = null;
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
}

View File

@ -1,272 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import me.mjolnir.mineconomy.MineConomy;
import me.mjolnir.mineconomy.exceptions.AccountNameConflictException;
import me.mjolnir.mineconomy.exceptions.NoAccountException;
import me.mjolnir.mineconomy.internal.MCCom;
import me.mjolnir.mineconomy.internal.util.MCFormat;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
public class Economy_MineConomy extends AbstractEconomy {
private final Logger log;
private final String name = "MineConomy";
private Plugin plugin = null;
private MineConomy econ = null;
public Economy_MineConomy(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("MineConomy");
if (econ != null && econ.isEnabled()) {
this.econ = (MineConomy) econ;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_MineConomy economy = null;
public EconomyServerListener(Economy_MineConomy economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = event.getPlugin();
if (eco.getDescription().getName().equals("MineConomy")) {
economy.econ = (MineConomy) eco;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("MineConomy")) {
economy.econ = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
public boolean isEnabled() {
return econ != null;
}
public String getName() {
return "MineConomy";
}
public String format(double amount) {
return MCFormat.format(amount);
}
public String currencyNameSingular() {
return MCCom.getDefaultCurrency();
}
public String currencyNamePlural() {
return MCCom.getDefaultCurrency();
}
public double getBalance(String playerName) {
try
{
return MCCom.getExternalBalance(playerName);
}
catch (NoAccountException e)
{
MCCom.create(playerName);
return MCCom.getExternalBalance(playerName);
}
}
@Override
public boolean has(String playerName, double amount) {
try {
return MCCom.canExternalAfford(playerName, amount);
} catch(NoAccountException e) {
MCCom.create(playerName);
return MCCom.canExternalAfford(playerName, amount);
}
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance;
try {
balance = MCCom.getExternalBalance(playerName);
} catch (NoAccountException e) {
MCCom.create(playerName);
balance = MCCom.getExternalBalance(playerName);
}
if(amount < 0.0D) {
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
if(balance >= amount) {
double finalBalance = balance - amount;
MCCom.setExternalBalance(playerName, finalBalance);
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
} else {
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance;
try {
balance = MCCom.getExternalBalance(playerName);
} catch (NoAccountException e) {
MCCom.create(playerName);
balance = MCCom.getExternalBalance(playerName);
}
if(amount < 0.0D) {
return new EconomyResponse(0.0D, 0.0, ResponseType.FAILURE, "Cannot deposit negative funds");
}
balance += amount;
MCCom.setExternalBalance(playerName, balance);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public boolean hasAccount(String playerName) {
return MCCom.exists(playerName);
}
public boolean createPlayerAccount(String playerName) {
try {
MCCom.create(playerName);
return true;
} catch(AccountNameConflictException e) {
return false;
}
}
@Override
public int fractionalDigits() {
return 2;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,215 +0,0 @@
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import me.coniin.plugins.minefaconomy.Minefaconomy;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
public class Economy_Minefaconomy extends AbstractEconomy {
private final Logger log;
private final String name = "Minefaconomy";
private Plugin plugin = null;
private Minefaconomy economy = null;
public Economy_Minefaconomy(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
Plugin econ = null;
// Load Plugin in case it was loaded before
if (economy == null) {
econ = plugin.getServer().getPluginManager().getPlugin("Minefaconomy");
log.info("Loading Minefaconomy");
}
if (econ != null && econ.isEnabled()) {
economy = (Minefaconomy) econ;
log.info(String.format("[Economy] %s hooked.", this.name));
return;
}
log.info("Error Loading Minefaconomy");
}
public class EconomyServerListener implements Listener {
Economy_Minefaconomy economy_minefaconomy = null;
public EconomyServerListener(Economy_Minefaconomy economy_minefaconomy) {
this.economy_minefaconomy = economy_minefaconomy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy_minefaconomy.economy == null) {
Plugin mfc = event.getPlugin();
if (mfc.getDescription().getName().equals("Minefaconomy")) {
economy_minefaconomy.economy = (Minefaconomy) economy;
log.info(String.format("[Economy] %s hooked.", economy_minefaconomy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy_minefaconomy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("Minefaconomy")) {
economy_minefaconomy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy_minefaconomy.name));
}
}
}
}
@Override
public boolean isEnabled() {
return economy != null && economy.isEnabled();
}
@Override
public String getName() {
return name;
}
@Override
public int fractionalDigits() {
return Minefaconomy.vaultLayer.fractionalDigits();
}
@Override
public String format(double amount) {
return Minefaconomy.vaultLayer.format(amount);
}
@Override
public String currencyNamePlural() {
return Minefaconomy.vaultLayer.currencyNamePlural();
}
@Override
public String currencyNameSingular() {
return Minefaconomy.vaultLayer.currencyNameSingular();
}
@Override
public boolean hasAccount(String playerName) {
return Minefaconomy.vaultLayer.hasAccount(playerName);
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return Minefaconomy.vaultLayer.hasAccount(playerName);
}
@Override
public double getBalance(String playerName) {
return Minefaconomy.vaultLayer.getBalance(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return Minefaconomy.vaultLayer.getBalance(playerName);
}
@Override
public boolean has(String playerName, double amount) {
return Minefaconomy.vaultLayer.has(playerName, amount);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return Minefaconomy.vaultLayer.has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
return Minefaconomy.vaultLayer.withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName,
double amount) {
return Minefaconomy.vaultLayer.withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
return Minefaconomy.vaultLayer.depositPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName,
double amount) {
return Minefaconomy.vaultLayer.depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName) {
return Minefaconomy.vaultLayer.createPlayerAccount(playerName);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return Minefaconomy.vaultLayer.createPlayerAccount(playerName);
}
@Override
public boolean hasBankSupport() {
return Minefaconomy.vaultLayer.hasBankSupport();
}
@Override
public EconomyResponse createBank(String name, String player) {
return Minefaconomy.vaultLayer.createBank(name, player);
}
@Override
public EconomyResponse deleteBank(String name) {
return Minefaconomy.vaultLayer.deleteBank(name);
}
@Override
public EconomyResponse bankBalance(String name) {
return Minefaconomy.vaultLayer.bankBalance(name);
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return Minefaconomy.vaultLayer.bankHas(name, amount);
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return Minefaconomy.vaultLayer.bankWithdraw(name, amount);
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return Minefaconomy.vaultLayer.bankDeposit(name, amount);
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return Minefaconomy.vaultLayer.isBankOwner(name, playerName);
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return Minefaconomy.vaultLayer.isBankMember(name, playerName);
}
@Override
public List<String> getBanks() {
return Minefaconomy.vaultLayer.getBanks();
}
}

View File

@ -1,294 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import me.ashtheking.currency.Currency;
import me.ashtheking.currency.CurrencyList;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
public class Economy_MultiCurrency extends AbstractEconomy {
private final Logger log;
private final String name = "MultiCurrency";
private Plugin plugin = null;
private Currency economy = null;
public Economy_MultiCurrency(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin multiCurrency = plugin.getServer().getPluginManager().getPlugin("MultiCurrency");
if (multiCurrency != null && multiCurrency.isEnabled()) {
economy = (Currency) multiCurrency;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public double getBalance(String playerName) {
final double balance;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
final double fBalance = balance;
return fBalance;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
if (amount < 0) {
errorMessage = "Cannot withdraw negative funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
}
if (!CurrencyList.hasEnough(playerName, amount)) {
errorMessage = "Insufficient funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
}
if (CurrencyList.subtract(playerName, amount)) {
type = EconomyResponse.ResponseType.SUCCESS;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
if (amount < 0) {
errorMessage = "Cannot deposit negative funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
}
if (CurrencyList.add(playerName, amount)) {
type = EconomyResponse.ResponseType.SUCCESS;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
public class EconomyServerListener implements Listener {
Economy_MultiCurrency economy = null;
public EconomyServerListener(Economy_MultiCurrency economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin mcur = event.getPlugin();
if (mcur.getDescription().getName().equals("MultiCurrency")) {
economy.economy = (Currency) mcur;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("MultiCurrency")) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public String format(double amount) {
return String.format("%.2f %s", amount, "currency");
}
@Override
public String currencyNameSingular() {
return "currency";
}
@Override
public String currencyNamePlural() {
return "currency";
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public boolean hasAccount(String playerName) {
return true;
}
@Override
public boolean createPlayerAccount(String playerName) {
return false;
}
@Override
public int fractionalDigits() {
return -1;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,228 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.plugin.Plugin;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import com.github.omwah.SDFEconomy.SDFEconomy;
import com.github.omwah.SDFEconomy.SDFEconomyAPI;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
public class Economy_SDFEconomy extends AbstractEconomy {
private final Logger log;
private final String name = "SDFEconomy";
private Plugin plugin = null;
private SDFEconomyAPI api = null;
public Economy_SDFEconomy(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
// Register a listener to wait for plugin being loaded
plugin.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Try and Load API in case plugin was loaded before Vault
load_api();
}
public void load_api() {
SDFEconomy pluginSDF = (SDFEconomy) plugin.getServer().getPluginManager().getPlugin("SDFEconomy");
if(!isEnabled() && pluginSDF != null) {
api = pluginSDF.getAPI();
log.info(String.format("[Economy] %s hooked.", name));
}
}
public void unload_api() {
SDFEconomy pluginSDF = (SDFEconomy) plugin.getServer().getPluginManager().getPlugin("SDFEconomy");
if(isEnabled() && pluginSDF != null) {
api = null;
log.info(String.format("[Economy] %s unhooked.", name));
}
}
public class EconomyServerListener implements Listener {
Economy_SDFEconomy economy = null;
public EconomyServerListener(Economy_SDFEconomy economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (event.getPlugin().getDescription().getName().equals("SDFEconomy")) {
economy.load_api();
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (event.getPlugin().getDescription().getName().equals("SDFEconomy")) {
economy.unload_api();
}
}
}
@Override
public boolean isEnabled() {
return api != null;
}
@Override
public String getName() {
return "SDFEconomy";
}
@Override
public boolean hasBankSupport() {
return api.hasBankSupport();
}
@Override
public int fractionalDigits() {
return api.fractionalDigits();
}
@Override
public String format(double amount) {
return api.format(amount);
}
@Override
public String currencyNamePlural() {
return api.currencyNamePlural();
}
@Override
public String currencyNameSingular() {
return api.currencyNameSingular();
}
@Override
public boolean hasAccount(String playerName) {
return api.hasAccount(playerName);
}
@Override
public double getBalance(String playerName) {
return api.getBalance(playerName);
}
@Override
public boolean has(String playerName, double amount) {
return api.has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
return api.withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
return api.depositPlayer(playerName, amount);
}
@Override
public EconomyResponse createBank(String name, String player) {
return api.createBank(name, player);
}
@Override
public EconomyResponse deleteBank(String name) {
return api.deleteBank(name);
}
@Override
public EconomyResponse bankBalance(String name) {
return api.bankBalance(name);
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return api.bankHas(name, amount);
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return api.bankWithdraw(name, amount);
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return api.bankDeposit(name, amount);
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return api.isBankOwner(name, playerName);
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return api.isBankMember(name, playerName);
}
@Override
public List<String> getBanks() {
return api.getBankNames();
}
@Override
public boolean createPlayerAccount(String playerName) {
return api.createPlayerAccount(playerName);
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,259 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import net.teamalpha.taecon.TAEcon;
public class Economy_TAEcon extends AbstractEconomy {
private final Logger log;
private final String name = "TAEcon";
private Plugin plugin = null;
private TAEcon economy = null;
public Economy_TAEcon(Plugin plugin){
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
if (economy == null) {
Plugin taecon = plugin.getServer().getPluginManager().getPlugin(name);
if (taecon != null && taecon.isEnabled()) {
economy = (TAEcon) taecon;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_TAEcon economy = null;
public EconomyServerListener(Economy_TAEcon economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin taecon = event.getPlugin();
if (taecon.getDescription().getName().equals(economy.name)) {
economy.economy = (TAEcon) taecon;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals(economy.name)) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
return economy != null;
}
@Override
public String getName() {
return name;
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public int fractionalDigits() {
return 0;
}
@Override
public String format(double amount) {
amount = Math.ceil(amount);
if (amount == 1) {
return String.format("%d %s", (int)amount, currencyNameSingular());
} else {
return String.format("%d %s", (int)amount, currencyNamePlural());
}
}
@Override
public String currencyNamePlural() {
return economy.getCurrencyName(true);
}
@Override
public String currencyNameSingular() {
return economy.getCurrencyName(false);
}
@Override
public boolean hasAccount(String playerName) {
return true;
}
@Override
public double getBalance(String playerName) {
return economy.getBalance(playerName);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
ResponseType rt;
String message;
int iamount = (int)Math.ceil(amount);
if (has(playerName, amount)) {
if (economy.removeBalance(playerName, iamount)) {
rt = ResponseType.SUCCESS;
message = null;
} else {
rt = ResponseType.SUCCESS;
message = "ERROR";
}
} else {
rt = ResponseType.FAILURE;
message = "Not enough money";
}
return new EconomyResponse(iamount, getBalance(playerName), rt, message);
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
ResponseType rt;
String message;
int iamount = (int)Math.floor(amount);
if (economy.addBalance(playerName, iamount)) {
rt = ResponseType.SUCCESS;
message = null;
} else {
rt = ResponseType.SUCCESS;
message = "ERROR";
}
return new EconomyResponse(iamount, getBalance(playerName), rt, message);
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean createPlayerAccount(String playerName) {
return false;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return true;
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return false;
}
}

View File

@ -1,388 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import com.gmail.mirelatrue.xpbank.API;
import com.gmail.mirelatrue.xpbank.Account;
import com.gmail.mirelatrue.xpbank.GroupBank;
import com.gmail.mirelatrue.xpbank.XPBank;
public class Economy_XPBank extends AbstractEconomy {
private final Logger log;
private final String name = "XPBank";
private Plugin plugin = null;
private XPBank XPB = null;
private API api = null;
public Economy_XPBank (Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (XPB == null) {
Plugin economy = plugin.getServer().getPluginManager().getPlugin("XPBank");
if (economy != null && economy.isEnabled()) {
XPB = (XPBank) economy;
api = XPB.getAPI();
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_XPBank economy = null;
public EconomyServerListener (Economy_XPBank economy_XPBank) {
this.economy = economy_XPBank;
}
@EventHandler (priority = EventPriority.MONITOR)
public void onPluginEnable (PluginEnableEvent event) {
if (economy.XPB == null) {
Plugin eco = event.getPlugin();
if (eco.getDescription().getName().equals("XPBank")) {
economy.XPB = (XPBank) eco;
api = XPB.getAPI();
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler (priority = EventPriority.MONITOR)
public void onPluginDisable (PluginDisableEvent event) {
if (economy.XPB != null) {
if (event.getPlugin().getDescription().getName().equals("XPBank")) {
economy.XPB = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled () {
return this.XPB != null;
}
@Override
public String getName () {
return name;
}
@Override
public boolean hasBankSupport () {
return true;
}
@Override
public int fractionalDigits () {
return 0;
}
@Override
public String format (double amount) {
return String.format("%d %s", (int) amount, api.currencyName((int) amount));
}
@Override
public String currencyNamePlural () {
return api.getMsg("CurrencyNamePlural");
}
@Override
public String currencyNameSingular () {
return api.getMsg("currencyName");
}
@Override
public boolean hasAccount (String playerName) {
Account account = api.getAccount(playerName);
if (account != null) {
return true;
}
return false;
}
@Override
public double getBalance (String playerName) {
Account account = api.getAccount(playerName);
return account.getBalance();
}
@Override
public boolean has (String playerName, double amount) {
Account account = api.getAccount(playerName);
if (account.getBalance() >= (int) amount) {
return true;
}
return false;
}
@Override
public EconomyResponse withdrawPlayer (String playerName, double amount) {
Account account = api.getAccount(playerName);
if (account == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("Player doesn't exist."));
}
int value = (int) amount;
int balance = account.getBalance();
if (value < 1) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
}
if (value > balance) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
}
account.modifyBalance(-value);
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse depositPlayer (String playerName, double amount) {
Account account = api.getAccount(playerName);
if (account == null) {
// Stupid plugins that use fake players without creating them first...
// return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player doesn't exist");
this.createPlayerAccount(playerName);
}
int value = (int) amount;
int balance = account.getBalance();
if (value < 1) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
}
account.addTaxableIncome(value);
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse createBank (String name, String player) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank != null) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("GroupBankExists"), name));
}
Account account = api.getAccount(player);
groupBank = api.createGroupBank(name, account);
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse deleteBank (String name) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
api.deleteGroupBank(groupBank, String.format(api.getMsg("Disbanded"), groupBank.getName()));
return new EconomyResponse(0, 0, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse bankBalance (String name) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse bankHas (String name, double amount) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
int value = (int) amount;
int balance = groupBank.getBalance();
if (balance >= value) {
return new EconomyResponse(0, balance, ResponseType.SUCCESS, null);
}
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
}
@Override
public EconomyResponse bankWithdraw (String name, double amount) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
int value = (int) amount;
int balance = groupBank.getBalance();
if (value < 1) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
}
if (value > balance) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
}
groupBank.modifyBalance(-value);
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse bankDeposit (String name, double amount) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
int value = (int) amount;
int balance = groupBank.getBalance();
if (value < 1) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
}
groupBank.modifyBalance(value);
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse isBankOwner (String name, String playerName) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
Account account = api.getAccount(name);
if (account == null) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
}
if (groupBank.getOwner().equalsIgnoreCase(name)) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
}
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("PlayerNotOwner"), account.getName(), groupBank.getName()));
}
@Override
public EconomyResponse isBankMember (String name, String playerName) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
Account account = api.getAccount(name);
if (account == null) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
}
if (groupBank.groupMembers.getMembers().containsKey(playerName)) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
}
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("NotAMemberOf"), groupBank.getName(), account.getName()));
}
@Override
public List<String> getBanks () {
return api.getAllGroupBanks();
}
@Override
public boolean createPlayerAccount (String playerName) {
api.createAccount(playerName);
return true;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,254 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import me.ethan.eWallet.ECO;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
public class Economy_eWallet extends AbstractEconomy {
private final Logger log;
private final String name = "eWallet";
private Plugin plugin = null;
private ECO econ = null;
public Economy_eWallet(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("eWallet");
if (econ != null && econ.isEnabled()) {
this.econ = (ECO) econ;
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_eWallet economy = null;
public EconomyServerListener(Economy_eWallet economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = event.getPlugin();
if (eco.getDescription().getName().equals("eWallet")) {
economy.econ = (ECO) eco;
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("eWallet")) {
economy.econ = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
return this.econ != null;
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
amount = Math.ceil(amount);
if (amount == 1) {
return String.format("%d %s", (int)amount, econ.singularCurrency);
} else {
return String.format("%d %s", (int)amount, econ.pluralCurrency);
}
}
@Override
public String currencyNameSingular() {
return econ.singularCurrency;
}
@Override
public String currencyNamePlural() {
return econ.pluralCurrency;
}
@Override
public double getBalance(String playerName) {
Integer i = econ.getMoney(playerName);
return i == null ? 0 : i;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= Math.ceil(amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
amount = Math.ceil(amount);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
} else if (balance >= amount) {
double finalBalance = balance - amount;
econ.takeMoney(playerName, (int) amount);
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
amount = Math.ceil(amount);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
} else {
balance += amount;
econ.giveMoney(playerName, (int) amount);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
@Override
public boolean hasBankSupport() {
return false;
}
@Override
public boolean hasAccount(String playerName) {
return econ.hasAccount(playerName);
}
@Override
public boolean createPlayerAccount(String playerName) {
if (hasAccount(playerName)) {
return false;
}
econ.createAccount(playerName, 0);
return true;
}
@Override
public int fractionalDigits() {
return 0;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}

View File

@ -1,293 +0,0 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.AbstractEconomy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import com.iCo6.Constants;
import com.iCo6.iConomy;
import com.iCo6.system.Accounts;
import com.iCo6.system.Holdings;
public class Economy_iConomy6 extends AbstractEconomy {
private final Logger log;
private String name = "iConomy ";
private Plugin plugin = null;
protected iConomy economy = null;
private Accounts accounts;
public Economy_iConomy6(Plugin plugin) {
this.plugin = plugin;
this.log = plugin.getLogger();
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
log.warning("iConomy - If you are using Flatfile storage be aware that versions 6, 7 and 8 have a CRITICAL bug which can wipe ALL iconomy data.");
log.warning("if you're using Votifier, or any other plugin which handles economy data in a threaded manner your server is at risk!");
log.warning("it is highly suggested to use SQL with iCo6 or to use an alternative economy plugin!");
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin ec = plugin.getServer().getPluginManager().getPlugin("iConomy");
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.iCo6.iConomy")) {
String version = ec.getDescription().getVersion().split("\\.")[0];
name += version;
economy = (iConomy) ec;
accounts = new Accounts();
log.info(String.format("[Economy] %s hooked.", name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_iConomy6 economy = null;
public EconomyServerListener(Economy_iConomy6 economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin ec = event.getPlugin();
if (ec.getClass().getName().equals("com.iCo6.iConomy")) {
String version = ec.getDescription().getVersion().split("\\.")[0];
name += version;
economy.economy = (iConomy) ec;
accounts = new Accounts();
log.info(String.format("[Economy] %s hooked.", economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("iConomy")) {
economy.economy = null;
log.info(String.format("[Economy] %s unhooked.", economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
return iConomy.format(amount);
}
@Override
public String currencyNameSingular() {
return Constants.Nodes.Major.getStringList().get(0);
}
@Override
public String currencyNamePlural() {
return Constants.Nodes.Major.getStringList().get(1);
}
@Override
public double getBalance(String playerName) {
if (accounts.exists(playerName)) {
return accounts.get(playerName).getHoldings().getBalance();
} else {
return 0;
}
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
Holdings holdings = accounts.get(playerName).getHoldings();
if (holdings.hasEnough(amount)) {
holdings.subtract(amount);
return new EconomyResponse(amount, holdings.getBalance(), ResponseType.SUCCESS, null);
} else {
return new EconomyResponse(0, holdings.getBalance(), ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
}
Holdings holdings = accounts.get(playerName).getHoldings();
holdings.add(amount);
return new EconomyResponse(amount, holdings.getBalance(), ResponseType.SUCCESS, null);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse createBank(String name, String player) {
if (accounts.exists(name)) {
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.FAILURE, "That account already exists.");
}
boolean created = accounts.create(name);
if (created) {
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There was an error creating the account");
}
}
@Override
public EconomyResponse deleteBank(String name) {
if (accounts.exists(name)) {
accounts.remove(name);
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank account does not exist.");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (has(name, amount)) {
return new EconomyResponse(0, amount, ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.FAILURE, "The account does not have enough!");
}
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
return withdrawPlayer(name, amount);
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
}
return depositPlayer(name, amount);
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank owners.");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank members.");
}
@Override
public EconomyResponse bankBalance(String name) {
if (!accounts.exists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no bank account with that name");
} else {
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.SUCCESS, null);
}
}
@Override
public List<String> getBanks() {
throw new UnsupportedOperationException("iConomy does not support listing of bank accounts");
}
@Override
public boolean hasBankSupport() {
return true;
}
@Override
public boolean hasAccount(String playerName) {
return accounts.exists(playerName);
}
@Override
public boolean createPlayerAccount(String playerName) {
if (hasAccount(playerName)) {
return false;
}
return accounts.create(playerName);
}
@Override
public int fractionalDigits() {
return -1;
}
@Override
public boolean hasAccount(String playerName, String worldName) {
return hasAccount(playerName);
}
@Override
public double getBalance(String playerName, String world) {
return getBalance(playerName);
}
@Override
public boolean has(String playerName, String worldName, double amount) {
return has(playerName, amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
return withdrawPlayer(playerName, amount);
}
@Override
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
return depositPlayer(playerName, amount);
}
@Override
public boolean createPlayerAccount(String playerName, String worldName) {
return createPlayerAccount(playerName);
}
}