diff --git a/src/main/java/net/milkbowl/vault/economy/Economy.java b/src/main/java/net/milkbowl/vault/economy/Economy.java
index a1b3ed9..ccb3740 100644
--- a/src/main/java/net/milkbowl/vault/economy/Economy.java
+++ b/src/main/java/net/milkbowl/vault/economy/Economy.java
@@ -17,7 +17,6 @@
package net.milkbowl.vault.economy;
import java.util.List;
-import java.util.UUID;
import org.bukkit.OfflinePlayer;
@@ -97,15 +96,7 @@ public interface Economy {
public boolean hasAccount(OfflinePlayer player);
/**
- * Checks if this uuid has an account yet
- *
- * @param uuid to check
- * @return if the uuid has an account
- */
- public boolean hasAccount(UUID uuid);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} or {@link #hasAccount(UUID, String)} instead.
+ * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} instead.
*/
@Deprecated
public boolean hasAccount(String playerName, String worldName);
@@ -122,16 +113,7 @@ public interface Economy {
public boolean hasAccount(OfflinePlayer player, String worldName);
/**
- * Checks if this uuid has an account yet on the given world
- *
- * @param uuid to check
- * @param worldName world-specific account
- * @return if the uuid has an account
- */
- public boolean hasAccount(UUID uuid, String worldName);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} or {@link #getBalance(UUID)} instead.
+ * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} instead.
*/
@Deprecated
public double getBalance(String playerName);
@@ -145,15 +127,7 @@ public interface Economy {
public double getBalance(OfflinePlayer player);
/**
- * Gets balance of a UUID
- *
- * @param uuid of the account to get a balance for
- * @return Amount currently held in account associated with the given UUID
- */
- public double getBalance(UUID uuid);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} or {@link #getBalance(UUID, String)} instead.
+ * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} instead.
*/
@Deprecated
public double getBalance(String playerName, String world);
@@ -168,16 +142,7 @@ public interface Economy {
public double getBalance(OfflinePlayer player, String world);
/**
- * Gets balance of a UUID on the specified world.
- * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
- * @param uuid of the account to get a balance for
- * @param world name of the world
- * @return Amount currently held in account associated with the given UUID
- */
- public double getBalance(UUID uuid, String world);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} or {@link #has(UUID, double)} instead.
+ * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} instead.
*/
@Deprecated
public boolean has(String playerName, double amount);
@@ -192,16 +157,7 @@ public interface Economy {
public boolean has(OfflinePlayer player, double amount);
/**
- * Checks if the account associated with the given UUID has the amount - DO NOT USE NEGATIVE AMOUNTS
- *
- * @param uuid to check
- * @param amount to check for
- * @return True if UUID has amount, False else wise
- */
- public boolean has(UUID uuid, double amount);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, String, double)} or {@link #has(UUID, String, double)} instead.
+ * @deprecated As of VaultAPI 1.4 use @{link {@link #has(OfflinePlayer, String, double)} instead.
*/
@Deprecated
public boolean has(String playerName, String worldName, double amount);
@@ -218,18 +174,7 @@ public interface Economy {
public boolean has(OfflinePlayer player, String worldName, double amount);
/**
- * Checks if the account associated with the given UUID has the amount in the given world - DO NOT USE NEGATIVE AMOUNTS
- * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
- *
- * @param uuid to check
- * @param worldName to check with
- * @param amount to check for
- * @return True if UUID has amount in the given world, False else wise
- */
- public boolean has(UUID uuid, String worldName, double amount);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} or {@link #withdrawPlayer(UUID, double)} instead.
+ * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} instead.
*/
@Deprecated
public EconomyResponse withdrawPlayer(String playerName, double amount);
@@ -244,16 +189,7 @@ public interface Economy {
public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount);
/**
- * Withdraw an amount from an account associated with a UUID - DO NOT USE NEGATIVE AMOUNTS
- *
- * @param uuid to withdraw from
- * @param amount Amount to withdraw
- * @return Detailed response of transaction
- */
- public EconomyResponse withdraw(UUID uuid, double amount);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} or {@link #withdrawPlayer(UUID, String, double)} instead.
+ * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} instead.
*/
@Deprecated
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount);
@@ -269,17 +205,7 @@ public interface Economy {
public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount);
/**
- * Withdraw an amount from an account associated with a UUID on a given world - DO NOT USE NEGATIVE AMOUNTS
- * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
- * @param uuid to withdraw from
- * @param worldName - name of the world
- * @param amount Amount to withdraw
- * @return Detailed response of transaction
- */
- public EconomyResponse withdraw(UUID uuid, String worldName, double amount);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} or {@link #depositPlayer(UUID, double)} instead.
+ * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} instead.
*/
@Deprecated
public EconomyResponse depositPlayer(String playerName, double amount);
@@ -294,16 +220,7 @@ public interface Economy {
public EconomyResponse depositPlayer(OfflinePlayer player, double amount);
/**
- * Deposit an amount to an account associated with the given UUID - DO NOT USE NEGATIVE AMOUNTS
- *
- * @param uuid to deposit to
- * @param amount Amount to deposit
- * @return Detailed response of transaction
- */
- public EconomyResponse deposit(UUID uuid, double amount);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} or {@link #depositPlayer(UUID, String, double)} instead.
+ * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} instead.
*/
@Deprecated
public EconomyResponse depositPlayer(String playerName, String worldName, double amount);
@@ -320,18 +237,7 @@ public interface Economy {
public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount);
/**
- * Deposit an amount from an account associated with a UUID on a given world - DO NOT USE NEGATIVE AMOUNTS
- * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
- *
- * @param uuid to deposit to
- * @param worldName name of the world
- * @param amount Amount to deposit
- * @return Detailed response of transaction
- */
- public EconomyResponse deposit(UUID uuid, String worldName, double amount);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #createBank(String, OfflinePlayer)} or {@link #createBank(String, UUID)} instead.
+ * @deprecated As of VaultAPI 1.4 use {{@link #createBank(String, OfflinePlayer)} instead.
*/
@Deprecated
public EconomyResponse createBank(String name, String player);
@@ -343,14 +249,6 @@ public interface Economy {
* @return EconomyResponse Object
*/
public EconomyResponse createBank(String name, OfflinePlayer player);
-
- /**
- * Creates a bank account with the specified name and the given UUID as the owner
- * @param name of account
- * @param uuid the account should be linked to
- * @return EconomyResponse Object
- */
- public EconomyResponse createBank(String name, UUID uuid);
/**
* Deletes a bank account with the specified name.
@@ -409,16 +307,7 @@ public interface Economy {
public EconomyResponse isBankOwner(String name, OfflinePlayer player);
/**
- * Check if a uuid is the owner of a bank account
- *
- * @param name of the account
- * @param uuid to check for ownership
- * @return EconomyResponse Object
- */
- public EconomyResponse isBankOwner(String name, UUID uuid);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #isBankMember(String, OfflinePlayer)} or {@link #isBankMember(String, UUID)} instead.
+ * @deprecated As of VaultAPI 1.4 use {{@link #isBankMember(String, OfflinePlayer)} instead.
*/
@Deprecated
public EconomyResponse isBankMember(String name, String playerName);
@@ -431,15 +320,6 @@ public interface Economy {
* @return EconomyResponse Object
*/
public EconomyResponse isBankMember(String name, OfflinePlayer player);
-
- /**
- * Check if the uuid is a member of the bank account
- *
- * @param name of the account
- * @param uuid to check membership
- * @return EconomyResponse Object
- */
- public EconomyResponse isBankMember(String name, UUID uuid);
/**
* Gets the list of banks
@@ -461,14 +341,7 @@ public interface Economy {
public boolean createPlayerAccount(OfflinePlayer player);
/**
- * Attempts to create a account for the given uuid
- * @param uuid associated with the account
- * @return if the account creation was successful
- */
- public boolean createAccount(UUID uuid);
-
- /**
- * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer, String)} or {@link #createPlayerAccount(UUID, String)} instead.
+ * @deprecated As of VaultAPI 1.4 use {{@link #createPlayerAccount(OfflinePlayer, String)} instead.
*/
@Deprecated
public boolean createPlayerAccount(String playerName, String worldName);
@@ -481,13 +354,4 @@ public interface Economy {
* @return if the account creation was successful
*/
public boolean createPlayerAccount(OfflinePlayer player, String worldName);
-
- /**
- * Attempts to create an account for the given UUID on the specified world
- * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then false will always be returned.
- * @param uuid associated with the account
- * @param worldName String name of the world
- * @return if the account creation was successful
- */
- public boolean createAccount(UUID uuid, String worldName);
}
diff --git a/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java b/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java
new file mode 100644
index 0000000..f3bfa5b
--- /dev/null
+++ b/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java
@@ -0,0 +1,324 @@
+/* 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 .
+ */
+
+package net.milkbowl.vault.economy;
+
+import net.milkbowl.vault.economy.wrappers.IdentityEconomyWrapper;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Adds UUID support to the Economy interface.
+ * In case of {@link #supportsAllRecordsOperation()} or {@link #supportsAllOnlineOperation()}
+ * returning true, methods such as
+ * {@link #getAllRecords()} and {@link #getAllOnline()}
+ * should not be expected to work.
+ *
+ * In order to register/provide it, you should use {@link IdentityEconomyWrapper#registerProviders()}
+ */
+public interface IdentityEconomy extends Economy{
+ /**
+ * Used to determine if IdentityEconomy was built through
+ * the EconomyWrapper as a LegacyEconomy.
+ * If false, method {@link #getAllRecords()} will not be work.
+ * This was made in order to support plugins which use older versions of VaultAPI/Vault.
+ * You can also use it / override it to disable previous mentioned methods!
+ * @return true if operation is supported
+ */
+ public boolean supportsAllRecordsOperation();
+
+ /**
+ * Used to determine if IdentityEconomy was built through
+ * the EconomyWrapper as a LegacyEconomy.
+ * If false, the method {@link #getAllOnline()} (UUID)} will not be work.
+ * This was made in order to support plugins which use older versions of VaultAPI/Vault.
+ * You can also use it / override it to disable previous mentioned methods!
+ * @return true if operation is supported
+ */
+ public boolean supportsAllOnlineOperation();
+
+ /**
+ * Used to determine if IdentityEconomy was built through
+ * the EconomyWrapper as a LegacyEconomy.
+ * If false, all operations must be done with players that
+ * are online/connected to the server in real time.
+ * If true, you should expect to call these operations
+ * asynchronously.
+ * @return true if operation is supported
+ */
+ public boolean supportsOfflineOperations();
+
+ /**
+ * Used to determine if IdentityEconomy was built through
+ * the EconomyWrapper as a LegacyEconomy.
+ * If false, you should expect UnsupportedOperationException
+ * being thrown when calling these methods.
+ * @return true if operation is supported
+ */
+ public boolean supportsUUIDOperations();
+
+ /*
+ * Account-related methods follow.
+ */
+
+ /**
+ * Attempts to create a account for the given uuid
+ *
+ * @param uuid associated with the account
+ * @param name associated with the account.
+ * @return if the account creation was successful
+ */
+ public boolean createAccount(UUID uuid, String name);
+
+ /**
+ * Attempts to create an account for the given UUID on the specified world
+ * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then
+ * false will always be returned.
+ *
+ * @param uuid associated with the account
+ * @param name associated with the account.
+ * @param worldName String name of the world
+ * @return if the account creation was successful
+ */
+ public boolean createAccount(UUID uuid, String name, String worldName);
+
+ /**
+ * Returns a map that represents all of the stored UUIDs which have accounts in the
+ * plugin (in the database, not memory), as well as their last-known-name. This is used for Vault's economy
+ * converter and should be given every account available.
+ * Needs IdentityEconomy#hasUUIDSupport() to be true.
+ *
+ * @return a {@link Map} composed of the accounts keyed by their UUID, along
+ * with their associated last-known-name.
+ */
+ public Map getAllRecords();
+
+ /**
+ * Returns a collection of all UUIDs which have accounts in the plugin and are currently
+ * online/connected to the server.
+ * This is used for Vault's economy converter and should
+ * Needs IdentityEconomy#hasUUIDSupport() to be true.
+ * @return a {@link Collection} of all UUIDs which have accounts in the plugin
+ */
+ public Collection getAllOnline();
+
+ /**
+ * Gets the last known name of an account owned by the given UUID. Required for
+ * messages to be more human-readable than UUIDs alone can provide.
+ *
+ * @param uuid UUID to look up.
+ */
+ public String getAccountName(UUID uuid);
+
+ /**
+ * Checks if this uuid has an account yet
+ *
+ * @param uuid to check
+ * @return if the uuid has an account
+ */
+ public boolean hasAccount(UUID uuid);
+
+ /**
+ * Checks if this uuid has an account yet on the given world
+ *
+ * @param uuid to check
+ * @param worldName world-specific account
+ * @return if the uuid has an account
+ */
+ public boolean hasAccount(UUID uuid, String worldName);
+
+ /**
+ * A method which changes the name associated with the given UUID in the
+ * Map received from {@link #getAllRecords()}
+ *
+ * @param uuid which is having a name change.
+ * @param name name that will be associated with the UUID in the
+ * Map map.
+ * @return true if the name change is successful.
+ */
+ public boolean renameAccount(UUID uuid, String name);
+
+ /**
+ * Gets balance of a UUID
+ *
+ * @param uuid of the account to get a balance for
+ * @return Amount currently held in account associated with the given UUID
+ */
+ public double getBalance(UUID uuid);
+
+ /**
+ * Gets balance of a UUID on the specified world. IMPLEMENTATION SPECIFIC - if
+ * an economy plugin does not support this the global balance will be returned.
+ *
+ * @param uuid of the account to get a balance for
+ * @param world name of the world
+ * @return Amount currently held in account associated with the given UUID
+ */
+ public double getBalance(UUID uuid, String world);
+
+ /**
+ * Checks if the account associated with the given UUID has the amount - DO NOT
+ * USE NEGATIVE AMOUNTS
+ *
+ * @param uuid to check
+ * @param amount to check for
+ * @return True if UUID has amount, False else wise
+ */
+ public boolean has(UUID uuid, double amount);
+
+ /**
+ * Checks if the account associated with the given UUID has the amount in the
+ * given world - DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an
+ * economy plugin does not support this the global balance will be returned.
+ *
+ * @param uuid to check
+ * @param worldName to check with
+ * @param amount to check for
+ * @return True if UUID has amount in the given world,
+ * False else wise
+ */
+ public boolean has(UUID uuid, String worldName, double amount);
+
+ /**
+ * Withdraw an amount from an account associated with a UUID - DO NOT USE
+ * NEGATIVE AMOUNTS
+ *
+ * @param uuid to withdraw from
+ * @param amount Amount to withdraw
+ * @return Detailed response of transaction
+ */
+ public EconomyResponse withdraw(UUID uuid, double amount);
+
+ /**
+ * Withdraw an amount from an account associated with a UUID on a given world -
+ * DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an economy plugin
+ * does not support this the global balance will be returned.
+ *
+ * @param uuid to withdraw from
+ * @param worldName - name of the world
+ * @param amount Amount to withdraw
+ * @return Detailed response of transaction
+ */
+ public EconomyResponse withdraw(UUID uuid, String worldName, double amount);
+
+ /**
+ * Deposit an amount to an account associated with the given UUID - DO NOT USE
+ * NEGATIVE AMOUNTS
+ *
+ * @param uuid to deposit to
+ * @param amount Amount to deposit
+ * @return Detailed response of transaction
+ */
+ public EconomyResponse deposit(UUID uuid, double amount);
+
+ /**
+ * Deposit an amount from an account associated with a UUID on a given world -
+ * DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an economy plugin
+ * does not support this the global balance will be returned.
+ *
+ * @param uuid to deposit to
+ * @param worldName name of the world
+ * @param amount Amount to deposit
+ * @return Detailed response of transaction
+ */
+ public EconomyResponse deposit(UUID uuid, String worldName, double amount);
+
+ /*
+ * Bank methods follow.
+ */
+
+ /**
+ * Creates a bank account with the specified name and the given UUID as the
+ * owner
+ *
+ * @param name of account
+ * @param uuid the account should be linked to
+ * @return EconomyResponse Object
+ */
+ public EconomyResponse createBank(String name, UUID uuid);
+
+ /**
+ * Deletes a bank account with the specified name.
+ *
+ * @param name of the back to delete
+ * @return if the operation completed successfully
+ */
+ public EconomyResponse deleteBank(String name);
+
+ /**
+ * Returns the amount the bank has
+ *
+ * @param name of the account
+ * @return EconomyResponse Object
+ */
+ public EconomyResponse bankBalance(String name);
+
+ /**
+ * Returns true or false whether the bank has the amount specified - DO NOT USE
+ * NEGATIVE AMOUNTS
+ *
+ * @param name of the account
+ * @param amount to check for
+ * @return EconomyResponse Object
+ */
+ public EconomyResponse bankHas(String name, double amount);
+
+ /**
+ * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS
+ *
+ * @param name of the account
+ * @param amount to withdraw
+ * @return EconomyResponse Object
+ */
+ public EconomyResponse bankWithdraw(String name, double amount);
+
+ /**
+ * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS
+ *
+ * @param name of the account
+ * @param amount to deposit
+ * @return EconomyResponse Object
+ */
+ public EconomyResponse bankDeposit(String name, double amount);
+
+ /**
+ * Check if a uuid is the owner of a bank account
+ *
+ * @param name of the account
+ * @param uuid to check for ownership
+ * @return EconomyResponse Object
+ */
+ public EconomyResponse isBankOwner(String name, UUID uuid);
+
+ /**
+ * Check if the uuid is a member of the bank account
+ *
+ * @param name of the account
+ * @param uuid to check membership
+ * @return EconomyResponse Object
+ */
+ public EconomyResponse isBankMember(String name, UUID uuid);
+
+ /**
+ * Gets the list of banks
+ *
+ * @return the List of Banks
+ */
+ public List getBanks();
+}
diff --git a/src/main/java/net/milkbowl/vault/economy/LegacyEconomy.java b/src/main/java/net/milkbowl/vault/economy/LegacyEconomy.java
new file mode 100644
index 0000000..cfedf6c
--- /dev/null
+++ b/src/main/java/net/milkbowl/vault/economy/LegacyEconomy.java
@@ -0,0 +1,345 @@
+package net.milkbowl.vault.economy;
+
+import org.bukkit.OfflinePlayer;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public class LegacyEconomy implements IdentityEconomy {
+ private final Economy economy;
+ public LegacyEconomy(Economy economy){
+ this.economy = economy;
+ }
+
+ @Override
+ public boolean supportsAllRecordsOperation() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAllOnlineOperation() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOfflineOperations(){
+ return false;
+ }
+
+ @Override
+ public boolean supportsUUIDOperations(){
+ return false;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return economy.isEnabled();
+ }
+
+ @Override
+ public String getName() {
+ return economy.getName();
+ }
+
+ @Override
+ public boolean hasBankSupport() {
+ return economy.hasBankSupport();
+ }
+
+ @Override
+ public int fractionalDigits() {
+ return economy.fractionalDigits();
+ }
+
+ @Override
+ public String format(double amount) {
+ return economy.format(amount);
+ }
+
+ @Override
+ public String currencyNamePlural() {
+ return economy.currencyNamePlural();
+ }
+
+ @Override
+ public String currencyNameSingular() {
+ return economy.currencyNameSingular();
+ }
+
+ @Override
+ public boolean hasAccount(String playerName) {
+ return economy.hasAccount(playerName);
+ }
+
+ @Override
+ public boolean hasAccount(OfflinePlayer player) {
+ return economy.hasAccount(player);
+ }
+
+ @Override
+ public boolean hasAccount(String playerName, String worldName) {
+ return economy.hasAccount(playerName, worldName);
+ }
+
+ @Override
+ public boolean hasAccount(OfflinePlayer player, String worldName) {
+ return economy.hasAccount(player, worldName);
+ }
+
+ @Override
+ public double getBalance(String playerName) {
+ return economy.getBalance(playerName);
+ }
+
+ @Override
+ public double getBalance(OfflinePlayer player) {
+ return economy.getBalance(player);
+ }
+
+ @Override
+ public double getBalance(String playerName, String world) {
+ return economy.getBalance(playerName, world);
+ }
+
+ @Override
+ public double getBalance(OfflinePlayer player, String world) {
+ return economy.getBalance(player, world);
+ }
+
+ @Override
+ public boolean has(String playerName, double amount) {
+ return economy.has(playerName, amount);
+ }
+
+ @Override
+ public boolean has(OfflinePlayer player, double amount) {
+ return economy.has(player, amount);
+ }
+
+ @Override
+ public boolean has(String playerName, String worldName, double amount) {
+ return economy.has(playerName, worldName, amount);
+ }
+
+ @Override
+ public boolean has(OfflinePlayer player, String worldName, double amount) {
+ return economy.has(player, worldName, amount);
+ }
+
+ @Override
+ public EconomyResponse withdrawPlayer(String playerName, double amount) {
+ return economy.withdrawPlayer(playerName, amount);
+ }
+
+ @Override
+ public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) {
+ return economy.withdrawPlayer(player, amount);
+ }
+
+ @Override
+ public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
+ return economy.withdrawPlayer(playerName, worldName, amount);
+ }
+
+ @Override
+ public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount) {
+ return economy.withdrawPlayer(player, worldName, amount);
+ }
+
+ @Override
+ public EconomyResponse depositPlayer(String playerName, double amount) {
+ return economy.depositPlayer(playerName, amount);
+ }
+
+ @Override
+ public EconomyResponse depositPlayer(OfflinePlayer player, double amount) {
+ return economy.depositPlayer(player, amount);
+ }
+
+ @Override
+ public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
+ return economy.depositPlayer(playerName, worldName, amount);
+ }
+
+ @Override
+ public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount) {
+ return economy.depositPlayer(player, worldName, amount);
+ }
+
+ @Override
+ public EconomyResponse createBank(String name, String player) {
+ return economy.createBank(name, player);
+ }
+
+ @Override
+ public EconomyResponse createBank(String name, OfflinePlayer player) {
+ return economy.createBank(name, player);
+ }
+
+ @Override
+ public EconomyResponse isBankOwner(String name, String playerName) {
+ return economy.isBankOwner(name, playerName);
+ }
+
+ @Override
+ public EconomyResponse isBankOwner(String name, OfflinePlayer player) {
+ return economy.isBankOwner(name, player);
+ }
+
+ @Override
+ public EconomyResponse isBankMember(String name, String playerName) {
+ return economy.isBankMember(name, playerName);
+ }
+
+ @Override
+ public EconomyResponse isBankMember(String name, OfflinePlayer player) {
+ return economy.isBankMember(name, player);
+ }
+
+ @Override
+ public boolean createPlayerAccount(String playerName) {
+ return economy.createPlayerAccount(playerName);
+ }
+
+ @Override
+ public boolean createPlayerAccount(OfflinePlayer player) {
+ return economy.createPlayerAccount(player);
+ }
+
+ @Override
+ public boolean createPlayerAccount(String playerName, String worldName) {
+ return economy.createPlayerAccount(playerName, worldName);
+ }
+
+ @Override
+ public boolean createPlayerAccount(OfflinePlayer player, String worldName) {
+ return economy.createPlayerAccount(player, worldName);
+ }
+
+ @Override
+ public boolean createAccount(UUID uuid, String name) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public boolean createAccount(UUID uuid, String name, String worldName) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public Map getAllRecords() {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public Collection getAllOnline() {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public String getAccountName(UUID uuid) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public boolean hasAccount(UUID uuid) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public boolean hasAccount(UUID uuid, String worldName) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public boolean renameAccount(UUID uuid, String name) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public double getBalance(UUID uuid) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public double getBalance(UUID uuid, String world) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public boolean has(UUID uuid, double amount) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public boolean has(UUID uuid, String worldName, double amount) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public EconomyResponse withdraw(UUID uuid, double amount) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public EconomyResponse withdraw(UUID uuid, String worldName, double amount) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public EconomyResponse deposit(UUID uuid, double amount) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public EconomyResponse deposit(UUID uuid, String worldName, double amount) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public EconomyResponse createBank(String name, UUID uuid) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public EconomyResponse deleteBank(String name) {
+ return economy.deleteBank(name);
+ }
+
+ @Override
+ public EconomyResponse bankBalance(String name) {
+ return economy.bankBalance(name);
+ }
+
+ @Override
+ public EconomyResponse bankHas(String name, double amount) {
+ return economy.bankHas(name, amount);
+ }
+
+ @Override
+ public EconomyResponse bankWithdraw(String name, double amount) {
+ return economy.bankWithdraw(name, amount);
+ }
+
+ @Override
+ public EconomyResponse bankDeposit(String name, double amount) {
+ return economy.bankDeposit(name, amount);
+ }
+
+ @Override
+ public EconomyResponse isBankOwner(String name, UUID uuid) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public EconomyResponse isBankMember(String name, UUID uuid) {
+ throw new UnsupportedOperationException("LegacyEconomy! Not supported.");
+ }
+
+ @Override
+ public List getBanks() {
+ return economy.getBanks();
+ }
+}
diff --git a/src/main/java/net/milkbowl/vault/economy/MultiEconomy.java b/src/main/java/net/milkbowl/vault/economy/MultiEconomy.java
new file mode 100644
index 0000000..1328e9a
--- /dev/null
+++ b/src/main/java/net/milkbowl/vault/economy/MultiEconomy.java
@@ -0,0 +1,114 @@
+package net.milkbowl.vault.economy;
+
+import net.milkbowl.vault.economy.wrappers.MultiEconomyWrapper;
+import org.bukkit.World;
+
+import java.util.Collection;
+
+/**
+ * This interface is used to provide multi-world, multi-currency support for the economy.
+ * It allows disabling currencies/economies.
+ * It forces currencies to support UUIDs.
+ *
+ * In order to register/provide it, you should use {@link MultiEconomyWrapper#registerProviders()}
+ * Inside this interface, we make use of the term "implementation" to refer to an actual currency.
+ * You should expect that these currencies/implementations might
+ * return false for both {@link IdentityEconomy#supportsAllRecordsOperation()} and
+ * {@link IdentityEconomy#supportsAllOnlineOperation()} in case of plugin's author preference!
+ */
+public interface MultiEconomy {
+
+ /**
+ * Checks if MultiEconomy method is enabled.
+ *
+ * @return Success or Failure
+ */
+ public boolean isEnabled();
+
+ /**
+ * Gets name of MultiEconomy method
+ *
+ * @return Name of Economy Method
+ */
+ public String getName();
+
+ /**
+ * Checks to see if a name of the implementation exists with this name.
+ *
+ * @param name The name of the name of the implementation to search for.
+ * @return True if the implementation exists, else false.
+ */
+ public boolean existsImplementation(String name);
+
+ /**
+ * Checks to see if a name of the implementation exists with this name.
+ *
+ * @param name The name of the name of the implementation to search for.
+ * @param world The name of the {@link World} to check for this name of the implementation in.
+ * @return True if the implementation exists, else false.
+ */
+ public boolean existsImplementation(String name, String world);
+
+ /**
+ * Used to get the implementation with the specified name.
+ *
+ * @param name The name of the implementation to get.
+ * @return The implementation with the specified name.
+ */
+ public IdentityEconomy getImplementation(String name);
+
+ /**
+ * Used to get the default implementation. This could be the default implementation for the server globally or
+ * for the default world if the implementation supports multi-world.
+ *
+ * @return The implementation that is the default for the server if multi-world support is not available
+ * otherwise the default for the default world.
+ */
+ public IdentityEconomy getDefault();
+
+ /**
+ * Checks to see if the default implementation is not null.
+ *
+ * @return True if the default implementation is not null, else false.
+ */
+ public default boolean hasDefault() {
+ return getDefault() != null;
+ }
+
+ /**
+ * Used to get the default implementation for the specified world if this implementation has multi-world
+ * support, otherwise the default implementation for the server.
+ *
+ * @param world The world to get the default implementation for.
+ * @return The default implementation for the specified world if this implementation has multi-world
+ * support, otherwise the default implementation for the server.
+ */
+ public IdentityEconomy getDefault(String world);
+
+ /**
+ * Checks to see if the default implementation for the specified world is not null.
+ *
+ * @param world The world to check the default implementation for.
+ * @return True if the default implementation for the specified world is not null, else false.
+ */
+ public default boolean hasDefault(String world) {
+ return getDefault(world) != null;
+ }
+
+ /**
+ * Used to get a collection of every implementation identifier for the server.
+ *
+ * @return A collection of every implementation identifier that is available for the server.
+ */
+ public Collection getAllImplementations();
+
+ /**
+ * Used to get a collection of every {@link IdentityEconomy} object that is available in the specified world if
+ * this implementation has multi-world support, otherwise all {@link IdentityEconomy} objects for the server.
+ *
+ * @param world The world we want to get the {@link IdentityEconomy} objects for.
+ * @return A collection of every implementation identifier that is available in the specified world if
+ * this implementation has multi-world support, otherwise all implementation identifiers for the server.
+ */
+ public Collection getAllImplementations(String world);
+}
\ No newline at end of file
diff --git a/src/main/java/net/milkbowl/vault/economy/wrappers/EconomyWrapper.java b/src/main/java/net/milkbowl/vault/economy/wrappers/EconomyWrapper.java
new file mode 100644
index 0000000..271f112
--- /dev/null
+++ b/src/main/java/net/milkbowl/vault/economy/wrappers/EconomyWrapper.java
@@ -0,0 +1,55 @@
+package net.milkbowl.vault.economy.wrappers;
+
+import net.milkbowl.vault.economy.Economy;
+import net.milkbowl.vault.economy.IdentityEconomy;
+import net.milkbowl.vault.economy.LegacyEconomy;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.ServicePriority;
+import org.bukkit.plugin.ServicesManager;
+
+public class EconomyWrapper {
+ private final Economy economy;
+ public EconomyWrapper(Economy economy){
+ this.economy = economy;
+ }
+
+ /**
+ * Will convert the Economy to a new IdentityEconomy
+ * which IdentityEconomy#isLegacy() returns true.
+ * Methods regarding UUID will fail fast.
+ * @return a legacy economy
+ */
+ public LegacyEconomy legacy(){
+ return new LegacyEconomy(economy);
+ }
+
+ /**
+ * Will register IdentityEconomy and legacy Economy to Vault
+ * @param force if true, will override existing Economy and IdentityEconomy providers
+ * @return true if registered successfully, false if already registered
+ */
+ public boolean registerProviders(boolean force){
+ ServicesManager manager = Bukkit.getServicesManager();
+ if (!force){
+ if (manager.isProvidedFor(IdentityEconomy.class))
+ return false;
+ if (manager.isProvidedFor(Economy.class))
+ return false;
+ }
+ LegacyEconomy legacy = legacy();
+ manager.register(IdentityEconomy.class, legacy,
+ Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
+ manager.register(Economy.class, economy,
+ Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
+ return true;
+ }
+
+ /**
+ * Will register IdentityEconomy and legacy Economy to Vault
+ * If any provider is already registered, it won't proceed
+ * @return true if registered successfully, false if already registered
+ */
+ public boolean registerProviders(){
+ return registerProviders(false);
+ }
+}
diff --git a/src/main/java/net/milkbowl/vault/economy/wrappers/IdentityEconomyWrapper.java b/src/main/java/net/milkbowl/vault/economy/wrappers/IdentityEconomyWrapper.java
new file mode 100644
index 0000000..7ba8ce1
--- /dev/null
+++ b/src/main/java/net/milkbowl/vault/economy/wrappers/IdentityEconomyWrapper.java
@@ -0,0 +1,44 @@
+package net.milkbowl.vault.economy.wrappers;
+
+import net.milkbowl.vault.economy.Economy;
+import net.milkbowl.vault.economy.IdentityEconomy;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.ServicePriority;
+import org.bukkit.plugin.ServicesManager;
+
+public class IdentityEconomyWrapper {
+ private final IdentityEconomy economy;
+
+ public IdentityEconomyWrapper(IdentityEconomy economy){
+ this.economy = economy;
+ }
+
+ /**
+ * Will register IdentityEconomy and legacy Economy to Vault
+ * @param force if true, will override existing Economy and IdentityEconomy providers
+ * @return true if registered successfully, false if already registered
+ */
+ public boolean registerProviders(boolean force){
+ ServicesManager manager = Bukkit.getServicesManager();
+ if (!force){
+ if (manager.isProvidedFor(IdentityEconomy.class))
+ return false;
+ if (manager.isProvidedFor(Economy.class))
+ return false;
+ }
+ manager.register(IdentityEconomy.class, economy,
+ Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
+ manager.register(Economy.class, economy,
+ Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
+ return true;
+ }
+
+ /**
+ * Will register IdentityEconomy and legacy Economy to Vault
+ * If any provider is already registered, it won't proceed
+ * @return true if registered successfully, false if already registered
+ */
+ public boolean registerProviders(){
+ return registerProviders(false);
+ }
+}
diff --git a/src/main/java/net/milkbowl/vault/economy/wrappers/MultiEconomyWrapper.java b/src/main/java/net/milkbowl/vault/economy/wrappers/MultiEconomyWrapper.java
new file mode 100644
index 0000000..f4988dc
--- /dev/null
+++ b/src/main/java/net/milkbowl/vault/economy/wrappers/MultiEconomyWrapper.java
@@ -0,0 +1,48 @@
+package net.milkbowl.vault.economy.wrappers;
+
+import net.milkbowl.vault.economy.Economy;
+import net.milkbowl.vault.economy.IdentityEconomy;
+import net.milkbowl.vault.economy.MultiEconomy;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.ServicePriority;
+import org.bukkit.plugin.ServicesManager;
+
+public class MultiEconomyWrapper {
+ private final MultiEconomy economy;
+
+ public MultiEconomyWrapper(MultiEconomy economy){
+ this.economy = economy;
+ }
+
+ /**
+ * Will register MultiEconomy, IdentityEconomy and legacy Economy to Vault
+ * @param force if true, will override existing Economy, IdentityEconomy and MultiEconomy providers
+ * @return true if registered successfully, false if already registered
+ */
+ public boolean registerProviders(boolean force){
+ ServicesManager manager = Bukkit.getServicesManager();
+ if (!force){
+ if (manager.isProvidedFor(MultiEconomy.class))
+ return false;
+ if (manager.isProvidedFor(IdentityEconomy.class))
+ return false;
+ if (manager.isProvidedFor(Economy.class))
+ return false;
+ }
+ manager.register(MultiEconomy.class, economy,
+ Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
+ manager.register(IdentityEconomy.class, economy.getDefault(),
+ Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
+ manager.register(Economy.class, economy.getDefault(),
+ Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
+ return true;
+ }
+ /**
+ * Will register MultiEconomy, IdentityEconomy and legacy Economy to Vault
+ * If any provider is already registered, it won't proceed
+ * @return true if registered successfully, false if already registered
+ */
+ public boolean registerProviders(){
+ return registerProviders(false);
+ }
+}