From 5c61077842c0a0f781f554dedd09959ad693bf0e Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Sun, 4 Apr 2021 10:32:25 -0500 Subject: [PATCH 01/44] Add UUID support to Vault. This commit adds UUID support to Vault, allowing plugins to bypass the OfflinePlayer methods which result in Bukkit trying to resolve a player to associate with the OfflinePlayer (via the server playercache and if that player doesn't exist via Mojang.) This is incredibly useful for any plugin which wants to have an Economy account that isn't associated with a player. This includes Towny, Factions, Shops plugins and others. Most importantly: having UUID methods will give these plugins an avenue to update from using the String accountName methods deprecated since Vault 1.4, which doesn't result in slow OfflinePlayer creation. AbstractEconomy has been updated so that the various Economy plugins supported internally by Vault will have support for the new methods in the same manner as when the OfflinePlayer methods were added. Small javadoc typos have also been fixed up (extra {'s, an additional {@link, etc.) --- pom.xml | 2 +- .../vault/economy/AbstractEconomy.java | 85 ++++++++- .../net/milkbowl/vault/economy/Economy.java | 170 ++++++++++++++++-- 3 files changed, 237 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 959b534..5c8c467 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.milkbowl.vault VaultAPI - 1.7 + 1.8 VaultAPI Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves. diff --git a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java b/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java index 4fe0e37..c5ec32e 100644 --- a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java +++ b/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java @@ -1,5 +1,8 @@ package net.milkbowl.vault.economy; +import java.util.UUID; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @SuppressWarnings("deprecation") @@ -16,6 +19,18 @@ public boolean hasAccount(OfflinePlayer player, String worldName) { if (player.getName() == null) return false; return hasAccount(player.getName(), worldName); } + + @Override + public boolean hasAccount(UUID uuid) { + if (uuid == null) return false; + return hasAccount(Bukkit.getOfflinePlayer(uuid)); + } + + @Override + public boolean hasAccount(UUID uuid, String worldName) { + if (uuid == null) return false; + return hasAccount(Bukkit.getOfflinePlayer(uuid), worldName); + } @Override public double getBalance(OfflinePlayer player) { @@ -23,8 +38,18 @@ public double getBalance(OfflinePlayer player) { } @Override - public double getBalance(OfflinePlayer player, String world) { - return getBalance(player.getName(), world); + public double getBalance(OfflinePlayer player, String worldName) { + return getBalance(player.getName(), worldName); + } + + @Override + public double getBalance(UUID uuid) { + return getBalance(Bukkit.getOfflinePlayer(uuid)); + } + + @Override + public double getBalance(UUID uuid, String worldName) { + return getBalance(Bukkit.getOfflinePlayer(uuid), worldName); } @Override @@ -38,6 +63,18 @@ public boolean has(OfflinePlayer player, String worldName, double amount) { if (player.getName() == null) return false; return has(player.getName(), worldName, amount); } + + @Override + public boolean has(UUID uuid, double amount) { + if (uuid == null) return false; + return has(Bukkit.getOfflinePlayer(uuid), amount); + } + + @Override + public boolean has(UUID uuid, String worldName, double amount) { + if (uuid == null) return false; + return has(Bukkit.getOfflinePlayer(uuid), worldName, amount); + } @Override public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) { @@ -49,6 +86,16 @@ public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, do return withdrawPlayer(player.getName(), worldName, amount); } + @Override + public EconomyResponse withdrawPlayer(UUID uuid, double amount) { + return withdrawPlayer(Bukkit.getOfflinePlayer(uuid), amount); + } + + @Override + public EconomyResponse withdrawPlayer(UUID uuid, String worldName, double amount) { + return withdrawPlayer(Bukkit.getOfflinePlayer(uuid), worldName, amount); + } + @Override public EconomyResponse depositPlayer(OfflinePlayer player, double amount) { return depositPlayer(player.getName(), amount); @@ -59,20 +106,45 @@ public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, dou return depositPlayer(player.getName(), worldName, amount); } + @Override + public EconomyResponse depositPlayer(UUID uuid, double amount) { + return depositPlayer(Bukkit.getOfflinePlayer(uuid), amount); + } + + @Override + public EconomyResponse depositPlayer(UUID uuid, String worldName, double amount) { + return depositPlayer(Bukkit.getOfflinePlayer(uuid), worldName, amount); + } + @Override public EconomyResponse createBank(String name, OfflinePlayer player) { return createBank(name, player.getName()); } + + @Override + public EconomyResponse createBank(String name, UUID uuid) { + return createBank(name, Bukkit.getOfflinePlayer(uuid)); + } @Override public EconomyResponse isBankOwner(String name, OfflinePlayer player) { return isBankOwner(name, player.getName()); } + + @Override + public EconomyResponse isBankOwner(String name, UUID uuid) { + return isBankOwner(name, Bukkit.getOfflinePlayer(uuid)); + } @Override public EconomyResponse isBankMember(String name, OfflinePlayer player) { return isBankMember(name, player.getName()); } + + @Override + public EconomyResponse isBankMember(String name, UUID uuid ) { + return isBankMember(name, Bukkit.getOfflinePlayer(uuid)); + } @Override public boolean createPlayerAccount(OfflinePlayer player) { @@ -84,4 +156,13 @@ public boolean createPlayerAccount(OfflinePlayer player, String worldName) { return createPlayerAccount(player.getName(), worldName); } + @Override + public boolean createPlayerAccount(UUID uuid) { + return createPlayerAccount(Bukkit.getOfflinePlayer(uuid)); + } + + @Override + public boolean createPlayerAccount(UUID uuid, String worldName) { + return createPlayerAccount(Bukkit.getOfflinePlayer(uuid), worldName); + } } diff --git a/src/main/java/net/milkbowl/vault/economy/Economy.java b/src/main/java/net/milkbowl/vault/economy/Economy.java index 1d14587..5182654 100644 --- a/src/main/java/net/milkbowl/vault/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault/economy/Economy.java @@ -17,6 +17,7 @@ package net.milkbowl.vault.economy; import java.util.List; +import java.util.UUID; import org.bukkit.OfflinePlayer; @@ -80,7 +81,7 @@ public interface Economy { /** * - * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} or {@link #hasAccount(UUID)} instead. */ @Deprecated public boolean hasAccount(String playerName); @@ -96,7 +97,15 @@ public interface Economy { public boolean hasAccount(OfflinePlayer player); /** - * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} instead. + * 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 public boolean hasAccount(String playerName, String worldName); @@ -113,7 +122,16 @@ public interface Economy { public boolean hasAccount(OfflinePlayer player, String worldName); /** - * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} instead. + * 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 public double getBalance(String playerName); @@ -127,7 +145,15 @@ public interface Economy { public double getBalance(OfflinePlayer player); /** - * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} instead. + * 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 public double getBalance(String playerName, String world); @@ -142,7 +168,16 @@ public interface Economy { public double getBalance(OfflinePlayer player, String world); /** - * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} instead. + * 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 public boolean has(String playerName, double amount); @@ -157,7 +192,16 @@ public interface Economy { public boolean has(OfflinePlayer player, double amount); /** - * @deprecated As of VaultAPI 1.4 use @{link {@link #has(OfflinePlayer, String, double)} instead. + * 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 public boolean has(String playerName, String worldName, double amount); @@ -169,12 +213,23 @@ public interface Economy { * @param player to check * @param worldName to check with * @param amount to check for - * @return True if player has amount, False else wise + * @return True if player has amount in the given world, False else wise */ public boolean has(OfflinePlayer player, String worldName, double amount); /** - * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} instead. + * 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 public EconomyResponse withdrawPlayer(String playerName, double amount); @@ -189,7 +244,16 @@ public interface Economy { public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount); /** - * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} instead. + * 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 withdrawPlayer(UUID uuid, double amount); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} or {@link #withdrawPlayer(UUID, String, double)} instead. */ @Deprecated public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount); @@ -205,7 +269,17 @@ public interface Economy { public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount); /** - * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} instead. + * 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 withdrawPlayer(UUID uuid, String worldName, double amount); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} or {@link #depositPlayer(UUID, double)} instead. */ @Deprecated public EconomyResponse depositPlayer(String playerName, double amount); @@ -220,13 +294,22 @@ public interface Economy { public EconomyResponse depositPlayer(OfflinePlayer player, double amount); /** - * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} instead. + * 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 depositPlayer(UUID uuid, double amount); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} or {@link #depositPlayer(UUID, String, double)} instead. */ @Deprecated public EconomyResponse depositPlayer(String playerName, String worldName, double amount); /** - * Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS + * Deposit an amount to a player 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 player to deposit to @@ -237,7 +320,18 @@ public interface Economy { public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount); /** - * @deprecated As of VaultAPI 1.4 use {{@link #createBank(String, OfflinePlayer)} instead. + * 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 depositPlayer(UUID uuid, String worldName, double amount); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #createBank(String, OfflinePlayer)} or {@link #createBank(String, UUID)} instead. */ @Deprecated public EconomyResponse createBank(String name, String player); @@ -249,6 +343,14 @@ 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. @@ -292,7 +394,7 @@ public interface Economy { public EconomyResponse bankDeposit(String name, double amount); /** - * @deprecated As of VaultAPI 1.4 use {{@link #isBankOwner(String, OfflinePlayer)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #isBankOwner(String, OfflinePlayer)} or {@link #isBankOwner(String, UUID)} instead. */ @Deprecated public EconomyResponse isBankOwner(String name, String playerName); @@ -305,9 +407,18 @@ public interface Economy { * @return EconomyResponse Object */ 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)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #isBankMember(String, OfflinePlayer)} or {@link #isBankMember(String, UUID)} instead. */ @Deprecated public EconomyResponse isBankMember(String name, String playerName); @@ -320,6 +431,15 @@ 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 @@ -328,7 +448,7 @@ public interface Economy { public List getBanks(); /** - * @deprecated As of VaultAPI 1.4 use {{@link #createPlayerAccount(OfflinePlayer)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer)} or {@link #createPlayerAccount(UUID)} instead. */ @Deprecated public boolean createPlayerAccount(String playerName); @@ -341,7 +461,14 @@ public interface Economy { public boolean createPlayerAccount(OfflinePlayer player); /** - * @deprecated As of VaultAPI 1.4 use {{@link #createPlayerAccount(OfflinePlayer, String)} instead. + * Attempts to create a account for the given uuid + * @param uuid associated with the account + * @return if the account creation was successful + */ + public boolean createPlayerAccount(UUID uuid); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer, String)} or {@link #createPlayerAccount(UUID, String)} instead. */ @Deprecated public boolean createPlayerAccount(String playerName, String worldName); @@ -354,4 +481,13 @@ 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 createPlayerAccount(UUID uuid, String worldName); } From 747940c8c63cc459c0a754aa7daa0294e4847cb6 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Tue, 28 Sep 2021 09:20:52 -0500 Subject: [PATCH 02/44] Improve UUID methods' names, dropping the word Player. These methods are meant for players, non-players and anything with a UUID. --- .../net/milkbowl/vault/economy/AbstractEconomy.java | 12 ++++++------ .../java/net/milkbowl/vault/economy/Economy.java | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java b/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java index c5ec32e..af60bc2 100644 --- a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java +++ b/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java @@ -87,12 +87,12 @@ public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, do } @Override - public EconomyResponse withdrawPlayer(UUID uuid, double amount) { + public EconomyResponse withdraw(UUID uuid, double amount) { return withdrawPlayer(Bukkit.getOfflinePlayer(uuid), amount); } @Override - public EconomyResponse withdrawPlayer(UUID uuid, String worldName, double amount) { + public EconomyResponse withdraw(UUID uuid, String worldName, double amount) { return withdrawPlayer(Bukkit.getOfflinePlayer(uuid), worldName, amount); } @@ -107,12 +107,12 @@ public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, dou } @Override - public EconomyResponse depositPlayer(UUID uuid, double amount) { + public EconomyResponse deposit(UUID uuid, double amount) { return depositPlayer(Bukkit.getOfflinePlayer(uuid), amount); } @Override - public EconomyResponse depositPlayer(UUID uuid, String worldName, double amount) { + public EconomyResponse deposit(UUID uuid, String worldName, double amount) { return depositPlayer(Bukkit.getOfflinePlayer(uuid), worldName, amount); } @@ -157,12 +157,12 @@ public boolean createPlayerAccount(OfflinePlayer player, String worldName) { } @Override - public boolean createPlayerAccount(UUID uuid) { + public boolean createAccount(UUID uuid) { return createPlayerAccount(Bukkit.getOfflinePlayer(uuid)); } @Override - public boolean createPlayerAccount(UUID uuid, String worldName) { + public boolean createAccount(UUID uuid, String worldName) { return createPlayerAccount(Bukkit.getOfflinePlayer(uuid), worldName); } } diff --git a/src/main/java/net/milkbowl/vault/economy/Economy.java b/src/main/java/net/milkbowl/vault/economy/Economy.java index 5182654..a1b3ed9 100644 --- a/src/main/java/net/milkbowl/vault/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault/economy/Economy.java @@ -250,7 +250,7 @@ public interface Economy { * @param amount Amount to withdraw * @return Detailed response of transaction */ - public EconomyResponse withdrawPlayer(UUID uuid, double amount); + 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. @@ -276,7 +276,7 @@ public interface Economy { * @param amount Amount to withdraw * @return Detailed response of transaction */ - public EconomyResponse withdrawPlayer(UUID uuid, String worldName, double amount); + 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. @@ -300,7 +300,7 @@ public interface Economy { * @param amount Amount to deposit * @return Detailed response of transaction */ - public EconomyResponse depositPlayer(UUID uuid, double amount); + 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. @@ -328,7 +328,7 @@ public interface Economy { * @param amount Amount to deposit * @return Detailed response of transaction */ - public EconomyResponse depositPlayer(UUID uuid, String worldName, double amount); + 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. @@ -465,7 +465,7 @@ public interface Economy { * @param uuid associated with the account * @return if the account creation was successful */ - public boolean createPlayerAccount(UUID uuid); + public boolean createAccount(UUID uuid); /** * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer, String)} or {@link #createPlayerAccount(UUID, String)} instead. @@ -489,5 +489,5 @@ public interface Economy { * @param worldName String name of the world * @return if the account creation was successful */ - public boolean createPlayerAccount(UUID uuid, String worldName); + public boolean createAccount(UUID uuid, String worldName); } From e0743da3674fa58874574678b556f97ae54941f0 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Tue, 12 Oct 2021 08:01:48 -0500 Subject: [PATCH 03/44] Remove the now un-needed AbstractEconomy class. To match the PR I have opened at the Vault repo, which has had the native economy plugin support removed, the VaultAPI plugin no longer requires the AbstractEconomy class. Removal means that this Pull Request no longer calls Bukkit.getOfflinePlayer(uuid), making this much safer. --- .../vault/economy/AbstractEconomy.java | 168 ------------------ 1 file changed, 168 deletions(-) delete mode 100644 src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java diff --git a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java b/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java deleted file mode 100644 index af60bc2..0000000 --- a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java +++ /dev/null @@ -1,168 +0,0 @@ -package net.milkbowl.vault.economy; - -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; - -@SuppressWarnings("deprecation") -public abstract class AbstractEconomy implements Economy { - - @Override - public boolean hasAccount(OfflinePlayer player) { - if (player.getName() == null) return false; - return hasAccount(player.getName()); - } - - @Override - public boolean hasAccount(OfflinePlayer player, String worldName) { - if (player.getName() == null) return false; - return hasAccount(player.getName(), worldName); - } - - @Override - public boolean hasAccount(UUID uuid) { - if (uuid == null) return false; - return hasAccount(Bukkit.getOfflinePlayer(uuid)); - } - - @Override - public boolean hasAccount(UUID uuid, String worldName) { - if (uuid == null) return false; - return hasAccount(Bukkit.getOfflinePlayer(uuid), worldName); - } - - @Override - public double getBalance(OfflinePlayer player) { - return getBalance(player.getName()); - } - - @Override - public double getBalance(OfflinePlayer player, String worldName) { - return getBalance(player.getName(), worldName); - } - - @Override - public double getBalance(UUID uuid) { - return getBalance(Bukkit.getOfflinePlayer(uuid)); - } - - @Override - public double getBalance(UUID uuid, String worldName) { - return getBalance(Bukkit.getOfflinePlayer(uuid), worldName); - } - - @Override - public boolean has(OfflinePlayer player, double amount) { - if (player.getName() == null) return false; - return has(player.getName(), amount); - } - - @Override - public boolean has(OfflinePlayer player, String worldName, double amount) { - if (player.getName() == null) return false; - return has(player.getName(), worldName, amount); - } - - @Override - public boolean has(UUID uuid, double amount) { - if (uuid == null) return false; - return has(Bukkit.getOfflinePlayer(uuid), amount); - } - - @Override - public boolean has(UUID uuid, String worldName, double amount) { - if (uuid == null) return false; - return has(Bukkit.getOfflinePlayer(uuid), worldName, amount); - } - - @Override - public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) { - return withdrawPlayer(player.getName(), amount); - } - - @Override - public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount) { - return withdrawPlayer(player.getName(), worldName, amount); - } - - @Override - public EconomyResponse withdraw(UUID uuid, double amount) { - return withdrawPlayer(Bukkit.getOfflinePlayer(uuid), amount); - } - - @Override - public EconomyResponse withdraw(UUID uuid, String worldName, double amount) { - return withdrawPlayer(Bukkit.getOfflinePlayer(uuid), worldName, amount); - } - - @Override - public EconomyResponse depositPlayer(OfflinePlayer player, double amount) { - return depositPlayer(player.getName(), amount); - } - - @Override - public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount) { - return depositPlayer(player.getName(), worldName, amount); - } - - @Override - public EconomyResponse deposit(UUID uuid, double amount) { - return depositPlayer(Bukkit.getOfflinePlayer(uuid), amount); - } - - @Override - public EconomyResponse deposit(UUID uuid, String worldName, double amount) { - return depositPlayer(Bukkit.getOfflinePlayer(uuid), worldName, amount); - } - - @Override - public EconomyResponse createBank(String name, OfflinePlayer player) { - return createBank(name, player.getName()); - } - - @Override - public EconomyResponse createBank(String name, UUID uuid) { - return createBank(name, Bukkit.getOfflinePlayer(uuid)); - } - - @Override - public EconomyResponse isBankOwner(String name, OfflinePlayer player) { - return isBankOwner(name, player.getName()); - } - - @Override - public EconomyResponse isBankOwner(String name, UUID uuid) { - return isBankOwner(name, Bukkit.getOfflinePlayer(uuid)); - } - - @Override - public EconomyResponse isBankMember(String name, OfflinePlayer player) { - return isBankMember(name, player.getName()); - } - - @Override - public EconomyResponse isBankMember(String name, UUID uuid ) { - return isBankMember(name, Bukkit.getOfflinePlayer(uuid)); - } - - @Override - public boolean createPlayerAccount(OfflinePlayer player) { - return createPlayerAccount(player.getName()); - } - - @Override - public boolean createPlayerAccount(OfflinePlayer player, String worldName) { - return createPlayerAccount(player.getName(), worldName); - } - - @Override - public boolean createAccount(UUID uuid) { - return createPlayerAccount(Bukkit.getOfflinePlayer(uuid)); - } - - @Override - public boolean createAccount(UUID uuid, String worldName) { - return createPlayerAccount(Bukkit.getOfflinePlayer(uuid), worldName); - } -} From b1e408be5a829893cf295b3d4575afad45d551c6 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Mon, 27 Jun 2022 19:23:14 -0500 Subject: [PATCH 04/44] Update pom with tentative version numbering. Add jetbrains annotations & remove mention of specifc economy plugins. --- pom.xml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5c8c467..1739da8 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ 4.0.0 net.milkbowl.vault VaultAPI - 1.8 + 2.0-SNAPSHOT VaultAPI Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves. -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 +Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, KPerms http://dev.bukkit.org/server-mods/vault/ @@ -44,6 +44,10 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms spigot-repo https://hub.spigotmc.org/nexus/content/groups/public/ + + central + https://repo1.maven.org/maven2 + @@ -61,6 +65,13 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms ${bukkitVersion} provided + + + org.jetbrains + annotations + 23.0.0 + provided + junit From 657069232ecce35feb1b5ca0455345cac0c8f0e2 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Mon, 27 Jun 2022 19:23:55 -0500 Subject: [PATCH 05/44] Deprecate vault package. --- .../java/net/milkbowl/vault/chat/Chat.java | 1 + .../net/milkbowl/vault/economy/Economy.java | 167 ++---------------- .../vault/economy/EconomyResponse.java | 1 + .../milkbowl/vault/permission/Permission.java | 1 + 4 files changed, 19 insertions(+), 151 deletions(-) diff --git a/src/main/java/net/milkbowl/vault/chat/Chat.java b/src/main/java/net/milkbowl/vault/chat/Chat.java index 2cb2091..1554bb8 100644 --- a/src/main/java/net/milkbowl/vault/chat/Chat.java +++ b/src/main/java/net/milkbowl/vault/chat/Chat.java @@ -24,6 +24,7 @@ /** * The main Chat API - allows for Prefix/Suffix nodes along with generic Info nodes if the linked Chat system supports them * + * @deprecated in lieu of the modern Vault2. To update alter your import to new.milkbowl.vault2.chat. */ public abstract class Chat { diff --git a/src/main/java/net/milkbowl/vault/economy/Economy.java b/src/main/java/net/milkbowl/vault/economy/Economy.java index a1b3ed9..ceb1668 100644 --- a/src/main/java/net/milkbowl/vault/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault/economy/Economy.java @@ -17,13 +17,13 @@ package net.milkbowl.vault.economy; import java.util.List; -import java.util.UUID; import org.bukkit.OfflinePlayer; /** * The main economy API * + * @deprecated in lieu of the modern Vault2. To update alter your import to new.milkbowl.vault2.economy and update to use the new UUID-based methods where available. */ public interface Economy { @@ -81,7 +81,7 @@ public interface Economy { /** * - * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} or {@link #hasAccount(UUID)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} instead. */ @Deprecated public boolean hasAccount(String playerName); @@ -97,15 +97,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 +114,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 +128,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 +143,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 +158,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 #has(OfflinePlayer, String, double)} instead. */ @Deprecated public boolean has(String playerName, String worldName, double amount); @@ -218,18 +175,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 +190,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 +206,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 +221,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 +238,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 +250,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. @@ -394,7 +293,7 @@ public interface Economy { public EconomyResponse bankDeposit(String name, double amount); /** - * @deprecated As of VaultAPI 1.4 use {@link #isBankOwner(String, OfflinePlayer)} or {@link #isBankOwner(String, UUID)} instead. + * @deprecated As of VaultAPI 1.4 use {{@link #isBankOwner(String, OfflinePlayer)} instead. */ @Deprecated public EconomyResponse isBankOwner(String name, String playerName); @@ -407,18 +306,9 @@ public interface Economy { * @return EconomyResponse Object */ 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 +321,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 @@ -448,7 +329,7 @@ public interface Economy { public List getBanks(); /** - * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer)} or {@link #createPlayerAccount(UUID)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer)} instead. */ @Deprecated public boolean createPlayerAccount(String playerName); @@ -461,14 +342,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 +355,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/EconomyResponse.java b/src/main/java/net/milkbowl/vault/economy/EconomyResponse.java index 508e2fd..2b6519e 100644 --- a/src/main/java/net/milkbowl/vault/economy/EconomyResponse.java +++ b/src/main/java/net/milkbowl/vault/economy/EconomyResponse.java @@ -20,6 +20,7 @@ * It includes a {@link ResponseType} indicating whether the plugin currently being used for Economy actually allows * the method, or if the operation was a success or failure. * + * @deprecated in lieu of the modern Vault2. To update alter your import to new.milkbowl.vault2.economy. */ public class EconomyResponse { diff --git a/src/main/java/net/milkbowl/vault/permission/Permission.java b/src/main/java/net/milkbowl/vault/permission/Permission.java index 0f68eba..9d15318 100644 --- a/src/main/java/net/milkbowl/vault/permission/Permission.java +++ b/src/main/java/net/milkbowl/vault/permission/Permission.java @@ -28,6 +28,7 @@ /** * The main Permission API - allows for group and player based permission tests * + * @deprecated in lieu of the modern Vault2. To update alter your import to new.milkbowl.vault2.permission. */ public abstract class Permission { From 5348352f5de7a7e32e1fcf1f5c96cd17abc1f5a8 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Mon, 27 Jun 2022 19:30:54 -0500 Subject: [PATCH 06/44] Add vault2 package. All classes are the same as their v1 selves. --- .../java/net/milkbowl/vault2/chat/Chat.java | 995 ++++++++++++++++++ .../vault2/economy/EconomyResponse.java | 89 ++ .../vault2/permission/Permission.java | 705 +++++++++++++ 3 files changed, 1789 insertions(+) create mode 100644 src/main/java/net/milkbowl/vault2/chat/Chat.java create mode 100644 src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java create mode 100644 src/main/java/net/milkbowl/vault2/permission/Permission.java diff --git a/src/main/java/net/milkbowl/vault2/chat/Chat.java b/src/main/java/net/milkbowl/vault2/chat/Chat.java new file mode 100644 index 0000000..7c48870 --- /dev/null +++ b/src/main/java/net/milkbowl/vault2/chat/Chat.java @@ -0,0 +1,995 @@ +/* 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.vault2.chat; + +import net.milkbowl.vault2.permission.Permission; + +import org.bukkit.OfflinePlayer; +import org.bukkit.World; +import org.bukkit.entity.Player; + +/** + * The main Chat API - allows for Prefix/Suffix nodes along with generic Info nodes if the linked Chat system supports them + * + */ +public abstract class Chat { + + private Permission perms; + + public Chat(Permission perms) { + this.perms = perms; + } + /** + * Gets name of permission method + * @return Name of Permission Method + */ + abstract public String getName(); + + /** + * Checks if permission method is enabled. + * @return Success or Failure + */ + abstract public boolean isEnabled(); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerPrefix(String, OfflinePlayer)} instead. + * + * Get players prefix + * @param world World name + * @param player Player name + * @return Prefix + */ + @Deprecated + abstract public String getPlayerPrefix(String world, String player); + + /** + * Get a players prefix in the given world + * Use NULL for world if requesting a global prefix + * + * @param world World name + * @param player OfflinePlayer + * @return Prefix + */ + public String getPlayerPrefix(String world, OfflinePlayer player) { + return getPlayerPrefix(world, player.getName()); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerPrefix(String, OfflinePlayer)} instead. + * + * Get players prefix + * @param world World Object + * @param player Player name + * @return Prefix + */ + @Deprecated + public String getPlayerPrefix(World world, String player) { + return getPlayerPrefix(world.getName(), player); + } + + /** + * Get players prefix from the world they are currently in. + * May or may not return the global prefix depending on implementation. + * + * @param player Player Object + * @return Prefix + */ + public String getPlayerPrefix(Player player) { + return getPlayerPrefix(player.getWorld().getName(), player); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerPrefix(String, OfflinePlayer, String)} instead. + * + * Set players prefix + * @param world World name + * @param player Player name + * @param prefix Prefix + */ + @Deprecated + abstract public void setPlayerPrefix(String world, String player, String prefix); + + /** + * Sets players prefix in the given world. + * Use NULL for world for setting in the Global scope. + * + * @param world World name + * @param player OfflinePlayer + * @param prefix Prefix + */ + public void setPlayerPrefix(String world, OfflinePlayer player, String prefix) { + setPlayerPrefix(world, player.getName(), prefix); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerPrefix(String, OfflinePlayer, String)} instead. + * + * Set players prefix in the given world. + * + * @param world World Object + * @param player Player name + * @param prefix Prefix + */ + @Deprecated + public void setPlayerPrefix(World world, String player, String prefix) { + setPlayerPrefix(world.getName(), player, prefix); + } + + /** + * Set players prefix in the world they are currently in. + * + * @param player Player Object + * @param prefix Prefix + */ + public void setPlayerPrefix(Player player, String prefix) { + setPlayerPrefix(player.getWorld().getName(), player, prefix); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerSuffix(String, OfflinePlayer)} instead. + * + * Get players suffix + * @param world World name + * @param player Player name + * @return Suffix + */ + @Deprecated + abstract public String getPlayerSuffix(String world, String player); + + /** + * Get players suffix in the specified world. + * + * @param world World name + * @param player OfflinePlayer name + * @return Suffix + */ + public String getPlayerSuffix(String world, OfflinePlayer player) { + return getPlayerSuffix(world, player.getName()); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerSuffix(String, OfflinePlayer)} instead. + * + * Get players suffix + * @param world World Object + * @param player Player name + * @return Suffix + */ + @Deprecated + public String getPlayerSuffix(World world, String player) { + return getPlayerSuffix(world.getName(), player); + } + + /** + * Get players suffix in the world they are currently in. + * + * @param player Player Object + * @return Suffix + */ + public String getPlayerSuffix(Player player) { + return getPlayerSuffix(player.getWorld().getName(), player); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerSuffix(String, OfflinePlayer, String)} instead. + * + * Set players suffix + * @param world World name + * @param player Player name + * @param suffix Suffix + */ + @Deprecated + abstract public void setPlayerSuffix(String world, String player, String suffix); + + /** + * Set players suffix for the world specified + * + * @param world World name + * @param player OfflinePlayer + * @param suffix Suffix + */ + public void setPlayerSuffix(String world, OfflinePlayer player, String suffix) { + setPlayerSuffix(world, player.getName(), suffix); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerSuffix(String, OfflinePlayer, String)} instead. + * + * Set players suffix + * @param world World Object + * @param player Player name + * @param suffix Suffix + */ + @Deprecated + public void setPlayerSuffix(World world, String player, String suffix) { + setPlayerSuffix(world.getName(), player, suffix); + } + + /** + * Set players suffix in the world they currently occupy. + * + * @param player Player Object + * @param suffix Suffix + */ + public void setPlayerSuffix(Player player, String suffix) { + setPlayerSuffix(player.getWorld().getName(), player, suffix); + } + + /** + * Get group prefix + * @param world World name + * @param group Group name + * @return Prefix + */ + abstract public String getGroupPrefix(String world, String group); + + /** + * Get group prefix + * @param world World Object + * @param group Group name + * @return Prefix + */ + public String getGroupPrefix(World world, String group) { + return getGroupPrefix(world.getName(), group); + } + + /** + * Set group prefix + * @param world World name + * @param group Group name + * @param prefix Prefix + */ + abstract public void setGroupPrefix(String world, String group, String prefix); + + /** + * Set group prefix + * @param world World Object + * @param group Group name + * @param prefix Prefix + */ + public void setGroupPrefix(World world, String group, String prefix) { + setGroupPrefix(world.getName(), group, prefix); + } + + /** + * Get group suffix + * @param world World name + * @param group Group name + * @return Suffix + */ + abstract public String getGroupSuffix(String world, String group); + + /** + * Get group suffix + * @param world World Object + * @param group Group name + * @return Suffix + */ + public String getGroupSuffix(World world, String group) { + return getGroupSuffix(world.getName(), group); + } + + /** + * Set group suffix + * @param world World name + * @param group Group name + * @param suffix Suffix + */ + abstract public void setGroupSuffix(String world, String group, String suffix); + + /** + * Set group suffix + * @param world World Object + * @param group Group name + * @param suffix Suffix + */ + public void setGroupSuffix(World world, String group, String suffix) { + setGroupSuffix(world.getName(), group, suffix); + } + + /** + * Get a players informational node (Integer) value + * @param world World name + * @param player OfflinePlayer + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public int getPlayerInfoInteger(String world, OfflinePlayer player, String node, int defaultValue) { + return getPlayerInfoInteger(world, player.getName(), node, defaultValue); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoInteger(String, OfflinePlayer, String, int)} instead. + * Get a players informational node (Integer) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + @Deprecated + abstract public int getPlayerInfoInteger(String world, String player, String node, int defaultValue); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoInteger(String, OfflinePlayer, String, int)} instead. + * + * Get a players informational node (Integer) value + * @param world World Object + * @param player Player name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + @Deprecated + public int getPlayerInfoInteger(World world, String player, String node, int defaultValue) { + return getPlayerInfoInteger(world.getName(), player, node, defaultValue); + } + + /** + * Get a players informational node (Integer) value + * @param player Player Object + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public int getPlayerInfoInteger(Player player, String node, int defaultValue) { + return getPlayerInfoInteger(player.getWorld().getName(), player, node, defaultValue); + } + + /** + * Set a players informational node (Integer) value + * @param world World name + * @param player OfflinePlayer + * @param node Permission node + * @param value Value to set + */ + public void setPlayerInfoInteger(String world, OfflinePlayer player, String node, int value) { + setPlayerInfoInteger(world, player.getName(), node, value); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoInteger(String, OfflinePlayer, String, int)} instead. + * + * Set a players informational node (Integer) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param value Value to set + */ + @Deprecated + abstract public void setPlayerInfoInteger(String world, String player, String node, int value); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoInteger(String, OfflinePlayer, String, int)} instead. + * + * Set a players informational node (Integer) value + * @param world World Object + * @param player Player name + * @param node Permission node + * @param value Value to set + */ + @Deprecated + public void setPlayerInfoInteger(World world, String player, String node, int value) { + setPlayerInfoInteger(world.getName(), player, node, value); + } + + /** + * Set a players informational node (Integer) value + * @param player Player Object + * @param node Permission node + * @param value Value to set + */ + public void setPlayerInfoInteger(Player player, String node, int value) { + setPlayerInfoInteger(player.getWorld().getName(), player, node, value); + } + + /** + * Get a groups informational node (Integer) value + * @param world World name + * @param group Group name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + abstract public int getGroupInfoInteger(String world, String group, String node, int defaultValue); + + /** + * Get a groups informational node (Integer) value + * @param world World Object + * @param group Group name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public int getGroupInfoInteger(World world, String group, String node, int defaultValue) { + return getGroupInfoInteger(world.getName(), group, node, defaultValue); + } + + /** + * Set a groups informational node (Integer) value + * @param world World name + * @param group Group name + * @param node Permission node + * @param value Value to set + */ + abstract public void setGroupInfoInteger(String world, String group, String node, int value); + + /** + * Set a groups informational node (Integer) value + * @param world World Object + * @param group Group name + * @param node Permission node + * @param value Value to set + */ + public void setGroupInfoInteger(World world, String group, String node, int value) { + setGroupInfoInteger(world.getName(), group, node, value); + } + + /** + * Get a players informational node (Double) value + * @param world World name + * @param player OfflinePlayer + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public double getPlayerInfoDouble(String world, OfflinePlayer player, String node, double defaultValue) { + return getPlayerInfoDouble(world, player.getName(), node, defaultValue); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoDouble(String, OfflinePlayer, String, double)} instead. + * + * Get a players informational node (Double) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + @Deprecated + abstract public double getPlayerInfoDouble(String world, String player, String node, double defaultValue); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoDouble(String, OfflinePlayer, String, double)} instead + * + * Get a players informational node (Double) value + * @param world World Object + * @param player Player name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + @Deprecated + public double getPlayerInfoDouble(World world, String player, String node, double defaultValue) { + return getPlayerInfoDouble(world.getName(), player, node, defaultValue); + } + + /** + * Get a players informational node (Double) value + * @param player Player Object + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public double getPlayerInfoDouble(Player player, String node, double defaultValue) { + return getPlayerInfoDouble(player.getWorld().getName(), player, node, defaultValue); + } + + /** + * Set a players informational node (Double) value + * @param world World name + * @param player OfflinePlayer + * @param node Permission node + * @param value Value to set + */ + public void setPlayerInfoDouble(String world, OfflinePlayer player, String node, double value) { + setPlayerInfoDouble(world, player.getName(), node, value); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoDouble(String, OfflinePlayer, String, double)} instead. + * Set a players informational node (Double) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param value Value to set + */ + @Deprecated + abstract public void setPlayerInfoDouble(String world, String player, String node, double value); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoDouble(String, OfflinePlayer, String, double)} instead. + * Set a players informational node (Double) value + * @param world World Object + * @param player Player name + * @param node Permission node + * @param value Value to set + */ + @Deprecated + public void setPlayerInfoDouble(World world, String player, String node, double value) { + setPlayerInfoDouble(world.getName(), player, node, value); + } + + /** + * Set a players informational node (Double) value + * @param player Player Object + * @param node Permission node + * @param value Value to set + */ + public void setPlayerInfoDouble(Player player, String node, double value) { + setPlayerInfoDouble(player.getWorld().getName(), player, node, value); + } + + /** + * Get a groups informational node (Double) value + * @param world World name + * @param group Group name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + abstract public double getGroupInfoDouble(String world, String group, String node, double defaultValue); + + /** + * Get a groups informational node (Double) value + * @param world World Object + * @param group Group name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public double getGroupInfoDouble(World world, String group, String node, double defaultValue) { + return getGroupInfoDouble(world.getName(), group, node, defaultValue); + } + + /** + * Set a groups informational node (Double) value + * @param world World name + * @param group Group name + * @param node Permission node + * @param value Value to set + */ + abstract public void setGroupInfoDouble(String world, String group, String node, double value); + + /** + * Set a groups informational node (Double) value + * @param world World Object + * @param group Group name + * @param node Permission node + * @param value Value to set + */ + public void setGroupInfoDouble(World world, String group, String node, double value) { + setGroupInfoDouble(world.getName(), group, node, value); + } + + /** + * Get a players informational node (Boolean) value + * @param world World name + * @param player OfflinePlayer + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public boolean getPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean defaultValue) { + return getPlayerInfoBoolean(world, player.getName(), node, defaultValue); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoBoolean(String, OfflinePlayer, String, boolean)} instead. + * + * Get a players informational node (Boolean) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + @Deprecated + abstract public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoBoolean(String, OfflinePlayer, String, boolean)} instead. + * + * Get a players informational node (Boolean) value + * @param world World Object + * @param player Player name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + @Deprecated + public boolean getPlayerInfoBoolean(World world, String player, String node, boolean defaultValue) { + return getPlayerInfoBoolean(world.getName(), player, node, defaultValue); + } + + /** + * Get a players informational node (Boolean) value + * @param player Player Object + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public boolean getPlayerInfoBoolean(Player player, String node, boolean defaultValue) { + return getPlayerInfoBoolean(player.getWorld().getName(), player, node, defaultValue); + } + + /** + * Set a players informational node (Boolean) value + * @param world World name + * @param player OfflinePlayer + * @param node Permission node + * @param value Value to set + */ + public void setPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean value) { + setPlayerInfoBoolean(world, player.getName(), node, value); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoBoolean(String, OfflinePlayer, String, boolean)} instead. + * Set a players informational node (Boolean) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param value Value to set + */ + @Deprecated + abstract public void setPlayerInfoBoolean(String world, String player, String node, boolean value); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoBoolean(String, OfflinePlayer, String, boolean)} instead. + * Set a players informational node (Boolean) value + * @param world World Object + * @param player Player name + * @param node Permission node + * @param value Value to set + */ + @Deprecated + public void setPlayerInfoBoolean(World world, String player, String node, boolean value) { + setPlayerInfoBoolean(world.getName(), player, node, value); + } + + /** + * Set a players informational node (Boolean) value + * @param player Player Object + * @param node Permission node + * @param value Value to set + */ + public void setPlayerInfoBoolean(Player player, String node, boolean value) { + setPlayerInfoBoolean(player.getWorld().getName(), player, node, value); + } + + /** + * Get a groups informational node (Boolean) value + * @param world Name of World + * @param group Name of Group + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + abstract public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue); + + /** + * Set a players informational node (Boolean) value + * @param world World Object + * @param group Group name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public boolean getGroupInfoBoolean(World world, String group, String node, boolean defaultValue) { + return getGroupInfoBoolean(world.getName(), group, node, defaultValue); + } + + /** + * Set a groups informational node (Boolean) value + * @param world World name + * @param group Group name + * @param node Permission node + * @param value Value to set + */ + abstract public void setGroupInfoBoolean(String world, String group, String node, boolean value); + + /** + * Set a players informational node (Boolean) value + * @param world World Object + * @param group Group name + * @param node Permission node + * @param value Value to set + */ + public void setGroupInfoBoolean(World world, String group, String node, boolean value) { + setGroupInfoBoolean(world.getName(), group, node, value); + } + + /** + * Get a players informational node (String) value + * @param world World name + * @param player OfflinePlayer + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public String getPlayerInfoString(String world, OfflinePlayer player, String node, String defaultValue) { + return getPlayerInfoString(world, player.getName(), node, defaultValue); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoString(String, OfflinePlayer, String, String)} instead. + * + * Get a players informational node (String) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + @Deprecated + abstract public String getPlayerInfoString(String world, String player, String node, String defaultValue); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoString(String, OfflinePlayer, String, String)} instead. + * Get a players informational node (String) value + * @param world World Object + * @param player Player name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + @Deprecated + public String getPlayerInfoString(World world, String player, String node, String defaultValue) { + return getPlayerInfoString(world.getName(), player, node, defaultValue); + } + + /** + * Get a players informational node (String) value + * @param player Player Object + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public String getPlayerInfoString(Player player, String node, String defaultValue) { + return getPlayerInfoString(player.getWorld().getName(), player, node, defaultValue); + } + + /** + * Set a players informational node (String) value + * @param world World name + * @param player OfflinePlayer + * @param node Permission node + * @param value Value to set + */ + public void setPlayerInfoString(String world, OfflinePlayer player, String node, String value) { + setPlayerInfoString(world, player.getName(), node, value); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoString(String, OfflinePlayer, String, String)} instead. + * Set a players informational node (String) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param value Value to set + */ + @Deprecated + abstract public void setPlayerInfoString(String world, String player, String node, String value); + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoString(String, OfflinePlayer, String, String)} instead. + * Set a players informational node (String) value + * @param world World name + * @param player Player name + * @param node Permission node + * @param value Value to set + */ + @Deprecated + public void setPlayerInfoString(World world, String player, String node, String value) { + setPlayerInfoString(world.getName(), player, node, value); + } + + /** + * Set a players informational node (String) value + * @param player Player Object + * @param node Permission node + * @param value Value ot set + */ + public void setPlayerInfoString(Player player, String node, String value) { + setPlayerInfoString(player.getWorld().getName(), player, node, value); + } + + /** + * Get a groups informational node (String) value + * @param world Name of World + * @param group Name of Group + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + abstract public String getGroupInfoString(String world, String group, String node, String defaultValue); + + /** + * Set a players informational node (String) value + * @param world World Object + * @param group Group name + * @param node Permission node + * @param defaultValue Default value + * @return Value + */ + public String getGroupInfoString(World world, String group, String node, String defaultValue) { + return getGroupInfoString(world.getName(), group, node, defaultValue); + } + + /** + * Set a groups informational node (String) value + * @param world World name + * @param group Group name + * @param node Permission node + * @param value Value to set + */ + abstract public void setGroupInfoString(String world, String group, String node, String value); + + /** + * Set a groups informational node (String) value + * @param world World name + * @param group Group name + * @param node Permission node + * @param value Value to set + */ + public void setGroupInfoString(World world, String group, String node, String value) { + setGroupInfoString(world.getName(), group, node, value); + } + + /** + * Check if player is member of a group. + * @param world World name + * @param player OfflinePlayer + * @param group Group name + * @return Success or Failure + */ + public boolean playerInGroup(String world, OfflinePlayer player, String group) { + return perms.playerInGroup(world, player, group); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #playerInGroup(String, OfflinePlayer, String)} instead. + * Check if player is member of a group. + * @param world World name + * @param player Player name + * @param group Group name + * @return Success or Failure + */ + @Deprecated + public boolean playerInGroup(String world, String player, String group) { + return perms.playerInGroup(world, player, group); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #playerInGroup(String, OfflinePlayer, String)} instead. + * Check if player is member of a group. + * @param world World Object + * @param player Player name + * @param group Group name + * @return Success or Failure + */ + @Deprecated + public boolean playerInGroup(World world, String player, String group) { + return playerInGroup(world.getName(), player, group); + } + + /** + * Check if player is member of a group. + * @param player Player Object + * @param group Group name + * @return Success or Failure + */ + public boolean playerInGroup(Player player, String group) { + return playerInGroup(player.getWorld().getName(), player, group); + } + + /** + * Gets the list of groups that this player has + * @param world World name + * @param player OfflinePlayer + * @return Array of groups + */ + public String[] getPlayerGroups(String world, OfflinePlayer player) { + return perms.getPlayerGroups(world, player); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerGroups(String, OfflinePlayer)} instead. + * Gets the list of groups that this player has + * @param world World name + * @param player Player name + * @return Array of groups + */ + @Deprecated + public String[] getPlayerGroups(String world, String player) { + return perms.getPlayerGroups(world, player); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerGroups(String, OfflinePlayer)} instead. + * Gets the list of groups that this player has + * @param world World Object + * @param player Player name + * @return Array of groups + */ + @Deprecated + public String[] getPlayerGroups(World world, String player) { + return getPlayerGroups(world.getName(), player); + } + + /** + * Gets the list of groups that this player has + * @param player Player Object + * @return Array of groups + */ + public String[] getPlayerGroups(Player player) { + return getPlayerGroups(player.getWorld().getName(), player); + } + + /** + * Gets players primary group + * @param world World name + * @param player OfflinePlayer + * @return Players primary group + */ + public String getPrimaryGroup(String world, OfflinePlayer player) { + return perms.getPrimaryGroup(world, player); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPrimaryGroup(String, OfflinePlayer)} instead. + * Gets players primary group + * @param world World name + * @param player Player name + * @return Players primary group + */ + @Deprecated + public String getPrimaryGroup(String world, String player) { + return perms.getPrimaryGroup(world, player); + } + + /** + * @deprecated As of VaultAPI 1.4 use {{@link #getPrimaryGroup(String, OfflinePlayer)} instead. + * Gets players primary group + * @param world World Object + * @param player Player name + * @return Players primary group + */ + @Deprecated + public String getPrimaryGroup(World world, String player) { + return getPrimaryGroup(world.getName(), player); + } + + /** + * Get players primary group + * @param player Player Object + * @return Players primary group + */ + public String getPrimaryGroup(Player player) { + return getPrimaryGroup(player.getWorld().getName(), player); + } + + /** + * Returns a list of all known groups + * @return an Array of String of all groups + */ + public String[] getGroups() { + return perms.getGroups(); + } +} diff --git a/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java b/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java new file mode 100644 index 0000000..f920491 --- /dev/null +++ b/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java @@ -0,0 +1,89 @@ +/* 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.vault2.economy; + +/** + * Indicates a typical Return for an Economy method. + * It includes a {@link ResponseType} indicating whether the plugin currently being used for Economy actually allows + * the method, or if the operation was a success or failure. + * + */ +public class EconomyResponse { + + /** + * Enum for types of Responses indicating the status of a method call. + */ + public static enum ResponseType { + SUCCESS(1), + FAILURE(2), + NOT_IMPLEMENTED(3); + + private int id; + + ResponseType(int id) { + this.id = id; + } + + int getId() { + return id; + } + } + + /** + * Amount modified by calling method + */ + public final double amount; + /** + * New balance of account + */ + public final double balance; + /** + * Success or failure of call. Using Enum of ResponseType to determine valid + * outcomes + */ + public final ResponseType type; + /** + * Error message if the variable 'type' is ResponseType.FAILURE + */ + public final String errorMessage; + + /** + * Constructor for EconomyResponse + * @param amount Amount modified during operation + * @param balance New balance of account + * @param type Success or failure type of the operation + * @param errorMessage Error message if necessary (commonly null) + */ + public EconomyResponse(double amount, double balance, ResponseType type, String errorMessage) { + this.amount = amount; + this.balance = balance; + this.type = type; + this.errorMessage = errorMessage; + } + + /** + * Checks if an operation was successful + * @return Value + */ + public boolean transactionSuccess() { + switch (type) { + case SUCCESS: + return true; + default: + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/milkbowl/vault2/permission/Permission.java b/src/main/java/net/milkbowl/vault2/permission/Permission.java new file mode 100644 index 0000000..d602278 --- /dev/null +++ b/src/main/java/net/milkbowl/vault2/permission/Permission.java @@ -0,0 +1,705 @@ +/* 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.vault2.permission; + +import java.util.logging.Logger; + +import org.bukkit.OfflinePlayer; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.plugin.Plugin; + +/** + * The main Permission API - allows for group and player based permission tests + * + */ +public abstract class Permission { + + protected static final Logger log = Logger.getLogger("Minecraft"); + protected Plugin plugin = null; + + /** + * Gets name of permission method + * @return Name of Permission Method + */ + abstract public String getName(); + + /** + * Checks if permission method is enabled. + * @return Success or Failure + */ + abstract public boolean isEnabled(); + + /** + * Returns if the permission system is or attempts to be compatible with super-perms. + * @return True if this permission implementation works with super-perms + */ + abstract public boolean hasSuperPermsCompat(); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. + */ + @Deprecated + public boolean has(String world, String player, String permission) { + if (world == null) { + return playerHas((String) null, player, permission); + } + return playerHas(world, player, permission); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. + */ + @Deprecated + public boolean has(World world, String player, String permission) { + if (world == null) { + return playerHas((String) null, player, permission); + } + return playerHas(world.getName(), player, permission); + } + + /** + * Checks if a CommandSender has a permission node. + * This will return the result of bukkits, generic .hasPermission() method and is identical in all cases. + * This method will explicitly fail if the registered permission system does not register permissions in bukkit. + * + * For easy checking of a commandsender + * @param sender to check permissions on + * @param permission to check for + * @return true if the sender has the permission + */ + public boolean has(CommandSender sender, String permission) { + return sender.hasPermission(permission); + } + + /** + * Checks if player has a permission node. (Short for playerHas(...) + * @param player Player Object + * @param permission Permission node + * @return Success or Failure + */ + public boolean has(Player player, String permission) { + return player.hasPermission(permission); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. + */ + @Deprecated + abstract public boolean playerHas(String world, String player, String permission); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. + */ + @Deprecated + public boolean playerHas(World world, String player, String permission) { + if (world == null) { + return playerHas((String) null, player, permission); + } + return playerHas(world.getName(), player, permission); + } + + /** + * Checks if player has a permission node. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world String world name + * @param player to check + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerHas(String world, OfflinePlayer player, String permission) { + if (world == null) { + return has((String) null, player.getName(), permission); + } + return has(world, player.getName(), permission); + } + + /** + * Checks if player has a permission node. + * Defaults to world-specific permission check if the permission system supports it. + * See {@link #playerHas(String, OfflinePlayer, String)} for explicit global or world checks. + * + * @param player Player Object + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerHas(Player player, String permission) { + return has(player, permission); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerAdd(String, OfflinePlayer, String)} instead. + * Add permission to a player. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World name + * @param player Player name + * @param permission Permission node + * @return Success or Failure + */ + @Deprecated + abstract public boolean playerAdd(String world, String player, String permission); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerAdd(String, OfflinePlayer, String)} instead. + */ + @Deprecated + public boolean playerAdd(World world, String player, String permission) { + if (world == null) { + return playerAdd((String) null, player, permission); + } + return playerAdd(world.getName(), player, permission); + } + + /** + * Add permission to a player. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world String world name + * @param player to add to + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerAdd(String world, OfflinePlayer player, String permission) { + if (world == null) { + return playerAdd((String) null, player.getName(), permission); + } + return playerAdd(world, player.getName(), permission); + } + + /** + * Add permission to a player ONLY for the world the player is currently on. + * This is a world-specific operation, if you want to add global permission you must explicitly use NULL for the world. + * See {@link #playerAdd(String, OfflinePlayer, String)} for global permission use. + * + * @param player Player Object + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerAdd(Player player, String permission) { + return playerAdd(player.getWorld().getName(), player, permission); + } + + /** + * Add transient permission to a player. + * This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e. + * one that only needs the built-in Bukkit API to add transient permissions to a player. + * + * @param player to add to + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerAddTransient(OfflinePlayer player, String permission) throws UnsupportedOperationException { + if (player.isOnline()) { + return playerAddTransient((Player) player, permission); + } + throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!"); + } + + /** + * Add transient permission to a player. + * This operation adds a permission onto the player object in bukkit via Bukkit's permission interface. + * + * @param player Player Object + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerAddTransient(Player player, String permission) { + for (PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) { + if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) { + paInfo.getAttachment().setPermission(permission, true); + return true; + } + } + + PermissionAttachment attach = player.addAttachment(plugin); + attach.setPermission(permission, true); + + return true; + } + + /** + * Adds a world specific transient permission to the player, may only work with some permission managers. + * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! + * + * @param worldName to check on + * @param player to add to + * @param permission to test + * @return Success or Failure + */ + public boolean playerAddTransient(String worldName, OfflinePlayer player, String permission) { + return playerAddTransient(player, permission); + } + + /** + * Adds a world specific transient permission to the player, may only work with some permission managers. + * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! + * + * @param worldName to check on + * @param player to check + * @param permission to check for + * @return Success or Failure + */ + public boolean playerAddTransient(String worldName, Player player, String permission) { + return playerAddTransient(player, permission); + } + + /** + * Removes a world specific transient permission from the player, may only work with some permission managers. + * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! + * + * @param worldName to remove for + * @param player to remove for + * @param permission to remove + * @return Success or Failure + */ + public boolean playerRemoveTransient(String worldName, OfflinePlayer player, String permission) { + return playerRemoveTransient(player, permission); + } + + /** + * Removes a world specific transient permission from the player, may only work with some permission managers. + * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! + * + * @param worldName to check on + * @param player to check + * @param permission to check for + * @return Success or Failure + */ + public boolean playerRemoveTransient(String worldName, Player player, String permission) { + return playerRemoveTransient((OfflinePlayer) player, permission); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerRemove(String, OfflinePlayer, String)} instead. + */ + @Deprecated + abstract public boolean playerRemove(String world, String player, String permission); + + /** + * Remove permission from a player. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World name + * @param player OfflinePlayer + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerRemove(String world, OfflinePlayer player, String permission) { + if (world == null) { + return playerRemove((String) null, player.getName(), permission); + } + return playerRemove(world, player.getName(), permission); + } + + /** + * Remove permission from a player. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World name + * @param player Player name + * @param permission Permission node + * @return Success or Failure + */ + @Deprecated + public boolean playerRemove(World world, String player, String permission) { + if (world == null) { + return playerRemove((String) null, player, permission); + } + return playerRemove(world.getName(), player, permission); + } + + /** + * Remove permission from a player. + * Will attempt to remove permission from the player on the player's current world. This is NOT a global operation. + * + * @param player Player Object + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerRemove(Player player, String permission) { + return playerRemove(player.getWorld().getName(), player, permission); + } + + + /** + * Remove transient permission from a player. + * This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e. + * one that only needs the built-in Bukkit API to remove transient permissions from a player. Any subclass + * implementing a plugin which provides its own API for this needs to override this method. + * + * @param player OfflinePlayer + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerRemoveTransient(OfflinePlayer player, String permission) { + if (player.isOnline()) { + return playerRemoveTransient((Player) player, permission); + } else { + return false; + } + } + + /** + * Remove transient permission from a player. + * + * @param player Player Object + * @param permission Permission node + * @return Success or Failure + */ + public boolean playerRemoveTransient(Player player, String permission) { + for (PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) { + if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) { + paInfo.getAttachment().unsetPermission(permission); + return true; + } + } + return false; + } + + /** + * Checks if group has a permission node. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World name + * @param group Group name + * @param permission Permission node + * @return Success or Failure + */ + abstract public boolean groupHas(String world, String group, String permission); + + /** + * Checks if group has a permission node. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World Object + * @param group Group name + * @param permission Permission node + * @return Success or Failure + */ + public boolean groupHas(World world, String group, String permission) { + if (world == null) { + return groupHas((String) null, group, permission); + } + return groupHas(world.getName(), group, permission); + } + + /** + * Add permission to a group. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World name + * @param group Group name + * @param permission Permission node + * @return Success or Failure + */ + abstract public boolean groupAdd(String world, String group, String permission); + + /** + * Add permission to a group. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World Object + * @param group Group name + * @param permission Permission node + * @return Success or Failure + */ + public boolean groupAdd(World world, String group, String permission) { + if (world == null) { + return groupAdd((String) null, group, permission); + } + return groupAdd(world.getName(), group, permission); + } + + /** + * Remove permission from a group. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World name + * @param group Group name + * @param permission Permission node + * @return Success or Failure + */ + abstract public boolean groupRemove(String world, String group, String permission); + + /** + * Remove permission from a group. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World Object + * @param group Group name + * @param permission Permission node + * @return Success or Failure + */ + public boolean groupRemove(World world, String group, String permission) { + if (world == null) { + return groupRemove((String) null, group, permission); + } + return groupRemove(world.getName(), group, permission); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerInGroup(String, OfflinePlayer, String)} instead. + */ + @Deprecated + abstract public boolean playerInGroup(String world, String player, String group); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerInGroup(String, OfflinePlayer, String)} instead. + */ + @Deprecated + public boolean playerInGroup(World world, String player, String group) { + if (world == null) { + return playerInGroup((String) null, player, group); + } + return playerInGroup(world.getName(), player, group); + } + + /** + * Check if player is member of a group. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World Object + * @param player to check + * @param group Group name + * @return Success or Failure + */ + public boolean playerInGroup(String world, OfflinePlayer player, String group) { + if (world == null) { + return playerInGroup((String) null, player.getName(), group); + } + return playerInGroup(world, player.getName(), group); + } + + /** + * Check if player is member of a group. + * This method will ONLY check groups for which the player is in that are defined for the current world. + * This may result in odd return behaviour depending on what permission system has been registered. + * + * @param player Player Object + * @param group Group name + * @return Success or Failure + */ + public boolean playerInGroup(Player player, String group) { + return playerInGroup(player.getWorld().getName(), player, group); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerAddGroup(String, OfflinePlayer, String)} instead. + */ + @Deprecated + abstract public boolean playerAddGroup(String world, String player, String group); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerAddGroup(String, OfflinePlayer, String)} instead. + */ + @Deprecated + public boolean playerAddGroup(World world, String player, String group) { + if (world == null) { + return playerAddGroup((String) null, player, group); + } + return playerAddGroup(world.getName(), player, group); + } + + /** + * Add player to a group. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world String world name + * @param player to add + * @param group Group name + * @return Success or Failure + */ + public boolean playerAddGroup(String world, OfflinePlayer player, String group) { + if (world == null) { + return playerAddGroup((String) null, player.getName(), group); + } + return playerAddGroup(world, player.getName(), group); + } + + /** + * Add player to a group. + * This will add a player to the group on the current World. This may return odd results if the permission system + * being used on the server does not support world-specific groups, or if the group being added to is a global group. + * + * @param player Player Object + * @param group Group name + * @return Success or Failure + */ + public boolean playerAddGroup(Player player, String group) { + return playerAddGroup(player.getWorld().getName(), player, group); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerRemoveGroup(String, OfflinePlayer, String)} instead. + */ + @Deprecated + abstract public boolean playerRemoveGroup(String world, String player, String group); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #playerRemoveGroup(String, OfflinePlayer, String)} instead. + */ + @Deprecated + public boolean playerRemoveGroup(World world, String player, String group) { + if (world == null) { + return playerRemoveGroup((String) null, player, group); + } + return playerRemoveGroup(world.getName(), player, group); + } + + /** + * Remove player from a group. + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world World Object + * @param player to remove + * @param group Group name + * @return Success or Failure + */ + public boolean playerRemoveGroup(String world, OfflinePlayer player, String group) { + if (world == null) { + return playerRemoveGroup((String) null, player.getName(), group); + } + return playerRemoveGroup(world, player.getName(), group); + } + + /** + * Remove player from a group. + * This will add a player to the group on the current World. This may return odd results if the permission system + * being used on the server does not support world-specific groups, or if the group being added to is a global group. + * + * @param player Player Object + * @param group Group name + * @return Success or Failure + */ + public boolean playerRemoveGroup(Player player, String group) { + return playerRemoveGroup(player.getWorld().getName(), player, group); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #getPlayerGroups(String, OfflinePlayer)} instead. + */ + @Deprecated + abstract public String[] getPlayerGroups(String world, String player); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #getPlayerGroups(String, OfflinePlayer)} instead. + */ + @Deprecated + public String[] getPlayerGroups(World world, String player) { + if (world == null) { + return getPlayerGroups((String) null, player); + } + return getPlayerGroups(world.getName(), player); + } + + /** + * Gets the list of groups that this player has + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world String world name + * @param player OfflinePlayer + * @return Array of groups + */ + public String[] getPlayerGroups(String world, OfflinePlayer player) { + return getPlayerGroups(world, player.getName()); + } + + /** + * Returns a list of world-specific groups that this player is currently in. May return unexpected results if + * you are looking for global groups, or if the registered permission system does not support world-specific groups. + * See {@link #getPlayerGroups(String, OfflinePlayer)} for better control of World-specific or global groups. + * + * @param player Player Object + * @return Array of groups + */ + public String[] getPlayerGroups(Player player) { + return getPlayerGroups(player.getWorld().getName(), player); + } + + /** + * @deprecated As of VaultAPI 1.4 use {@link #getPrimaryGroup(String, OfflinePlayer)} instead. + */ + @Deprecated + abstract public String getPrimaryGroup(String world, String player); + + /** + * @deprecated As of VaultAPI 1.4 use {@link #getPrimaryGroup(String, OfflinePlayer)} instead. + */ + @Deprecated + public String getPrimaryGroup(World world, String player) { + if (world == null) { + return getPrimaryGroup((String) null, player); + } + return getPrimaryGroup(world.getName(), player); + } + + /** + * Gets players primary group + * Supports NULL value for World if the permission system registered supports global permissions. + * But May return odd values if the servers registered permission system does not have a global permission store. + * + * @param world String world name + * @param player to get from + * @return Players primary group + */ + public String getPrimaryGroup(String world, OfflinePlayer player) { + return getPrimaryGroup(world, player.getName()); + } + + /** + * Get players primary group. + * Defaults to the players current world, so may return only world-specific groups. + * In most cases {@link #getPrimaryGroup(String, OfflinePlayer)} is preferable. + * + * @param player Player Object + * @return Players primary group + */ + public String getPrimaryGroup(Player player) { + return getPrimaryGroup(player.getWorld().getName(), player); + } + + /** + * Returns a list of all known groups + * @return an Array of String of all groups + */ + abstract public String[] getGroups(); + + /** + * Returns true if the given implementation supports groups. + * @return true if the implementation supports groups + */ + abstract public boolean hasGroupSupport(); +} \ No newline at end of file From 1a733089329ca5c973a68e11e66257b1ecf27f45 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Mon, 27 Jun 2022 19:50:24 -0500 Subject: [PATCH 07/44] Economy v2. New methods include: - UUID-focused methods replacing the Name and OfflinePlayer methods. - getUUIDNameMap() which makes the economy plugin able to supply a Map of UUIDs and last-known-names on request. This will be used to replace the code in Vault which converts between economy plugins (and is currently only able to convert accounts belonging to players which have logged in.) The @Nullable annotation is used here in order to declare that the last-known-name of the account is allowed to be null. - getAccountName(UUID) which will return the last-known-name of an account or null. Other Changes: - Minor changes to javadocs. --- .../net/milkbowl/vault2/economy/Economy.java | 322 ++++++++++++++++++ 1 file changed, 322 insertions(+) create mode 100644 src/main/java/net/milkbowl/vault2/economy/Economy.java diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java new file mode 100644 index 0000000..7f80531 --- /dev/null +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -0,0 +1,322 @@ +/* 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.vault2.economy; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.jetbrains.annotations.Nullable; + +/** + * The main economy API + * + */ +public interface Economy { + + /* + * Economy plugin-related methods follow. + */ + + /** + * Checks if economy plugin is enabled. + * + * @return Success or Failure + */ + public boolean isEnabled(); + + /** + * Gets name of economy plugin. + * + * @return Name of Economy plugin. + */ + public String getName(); + + /** + * Returns true if the given implementation supports banks. + * + * @return true if the implementation supports banks + */ + public boolean hasBankSupport(); + + /* + * Currency-related methods follow. + */ + + /** + * Some economy plugins round off after a certain number of digits. This + * function returns the number of digits the plugin keeps or -1 if no rounding + * occurs. + * + * @return number of digits after the decimal point kept + */ + public int fractionalDigits(); + + /** + * Format amount into a human readable String This provides translation into + * economy specific formatting to improve consistency between plugins. + * + * @param amount to format + * @return Human readable string describing amount + */ + public String format(double amount); + + /** + * Returns the name of the currency in plural form. If the economy being used + * does not support currency names then an empty string will be returned. + * + * @return name of the currency (plural) + */ + public String currencyNamePlural(); + + /** + * Returns the name of the currency in singular form. If the economy being used + * does not support currency names then an empty string will be returned. + * + * @return name of the currency (singular) + */ + public String currencyNameSingular(); + + /* + * Account-related methods follow. + */ + + /** + * 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); + + /** + * 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); + + /** + * Returns a map that represents all of the UUIDs which have accounts in the + * plugin, as well as their last-known-name whether it is null or not. This is + * used for Vault's economy converter and should be given every account + * available. + * + * @return a {@link Map} composed of the accounts keyed by their UUID, along + * with their associated last-known-name (null or not.) + */ + public Map getUUIDNameMap(); + + /** + * 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. + * @return name of the account owner or null. + */ + @Nullable + 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); + + /** + * 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(); +} From 918bda26d2fa1b7a51d33ffa62afed762119a033 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Mon, 27 Jun 2022 19:50:50 -0500 Subject: [PATCH 08/44] Update README to include new version, example code. --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c186065..e2e71e5 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ How to include the API with Maven: com.github.MilkBowl VaultAPI - 1.7 + 2.0 provided @@ -24,7 +24,7 @@ repositories { maven { url 'https://jitpack.io' } } dependencies { - compileOnly "com.github.MilkBowl:VaultAPI:1.7" + compileOnly "com.github.MilkBowl:VaultAPI:2.0" } ``` @@ -69,10 +69,10 @@ package com.example.plugin; import java.util.logging.Logger; -import net.milkbowl.vault.chat.Chat; -import net.milkbowl.vault.economy.Economy; -import net.milkbowl.vault.economy.EconomyResponse; -import net.milkbowl.vault.permission.Permission; +import net.milkbowl.vault2.chat.Chat; +import net.milkbowl.vault2.economy.Economy; +import net.milkbowl.vault2.economy.EconomyResponse; +import net.milkbowl.vault2.permission.Permission; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -137,8 +137,8 @@ public class ExamplePlugin extends JavaPlugin { if(command.getLabel().equals("test-economy")) { // Lets give the player 1.05 currency (note that SOME economic plugins require rounding!) - sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getName())))); - EconomyResponse r = econ.depositPlayer(player, 1.05); + sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getUniqueId())))); + EconomyResponse r = econ.depositPlayer(player.getUniqueId(), 1.05); if(r.transactionSuccess()) { sender.sendMessage(String.format("You were given %s and now have %s", econ.format(r.amount), econ.format(r.balance))); } else { From 7129ffb94f876e6983c8c3d96cdce162bcd06b81 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Mon, 27 Jun 2022 21:36:24 -0500 Subject: [PATCH 09/44] Add account name to the createAccount method. --- src/main/java/net/milkbowl/vault2/economy/Economy.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index 7f80531..a79ba93 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -99,9 +99,10 @@ public interface Economy { * 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); + public boolean createAccount(UUID uuid, String name); /** * Attempts to create an account for the given UUID on the specified world @@ -109,10 +110,11 @@ public interface Economy { * 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 worldName); + public boolean createAccount(UUID uuid, String name, String worldName); /** * Returns a map that represents all of the UUIDs which have accounts in the From 698c623ccc59299fdc5cde995392edda604e921e Mon Sep 17 00:00:00 2001 From: LlmDl Date: Wed, 3 Aug 2022 15:35:52 -0500 Subject: [PATCH 10/44] Fix typo in JavaDoc Co-authored-by: Morgan --- src/main/java/net/milkbowl/vault/chat/Chat.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/milkbowl/vault/chat/Chat.java b/src/main/java/net/milkbowl/vault/chat/Chat.java index 1554bb8..8945223 100644 --- a/src/main/java/net/milkbowl/vault/chat/Chat.java +++ b/src/main/java/net/milkbowl/vault/chat/Chat.java @@ -24,7 +24,8 @@ /** * The main Chat API - allows for Prefix/Suffix nodes along with generic Info nodes if the linked Chat system supports them * - * @deprecated in lieu of the modern Vault2. To update alter your import to new.milkbowl.vault2.chat. + * @deprecated in lieu of the modern Vault2. To update alter your import to net.milkbowl.vault2.chat. + */ public abstract class Chat { From 1af24b2e89b7a3dbfbcacfdbb0679713c1f2ed7c Mon Sep 17 00:00:00 2001 From: LlmDl Date: Wed, 3 Aug 2022 15:38:47 -0500 Subject: [PATCH 11/44] Fix typo in JavaDoc Co-authored-by: Morgan --- src/main/java/net/milkbowl/vault/economy/EconomyResponse.java | 2 +- src/main/java/net/milkbowl/vault/permission/Permission.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/milkbowl/vault/economy/EconomyResponse.java b/src/main/java/net/milkbowl/vault/economy/EconomyResponse.java index 2b6519e..b7f05e7 100644 --- a/src/main/java/net/milkbowl/vault/economy/EconomyResponse.java +++ b/src/main/java/net/milkbowl/vault/economy/EconomyResponse.java @@ -20,7 +20,7 @@ * It includes a {@link ResponseType} indicating whether the plugin currently being used for Economy actually allows * the method, or if the operation was a success or failure. * - * @deprecated in lieu of the modern Vault2. To update alter your import to new.milkbowl.vault2.economy. + * @deprecated in lieu of the modern Vault2. To update alter your import to net.milkbowl.vault2.economy. */ public class EconomyResponse { diff --git a/src/main/java/net/milkbowl/vault/permission/Permission.java b/src/main/java/net/milkbowl/vault/permission/Permission.java index 9d15318..608bc6c 100644 --- a/src/main/java/net/milkbowl/vault/permission/Permission.java +++ b/src/main/java/net/milkbowl/vault/permission/Permission.java @@ -28,7 +28,7 @@ /** * The main Permission API - allows for group and player based permission tests * - * @deprecated in lieu of the modern Vault2. To update alter your import to new.milkbowl.vault2.permission. + * @deprecated in lieu of the modern Vault2. To update alter your import to net.milkbowl.vault2.permission. */ public abstract class Permission { From 7c7d0abcc2a89011a5bd44f67088d6446c7cd676 Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Wed, 3 Aug 2022 16:03:48 -0500 Subject: [PATCH 12/44] Implement requested changes. - Added renameAccount(UUID, String). - Remove @Nullable annotation and remove repo/dependency from pom.xml. - Fixed typo in javadoc in Economy. --- pom.xml | 11 -------- .../net/milkbowl/vault/economy/Economy.java | 2 +- .../net/milkbowl/vault2/economy/Economy.java | 27 ++++++++++++------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index 1739da8..4a0800c 100644 --- a/pom.xml +++ b/pom.xml @@ -44,10 +44,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms spigot-repo https://hub.spigotmc.org/nexus/content/groups/public/ - - central - https://repo1.maven.org/maven2 - @@ -65,13 +61,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms ${bukkitVersion} provided - - - org.jetbrains - annotations - 23.0.0 - provided - junit diff --git a/src/main/java/net/milkbowl/vault/economy/Economy.java b/src/main/java/net/milkbowl/vault/economy/Economy.java index ceb1668..d37c725 100644 --- a/src/main/java/net/milkbowl/vault/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault/economy/Economy.java @@ -23,7 +23,7 @@ /** * The main economy API * - * @deprecated in lieu of the modern Vault2. To update alter your import to new.milkbowl.vault2.economy and update to use the new UUID-based methods where available. + * @deprecated in lieu of the modern Vault2. To update alter your import to net.milkbowl.vault2.economy and update to use the new UUID-based methods where available. */ public interface Economy { diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index a79ba93..c60f576 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -20,8 +20,6 @@ import java.util.Map; import java.util.UUID; -import org.jetbrains.annotations.Nullable; - /** * The main economy API * @@ -29,7 +27,7 @@ public interface Economy { /* - * Economy plugin-related methods follow. + * Economy plugin-related methods follow. */ /** @@ -118,23 +116,21 @@ public interface Economy { /** * Returns a map that represents all of the UUIDs which have accounts in the - * plugin, as well as their last-known-name whether it is null or not. This is - * used for Vault's economy converter and should be given every account - * available. + * plugin, as well as their last-known-name. This is used for Vault's economy + * converter and should be given every account available. * * @return a {@link Map} composed of the accounts keyed by their UUID, along - * with their associated last-known-name (null or not.) + * with their associated last-known-name. */ - public Map getUUIDNameMap(); + public Map getUUIDNameMap(); /** * 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. - * @return name of the account owner or null. + * @return name of the account owner. */ - @Nullable public String getAccountName(UUID uuid); /** @@ -154,6 +150,17 @@ public interface Economy { */ public boolean hasAccount(UUID uuid, String worldName); + /** + * A method which changes the name associated with the given UUID in the + * Map received from {@link #getUUIDNameMap()}. + * + * @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 * From d739d52432832ac310b888b243000abe8ec666ed Mon Sep 17 00:00:00 2001 From: LlmDl Date: Mon, 11 Dec 2023 09:58:21 -0600 Subject: [PATCH 13/44] Replace double usage with BigDecimal, to bring Vault2 further into the future. Major clean up of javadocs in the Economy class. --- .../net/milkbowl/vault2/economy/Economy.java | 276 +++++++++++------- .../vault2/economy/EconomyResponse.java | 15 +- 2 files changed, 176 insertions(+), 115 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index c60f576..0212c5a 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -16,10 +16,13 @@ package net.milkbowl.vault2.economy; +import java.math.BigDecimal; import java.util.List; import java.util.Map; import java.util.UUID; +import net.milkbowl.vault2.economy.EconomyResponse.ResponseType; + /** * The main economy API * @@ -33,21 +36,21 @@ public interface Economy { /** * Checks if economy plugin is enabled. * - * @return Success or Failure + * @return true if the server's economy plugin has properly enabled. */ public boolean isEnabled(); /** - * Gets name of economy plugin. + * Gets name of the economy plugin. * - * @return Name of Economy plugin. + * @return Name of the active economy plugin on the server. */ public String getName(); /** - * Returns true if the given implementation supports banks. + * Returns true if the economy plugin supports banks. * - * @return true if the implementation supports banks + * @return true if the economy plugin supports banks. */ public boolean hasBankSupport(); @@ -60,24 +63,25 @@ public interface Economy { * function returns the number of digits the plugin keeps or -1 if no rounding * occurs. * - * @return number of digits after the decimal point kept + * @return number of digits after the decimal point this plugin supports or -1 + * if no rounding occurs. */ public int fractionalDigits(); /** - * Format amount into a human readable String This provides translation into - * economy specific formatting to improve consistency between plugins. + * Plugins use this method to format a given BigDecimal amount into a human + * readable amount using your economy plugin's currency names/conventions. * - * @param amount to format - * @return Human readable string describing amount + * @param amount to format. + * @return Human readable string describing amount, ie 5 Dollars or 5.55 Pounds. */ - public String format(double amount); + public String format(BigDecimal amount); /** * Returns the name of the currency in plural form. If the economy being used * does not support currency names then an empty string will be returned. * - * @return name of the currency (plural) + * @return name of the currency (plural) ie: Dollars or Pounds. */ public String currencyNamePlural(); @@ -85,7 +89,7 @@ public interface Economy { * Returns the name of the currency in singular form. If the economy being used * does not support currency names then an empty string will be returned. * - * @return name of the currency (singular) + * @return name of the currency (singular) ie: Dollar or Pound. */ public String currencyNameSingular(); @@ -94,11 +98,11 @@ public interface Economy { */ /** - * Attempts to create a account for the given uuid + * 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 + * @param uuid UUID associated with the account. + * @param name UUID associated with the account. + * @return true if the account creation was successful. */ public boolean createAccount(UUID uuid, String name); @@ -107,9 +111,9 @@ public interface Economy { * 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 + * @param uuid UUID associated with the account. + * @param name 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 name, String worldName); @@ -128,25 +132,25 @@ public interface Economy { * 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. + * @param uuid UUID associated with the account. * @return name of the account owner. */ public String getAccountName(UUID uuid); /** - * Checks if this uuid has an account yet + * Checks if this UUID has an account yet. * - * @param uuid to check - * @return if the uuid has an account + * @param uuid UUID to check for an existing account. + * @return true if the UUID has an account. */ public boolean hasAccount(UUID uuid); /** - * Checks if this uuid has an account yet on the given world + * 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 + * @param uuid UUID to check for an existing account. + * @param worldName world-specific account. + * @return if the UUID has an account. */ public boolean hasAccount(UUID uuid, String worldName); @@ -154,97 +158,109 @@ public interface Economy { * A method which changes the name associated with the given UUID in the * Map received from {@link #getUUIDNameMap()}. * - * @param uuid which is having a name change. - * @param name name that will be associated with the UUID in the + * @param uuid UUID whose account is having a name change. + * @param name String 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); + /* + * Account balance related methods follow. + */ + /** - * Gets balance of a UUID + * Gets balance of an account associated with a UUID. * - * @param uuid of the account to get a balance for - * @return Amount currently held in account associated with the given UUID + * @param uuid 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); + public BigDecimal 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 + * @param uuid 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); + public BigDecimal getBalance(UUID uuid, String world); /** * Checks if the account associated with the given UUID has the amount - DO NOT - * USE NEGATIVE AMOUNTS + * USE NEGATIVE AMOUNTS. * - * @param uuid to check - * @param amount to check for - * @return True if UUID has amount, False else wise + * @param uuid the UUID associated with the account to check the balance of. + * @param amount the amount to check for. + * @return True if UUID has amount, False else wise. */ - public boolean has(UUID uuid, double amount); + public boolean has(UUID uuid, BigDecimal 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 + * @param uuid the UUID associated with the account to check the balance of. + * @param worldName the name of the world to check in. + * @param amount the amount to check for. * @return True if UUID has amount in the given world, - * False else wise + * False else wise. */ - public boolean has(UUID uuid, String worldName, double amount); + public boolean has(UUID uuid, String worldName, BigDecimal amount); /** * Withdraw an amount from an account associated with a UUID - DO NOT USE - * NEGATIVE AMOUNTS + * NEGATIVE AMOUNTS. * - * @param uuid to withdraw from - * @param amount Amount to withdraw - * @return Detailed response of transaction + * @param uuid the UUID associated with the account to withdraw from. + * @param amount Amount to withdraw. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. */ - public EconomyResponse withdraw(UUID uuid, double amount); + public EconomyResponse withdraw(UUID uuid, BigDecimal 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 + * @param uuid the UUID associated with the account to withdraw from. + * @param worldName the name of the world to check in. + * @param amount Amount to withdraw. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. */ - public EconomyResponse withdraw(UUID uuid, String worldName, double amount); + public EconomyResponse withdraw(UUID uuid, String worldName, BigDecimal amount); /** * Deposit an amount to an account associated with the given UUID - DO NOT USE - * NEGATIVE AMOUNTS + * NEGATIVE AMOUNTS. * - * @param uuid to deposit to - * @param amount Amount to deposit - * @return Detailed response of transaction + * @param uuid the UUID associated with the account to deposit to. + * @param amount Amount to deposit. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. */ - public EconomyResponse deposit(UUID uuid, double amount); + public EconomyResponse deposit(UUID uuid, BigDecimal amount); /** - * Deposit an amount from an account associated with a UUID on a given world - + * Deposit an amount to 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 + * @param uuid the UUID associated with the account to deposit to. + * @param worldName the name of the world to check in. + * @param amount Amount to deposit. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. */ - public EconomyResponse deposit(UUID uuid, String worldName, double amount); + public EconomyResponse deposit(UUID uuid, String worldName, BigDecimal amount); /* * Bank methods follow. @@ -252,80 +268,122 @@ public interface Economy { /** * Creates a bank account with the specified name and the given UUID as the - * owner + * owner. + * + * @param name Name of account. + * @param uuid UUID of the account should be linked to. + * @return true if bank creation is successful. + */ + public boolean createBank(String name, UUID uuid); + + /** + * Deletes a bank account with the specified UUID. + * + * @param uuid UUID of the bank to be deleted. + * @return true if the operation completed successfully + */ + public boolean deleteBank(UUID uuid); + + /** + * Returns a map that represents all of the UUIDs which have banks in the + * plugin, as well as their last-known-name. This is used for Vault's economy + * converter and should be given every account available. * - * @param name of account - * @param uuid the account should be linked to - * @return EconomyResponse Object + * @return a {@link Map} composed of the accounts keyed by their UUID, along + * with their associated last-known-name. + */ + public Map getBankUUIDNameMap(); + + /** + * Gets the last known name of an bank with the given UUID. Required for + * messages to be more human-readable than UUIDs alone can provide. + * + * @param uuid UUID to look up. + * @return name of the bank. */ - public EconomyResponse createBank(String name, UUID uuid); + public String getBankAccountName(UUID uuid); /** - * Deletes a bank account with the specified name. + * Checks if this UUID has a bank yet. * - * @param name of the back to delete - * @return if the operation completed successfully + * @param uuid UUID to check. + * @return true if the UUID has an account. + */ + public boolean hasBankAccount(UUID uuid); + + /** + * A method which changes the name associated with the given UUID in the + * Map received from {@link #getBankUUIDNameMap()}. + * + * @param uuid 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 EconomyResponse deleteBank(String name); + public boolean renameBankAccount(UUID uuid, String name); /** - * Returns the amount the bank has + * Returns the amount the bank has. * - * @param name of the account - * @return EconomyResponse Object + * @param uuid UUID of the account. + * @return amount which the bank holds as a balance. */ - public EconomyResponse bankBalance(String name); + public BigDecimal bankBalance(UUID uuid); /** * Returns true or false whether the bank has the amount specified - DO NOT USE - * NEGATIVE AMOUNTS + * NEGATIVE AMOUNTS. * - * @param name of the account + * @param uuid UUID of the account. * @param amount to check for - * @return EconomyResponse Object + * @return true if the bank has the given amount. */ - public EconomyResponse bankHas(String name, double amount); + public boolean bankHas(UUID uuid, BigDecimal amount); /** - * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS + * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS. * - * @param name of the account - * @param amount to withdraw - * @return EconomyResponse Object + * @param uuid UUID of the account. + * @param amount to withdraw. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. */ - public EconomyResponse bankWithdraw(String name, double amount); + public EconomyResponse bankWithdraw(String name, BigDecimal amount); /** - * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS + * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS. * - * @param name of the account - * @param amount to deposit - * @return EconomyResponse Object + * @param uuid UUID of the account. + * @param amount to deposit. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. */ - public EconomyResponse bankDeposit(String name, double amount); + public EconomyResponse bankDeposit(String name, BigDecimal amount); /** - * Check if a uuid is the owner of a bank account + * 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 + * @param uuid UUID of the player/object who might be an owner. + * @param bankUUID UUID of the bank account to check ownership of. + * @return true if the uuid is the owner of the bank associated with bankUUID. */ - public EconomyResponse isBankOwner(String name, UUID uuid); + public boolean isBankOwner(UUID uuid, UUID bankUUID); /** - * Check if the uuid is a member of the bank account + * Check if the UUID is a member of the bank account * - * @param name of the account - * @param uuid to check membership - * @return EconomyResponse Object + * @param uuid UUID of the player/object who might be a member.. + * @param bankUUID UUID of the bank account to check membership of. + * @return @return true if the uuid is a member of the bank associated with bankUUID. */ - public EconomyResponse isBankMember(String name, UUID uuid); + public boolean isBankMember(UUID uuid, UUID bankUUID); /** - * Gets the list of banks + * Gets the list of banks' UUIDs. * - * @return the List of Banks + * @return the List of Banks' UUIDs. */ - public List getBanks(); + public List getBanks(); } diff --git a/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java b/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java index f920491..7e00634 100644 --- a/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java +++ b/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java @@ -15,10 +15,13 @@ */ package net.milkbowl.vault2.economy; +import java.math.BigDecimal; + /** - * Indicates a typical Return for an Economy method. - * It includes a {@link ResponseType} indicating whether the plugin currently being used for Economy actually allows - * the method, or if the operation was a success or failure. + * Indicates a typical Return for an Economy method. It includes a + * {@link ResponseType} indicating whether the plugin currently being used for + * Economy actually allows the method, or if the operation was a success or + * failure. * */ public class EconomyResponse { @@ -45,11 +48,11 @@ int getId() { /** * Amount modified by calling method */ - public final double amount; + public final BigDecimal amount; /** * New balance of account */ - public final double balance; + public final BigDecimal balance; /** * Success or failure of call. Using Enum of ResponseType to determine valid * outcomes @@ -67,7 +70,7 @@ int getId() { * @param type Success or failure type of the operation * @param errorMessage Error message if necessary (commonly null) */ - public EconomyResponse(double amount, double balance, ResponseType type, String errorMessage) { + public EconomyResponse(BigDecimal amount, BigDecimal balance, ResponseType type, String errorMessage) { this.amount = amount; this.balance = balance; this.type = type; From 79bb998347b6e6d63f39e8497013b9c9e9da670f Mon Sep 17 00:00:00 2001 From: LlmDl Date: Mon, 11 Dec 2023 10:05:08 -0600 Subject: [PATCH 14/44] Remove unneeded space in the readme, while we're already altering the readme. Closes #149. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4119f02..922b9c5 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ public class ExamplePlugin extends JavaPlugin { @Override public void onEnable() { - if (!setupEconomy() ) { + if (!setupEconomy()) { getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName())); getServer().getPluginManager().disablePlugin(this); return; From b52495b66fd20e12d5b134ab5f6672200ce44b57 Mon Sep 17 00:00:00 2001 From: LlmDl Date: Mon, 11 Dec 2023 14:06:10 -0600 Subject: [PATCH 15/44] Alter readme to use BigDecimal in example. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 922b9c5..0294407 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ public class ExamplePlugin extends JavaPlugin { if(command.getLabel().equals("test-economy")) { // Lets give the player 1.05 currency (note that SOME economic plugins require rounding!) sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getUniqueId())))); - EconomyResponse r = econ.depositPlayer(player.getUniqueId(), 1.05); + EconomyResponse r = econ.depositPlayer(player.getUniqueId(), new BigDecimal("1.05")); if(r.transactionSuccess()) { sender.sendMessage(String.format("You were given %s and now have %s", econ.format(r.amount), econ.format(r.balance))); } else { From c491a544b0f6be6f2842394227ac59473ebac332 Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 10:40:57 -0400 Subject: [PATCH 16/44] Rebranded to VaultUnlocked because accepting PRs and adding actual improvements is such a radical idea. --- .github/workflows/maven.yml | 2 +- .github/workflows/release.yml | 2 +- .gitignore | 2 ++ .mvn/settings.xml | 36 ---------------------- .travis.yml | 13 -------- .utility/do-publish.sh | 24 --------------- .utility/settings.xml | 9 ------ README.md | 12 ++++---- pom.xml | 56 ++++++++++++++++++++++------------- 9 files changed, 46 insertions(+), 110 deletions(-) delete mode 100644 .mvn/settings.xml delete mode 100644 .travis.yml delete mode 100755 .utility/do-publish.sh delete mode 100644 .utility/settings.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 31df88d..f5abe21 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -34,5 +34,5 @@ jobs: run: mkdir staging && cp target/*.jar staging - uses: actions/upload-artifact@v2 with: - name: VaultAPI + name: VaultUnlockedAPI path: staging diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 97b9189..8eabd27 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Publish VaultAPI to GitHub Packages +name: Publish VaultUnlockedAPI to GitHub Packages on: release: types: [created] diff --git a/.gitignore b/.gitignore index 37cc1ae..5450c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /.project /.settings /bin/ +/.idea/ +/VaultAPI.iml diff --git a/.mvn/settings.xml b/.mvn/settings.xml deleted file mode 100644 index bdef178..0000000 --- a/.mvn/settings.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - github - - - - - github - - - central - https://repo1.maven.org/maven2 - true - true - - - github - GitHub Maven Packages - https://maven.pkg.github.com/milkbowl/github-releases - - - - - - - - github - MilkBowl - ${env.GITHUB_TOKEN} - - - \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 708d9c4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: java -jdk: [ openjdk8 ] -branches: - except: - - gh-pages -sudo: false -env: - global: - - secure: "lkC+9PeVPx0sFEAITPszoHvPV9jnavsJdA3Slo4FakzTB5AlERHszto4RdenAhPf347r8xKL120YvDxDeYvmffpG7NUcRXfQZxod1SRyFEFUUBC0zGHkLiJlBjAqkSEDacruldT4+1BCqRc/A96zj17knmUkvKnyutQtasOGKxk=" - - secure: "UxxyRTgZFxEbzxfpEKFC6bYVKkhVp/kOCy5QZwbctkwQP33l3eEwDUquDVXewwLWgM6yJvWdUq9Va/f2kJ8Z7NMHLj5UTj3zIWdqJ/dZIrZ32Vb6tTawXV56627ANLsGHfw55uqIIHFs3u3HUlucyYhBAxLsxJNR4XbU2IeA8fA=" - - secure: "ljUPRZkuNEqck8RIHONVD7lCr1a/aslagOQ27uB0EpuOMGfeBlDdAlpo+GnRSs2bsfvUGX9nmcgGPR6mTcV0fzHaSBg+p/BPWBuzo9wEs39H4wn8yVU70pu/wCEuRhGlFw4GE0mYp8pbHMHrc8WdxsF3dt4kAGsdVhivXuz9HHI=" -after_success: -- .utility/do-publish.sh diff --git a/.utility/do-publish.sh b/.utility/do-publish.sh deleted file mode 100755 index f663952..0000000 --- a/.utility/do-publish.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -current_dir=`pwd` - -if [[ "$TRAVIS_REPO_SLUG" != "MilkBowl/VaultAPI" || "$TRAVIS_PULL_REQUEST" == "true" || "$TRAVIS_BRANCH" != "master" ]] -then - echo 'Travis can only publish docs for release builds.' - return 0 -fi - -mvn clean javadoc:javadoc javadoc:jar deploy --settings .utility/settings.xml - -# Get to the Travis build directory, configure git and clone the repo -cd $HOME -git config --global user.email "travis@travis-ci.org" -git config --global user.name "travis-ci" -git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/MilkBowl/VaultAPI gh-pages > /dev/null - -# Commit and Push the Changes -cd gh-pages -git rm -rf * -cp -Rfv $current_dir/target/javadoc-latest/* ./ -git add -f . -git commit -m "Latest javadoc on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages" -git push -fq origin gh-pages > /dev/null diff --git a/.utility/settings.xml b/.utility/settings.xml deleted file mode 100644 index e16eb13..0000000 --- a/.utility/settings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - pub-repo - ${env.DEPLOY_USER} - ${env.DEPLOY_PASS} - - - \ No newline at end of file diff --git a/README.md b/README.md index d50c704..871f7aa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# VaultAPI - Abstraction Library API for Bukkit Plugins - [![](https://travis-ci.org/MilkBowl/VaultAPI.svg?branch=master)](https://travis-ci.org/MilkBowl/VaultAPI) +# VaultUnlockedAPI - Abstraction Library API for Bukkit Plugins - [![](https://travis-ci.org/MilkBowl/VaultAPI.svg?branch=master)](https://travis-ci.org/MilkBowl/VaultAPI) How to include the API with Maven: ```xml @@ -28,9 +28,11 @@ dependencies { } ``` -**Note**: The VaultAPI version has 2 numbers (major.minor), unlike Vault, which has 3. The 2 numbers in the VaultAPI will always correspond to the 2 beginning numbers in a Vault version to make it clear what versions your plugin will for sure work with. +**Note**: The VaultUnlockedAPI version has 2 numbers (major.minor), unlike Vault, which has 3. The 2 +numbers in the VaultUnlockedAPI will always correspond to the 2 beginning numbers in a VaultUnlocked +version to make it clear what versions your plugin will for sure work with. -## Why Vault? +## Why VaultUnlocked? I have no preference which library suits your plugin and development efforts best. Really, I thought a central suite (rather...Vault) of solutions was the the proper avenue than focusing on a single category of plugin. That's where @@ -59,10 +61,10 @@ You should have received a copy of the GNU Lesser General Public License along with Vault. If not, see . ## Building -VaultAPI comes with all libraries needed to build from the current branch. +VaultUnlockedAPI comes with all libraries needed to build from the current branch. ## Implementing Vault -Implementing Vault is quite simple. It requires getting the Economy, Permission, or Chat service from the Bukkit ServiceManager. See the example below: +Implementing VaultUnlocked is quite simple. It requires getting the Economy, Permission, or Chat service from the Bukkit ServiceManager. See the example below: ```java package com.example.plugin; diff --git a/pom.xml b/pom.xml index 959b534..078dd64 100644 --- a/pom.xml +++ b/pom.xml @@ -2,13 +2,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 net.milkbowl.vault - VaultAPI - 1.7 + VaultUnlockedAPI + 2.0 - VaultAPI - Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves. + VaultUnlockedAPI + VaultUnlocked is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves. -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 + VaultUnlocked supports all plugins that support Vault http://dev.bukkit.org/server-mods/vault/ @@ -18,25 +18,36 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms + - MilkBowl - https://github.com/MilkBowl + The New Economy + https://tnemc.net + + + creatorfromhell + Daniel "creatorfromhell" Vidmar + daniel.viddy@gmail.com + https://cfh.dev + The New Economy + https://tnemc.net + + developer + + America/New_York + + + - https://github.com/MilkBowl/VaultAPI - scm:git:git://github.com:MilkBowl/VaultAPI.git + https://github.com/TheNewEconomy/VaultUnlockedAPI + scm:git:git://github.com/TheNewEconomy/VaultUnlockedAPI.git scm:git:git@github.com:MilkBowl/VaultAPI.git - - Travis-CI - https://travis-ci.org/MilkBowl/VaultAPI - - GitHub - https://github.com/MilkBowl/VaultAPI/issues + https://github.com/TheNewEconomy/VaultUnlockedAPI/issues @@ -47,11 +58,14 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms - - github - GitHub Packages - https://maven.pkg.github.com/milkbowl/github-releases - + + codemc-releases + https://repo.codemc.io/repository/maven-releases/ + + + codemc-snapshots + https://repo.codemc.io/repository/maven-snapshots/ + @@ -110,7 +124,7 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms true true true - Milkbowl, 2020]]> + TheNewEconomy, 2024]]> ${project.build.directory} javadoc-latest From 5776aaf43c99ae9d9d2de15d73405cff59069e97 Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 11:27:11 -0400 Subject: [PATCH 17/44] Update Maven compiler plugin --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 078dd64..8ed7438 100644 --- a/pom.xml +++ b/pom.xml @@ -92,10 +92,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.10.1 - 1.8 - 1.8 + 8 + 8 From 7d94726d4eca4260f83c94d9340b68dfd840d651 Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 11:39:00 -0400 Subject: [PATCH 18/44] Update README.md. --- README.md | 52 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 871f7aa..52a745d 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,18 @@ -# VaultUnlockedAPI - Abstraction Library API for Bukkit Plugins - [![](https://travis-ci.org/MilkBowl/VaultAPI.svg?branch=master)](https://travis-ci.org/MilkBowl/VaultAPI) +# VaultUnlockedAPI - Abstraction Library API for Bukkit Plugins - [![Build Status](https://ci.codemc.io/job/creatorfromhell/job/VaultUnlockedAPI/badge/icon)](https://ci.codemc.io/job/creatorfromhell/job/VaultUnlockedAPI/) How to include the API with Maven: ```xml - jitpack.io - https://jitpack.io + codemc-repo + https://repo.codemc.org/repository/maven-public - com.github.MilkBowl - VaultAPI - 1.7 - provided + net.milkbowl.vault + VaultUnlockedAPI + 2.0 ``` @@ -21,10 +20,10 @@ How to include the API with Maven: How to include the API with Gradle: ```groovy repositories { - maven { url 'https://jitpack.io' } + maven { url 'https://repo.codemc.org/repository/maven-public' } } dependencies { - compileOnly "com.github.MilkBowl:VaultAPI:1.7" + compileOnly "net.milkbowl.vault:VaultUnlockedAPI:2.0" } ``` @@ -33,26 +32,37 @@ numbers in the VaultUnlockedAPI will always correspond to the 2 beginning number version to make it clear what versions your plugin will for sure work with. ## Why VaultUnlocked? -I have no preference which library suits your plugin and development efforts -best. Really, I thought a central suite (rather...Vault) of solutions was the -the proper avenue than focusing on a single category of plugin. That's where -the idea for Vault came into play. +I have no preference regarding which library is best suited for +your plugin development efforts. I believe a central suite (or "Vault") +of solutions is a more effective approach than focusing on a single +category of plugins. This is the concept behind VaultUnlocked. -So, what features do I _think_ you'll like the most? +### Key Features You'll Appreciate - * No need to include my source code in your plugin - * Broad range of supported plugins - * Choice! +* **No Source Code Integration Needed** + VaultUnlocked operates as a standalone plugin, so you only need to obtain an instance of it. This prevents conflicts with multiple plugins using the same namespaces. Simply include VaultUnlocked.jar in your download zip file for seamless integration! +* **Extensive Plugin Support** + VaultUnlocked provides an abstraction layer not just for Economic plugins but for Permission plugins as well, ensuring broad compatibility. +* **Freedom of Choice** + One of the best aspects of Bukkit is the freedom to choose what to use. More options benefit developers, so here’s to embracing choice! + +### Enhanced Features of VaultUnlocked + +* **Multi-Currency Support** +* **More Friendly PR Acceptance** +* **Folia Support** + +Let me know if you need any further modifications! ## License -Copyright (C) 2011-2018 Morgan Humes +Copyright (C) 2024 Daniel "creatorfromhell" Vidmar -Vault is free software: you can redistribute it and/or modify +VaultUnlocked 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, +VaultUnlocked 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. @@ -63,7 +73,7 @@ along with Vault. If not, see . ## Building VaultUnlockedAPI comes with all libraries needed to build from the current branch. -## Implementing Vault +## Implementing VaultUnlocked Implementing VaultUnlocked is quite simple. It requires getting the Economy, Permission, or Chat service from the Bukkit ServiceManager. See the example below: ```java From 3fb336e5c94bae3c133f7da46f1bbc1ad2ef8b0e Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 12:15:45 -0400 Subject: [PATCH 19/44] Remove abstracteconomy, it wasn't even that abstract --- .../vault/economy/AbstractEconomy.java | 87 ------------------- .../net/milkbowl/vault/economy/Economy.java | 86 +++++++++--------- 2 files changed, 43 insertions(+), 130 deletions(-) delete mode 100644 src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java diff --git a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java b/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java deleted file mode 100644 index 4fe0e37..0000000 --- a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.milkbowl.vault.economy; - -import org.bukkit.OfflinePlayer; - -@SuppressWarnings("deprecation") -public abstract class AbstractEconomy implements Economy { - - @Override - public boolean hasAccount(OfflinePlayer player) { - if (player.getName() == null) return false; - return hasAccount(player.getName()); - } - - @Override - public boolean hasAccount(OfflinePlayer player, String worldName) { - if (player.getName() == null) return false; - return hasAccount(player.getName(), worldName); - } - - @Override - public double getBalance(OfflinePlayer player) { - return getBalance(player.getName()); - } - - @Override - public double getBalance(OfflinePlayer player, String world) { - return getBalance(player.getName(), world); - } - - @Override - public boolean has(OfflinePlayer player, double amount) { - if (player.getName() == null) return false; - return has(player.getName(), amount); - } - - @Override - public boolean has(OfflinePlayer player, String worldName, double amount) { - if (player.getName() == null) return false; - return has(player.getName(), worldName, amount); - } - - @Override - public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) { - return withdrawPlayer(player.getName(), amount); - } - - @Override - public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount) { - return withdrawPlayer(player.getName(), worldName, amount); - } - - @Override - public EconomyResponse depositPlayer(OfflinePlayer player, double amount) { - return depositPlayer(player.getName(), amount); - } - - @Override - public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount) { - return depositPlayer(player.getName(), worldName, amount); - } - - @Override - public EconomyResponse createBank(String name, OfflinePlayer player) { - return createBank(name, player.getName()); - } - - @Override - public EconomyResponse isBankOwner(String name, OfflinePlayer player) { - return isBankOwner(name, player.getName()); - } - - @Override - public EconomyResponse isBankMember(String name, OfflinePlayer player) { - return isBankMember(name, player.getName()); - } - - @Override - public boolean createPlayerAccount(OfflinePlayer player) { - return createPlayerAccount(player.getName()); - } - - @Override - public boolean createPlayerAccount(OfflinePlayer player, String worldName) { - return createPlayerAccount(player.getName(), worldName); - } - -} diff --git a/src/main/java/net/milkbowl/vault/economy/Economy.java b/src/main/java/net/milkbowl/vault/economy/Economy.java index 1d14587..b844c3e 100644 --- a/src/main/java/net/milkbowl/vault/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault/economy/Economy.java @@ -30,19 +30,19 @@ public interface Economy { * Checks if economy method is enabled. * @return Success or Failure */ - public boolean isEnabled(); + boolean isEnabled(); /** * Gets name of economy method * @return Name of Economy Method */ - public String getName(); + String getName(); /** * Returns true if the given implementation supports banks. * @return true if the implementation supports banks */ - public boolean hasBankSupport(); + boolean hasBankSupport(); /** * Some economy plugins round off after a certain number of digits. @@ -50,7 +50,7 @@ public interface Economy { * or -1 if no rounding occurs. * @return number of digits after the decimal point kept */ - public int fractionalDigits(); + int fractionalDigits(); /** * Format amount into a human readable String This provides translation into @@ -59,7 +59,7 @@ public interface Economy { * @param amount to format * @return Human readable string describing amount */ - public String format(double amount); + String format(double amount); /** * Returns the name of the currency in plural form. @@ -67,7 +67,7 @@ public interface Economy { * * @return name of the currency (plural) */ - public String currencyNamePlural(); + String currencyNamePlural(); /** @@ -76,14 +76,14 @@ public interface Economy { * * @return name of the currency (singular) */ - public String currencyNameSingular(); + String currencyNameSingular(); /** * * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} instead. */ @Deprecated - public boolean hasAccount(String playerName); + boolean hasAccount(String playerName); /** * Checks if this player has an account on the server yet @@ -93,13 +93,13 @@ public interface Economy { * @param player to check * @return if the player has an account */ - public boolean hasAccount(OfflinePlayer player); + boolean hasAccount(OfflinePlayer player); /** * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} instead. */ @Deprecated - public boolean hasAccount(String playerName, String worldName); + boolean hasAccount(String playerName, String worldName); /** * Checks if this player has an account on the server yet on the given world @@ -110,13 +110,13 @@ public interface Economy { * @param worldName world-specific account * @return if the player has an account */ - public boolean hasAccount(OfflinePlayer player, String worldName); + boolean hasAccount(OfflinePlayer player, String worldName); /** * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} instead. */ @Deprecated - public double getBalance(String playerName); + double getBalance(String playerName); /** * Gets balance of a player @@ -124,13 +124,13 @@ public interface Economy { * @param player of the player * @return Amount currently held in players account */ - public double getBalance(OfflinePlayer player); + double getBalance(OfflinePlayer player); /** * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} instead. */ @Deprecated - public double getBalance(String playerName, String world); + double getBalance(String playerName, String world); /** * Gets balance of a player on the specified world. @@ -139,13 +139,13 @@ public interface Economy { * @param world name of the world * @return Amount currently held in players account */ - public double getBalance(OfflinePlayer player, String world); + double getBalance(OfflinePlayer player, String world); /** * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} instead. */ @Deprecated - public boolean has(String playerName, double amount); + boolean has(String playerName, double amount); /** * Checks if the player account has the amount - DO NOT USE NEGATIVE AMOUNTS @@ -154,13 +154,13 @@ public interface Economy { * @param amount to check for * @return True if player has amount, False else wise */ - public boolean has(OfflinePlayer player, double amount); + boolean has(OfflinePlayer player, double amount); /** * @deprecated As of VaultAPI 1.4 use @{link {@link #has(OfflinePlayer, String, double)} instead. */ @Deprecated - public boolean has(String playerName, String worldName, double amount); + boolean has(String playerName, String worldName, double amount); /** * Checks if the player account has the amount in a given world - DO NOT USE NEGATIVE AMOUNTS @@ -171,13 +171,13 @@ public interface Economy { * @param amount to check for * @return True if player has amount, False else wise */ - public boolean has(OfflinePlayer player, String worldName, double amount); + boolean has(OfflinePlayer player, String worldName, double amount); /** * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} instead. */ @Deprecated - public EconomyResponse withdrawPlayer(String playerName, double amount); + EconomyResponse withdrawPlayer(String playerName, double amount); /** * Withdraw an amount from a player - DO NOT USE NEGATIVE AMOUNTS @@ -186,13 +186,13 @@ public interface Economy { * @param amount Amount to withdraw * @return Detailed response of transaction */ - public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount); + EconomyResponse withdrawPlayer(OfflinePlayer player, double amount); /** * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} instead. */ @Deprecated - public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount); + EconomyResponse withdrawPlayer(String playerName, String worldName, double amount); /** * Withdraw an amount from a player on a given world - DO NOT USE NEGATIVE AMOUNTS @@ -202,13 +202,13 @@ public interface Economy { * @param amount Amount to withdraw * @return Detailed response of transaction */ - public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount); + EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount); /** * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} instead. */ @Deprecated - public EconomyResponse depositPlayer(String playerName, double amount); + EconomyResponse depositPlayer(String playerName, double amount); /** * Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS @@ -217,13 +217,13 @@ public interface Economy { * @param amount Amount to deposit * @return Detailed response of transaction */ - public EconomyResponse depositPlayer(OfflinePlayer player, double amount); + EconomyResponse depositPlayer(OfflinePlayer player, double amount); /** * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} instead. */ @Deprecated - public EconomyResponse depositPlayer(String playerName, String worldName, double amount); + EconomyResponse depositPlayer(String playerName, String worldName, double amount); /** * Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS @@ -234,13 +234,13 @@ public interface Economy { * @param amount Amount to deposit * @return Detailed response of transaction */ - public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount); + EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount); /** * @deprecated As of VaultAPI 1.4 use {{@link #createBank(String, OfflinePlayer)} instead. */ @Deprecated - public EconomyResponse createBank(String name, String player); + EconomyResponse createBank(String name, String player); /** * Creates a bank account with the specified name and the player as the owner @@ -248,21 +248,21 @@ public interface Economy { * @param player the account should be linked to * @return EconomyResponse Object */ - public EconomyResponse createBank(String name, OfflinePlayer player); + EconomyResponse createBank(String name, OfflinePlayer player); /** * 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); + EconomyResponse deleteBank(String name); /** * Returns the amount the bank has * @param name of the account * @return EconomyResponse Object */ - public EconomyResponse bankBalance(String name); + EconomyResponse bankBalance(String name); /** * Returns true or false whether the bank has the amount specified - DO NOT USE NEGATIVE AMOUNTS @@ -271,7 +271,7 @@ public interface Economy { * @param amount to check for * @return EconomyResponse Object */ - public EconomyResponse bankHas(String name, double amount); + EconomyResponse bankHas(String name, double amount); /** * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS @@ -280,7 +280,7 @@ public interface Economy { * @param amount to withdraw * @return EconomyResponse Object */ - public EconomyResponse bankWithdraw(String name, double amount); + EconomyResponse bankWithdraw(String name, double amount); /** * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS @@ -289,13 +289,13 @@ public interface Economy { * @param amount to deposit * @return EconomyResponse Object */ - public EconomyResponse bankDeposit(String name, double amount); + EconomyResponse bankDeposit(String name, double amount); /** * @deprecated As of VaultAPI 1.4 use {{@link #isBankOwner(String, OfflinePlayer)} instead. */ @Deprecated - public EconomyResponse isBankOwner(String name, String playerName); + EconomyResponse isBankOwner(String name, String playerName); /** * Check if a player is the owner of a bank account @@ -304,13 +304,13 @@ public interface Economy { * @param player to check for ownership * @return EconomyResponse Object */ - public EconomyResponse isBankOwner(String name, OfflinePlayer player); + EconomyResponse isBankOwner(String name, OfflinePlayer player); /** * @deprecated As of VaultAPI 1.4 use {{@link #isBankMember(String, OfflinePlayer)} instead. */ @Deprecated - public EconomyResponse isBankMember(String name, String playerName); + EconomyResponse isBankMember(String name, String playerName); /** * Check if the player is a member of the bank account @@ -319,32 +319,32 @@ public interface Economy { * @param player to check membership * @return EconomyResponse Object */ - public EconomyResponse isBankMember(String name, OfflinePlayer player); + EconomyResponse isBankMember(String name, OfflinePlayer player); /** * Gets the list of banks * @return the List of Banks */ - public List getBanks(); + List getBanks(); /** * @deprecated As of VaultAPI 1.4 use {{@link #createPlayerAccount(OfflinePlayer)} instead. */ @Deprecated - public boolean createPlayerAccount(String playerName); + boolean createPlayerAccount(String playerName); /** * Attempts to create a player account for the given player * @param player OfflinePlayer * @return if the account creation was successful */ - public boolean createPlayerAccount(OfflinePlayer player); + boolean createPlayerAccount(OfflinePlayer player); /** * @deprecated As of VaultAPI 1.4 use {{@link #createPlayerAccount(OfflinePlayer, String)} instead. */ @Deprecated - public boolean createPlayerAccount(String playerName, String worldName); + boolean createPlayerAccount(String playerName, String worldName); /** * Attempts to create a player account for the given player on the specified world @@ -353,5 +353,5 @@ public interface Economy { * @param worldName String name of the world * @return if the account creation was successful */ - public boolean createPlayerAccount(OfflinePlayer player, String worldName); + boolean createPlayerAccount(OfflinePlayer player, String worldName); } From 6e69e209e177e685692a6589e80362b0a241e91e Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 12:18:27 -0400 Subject: [PATCH 20/44] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5450c1b..9686bf3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /bin/ /.idea/ /VaultAPI.iml +/VaultUnlockedAPI.iml From ab14d7fd87b5c19729c1bf61a7fbd54cf3b972af Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 12:21:28 -0400 Subject: [PATCH 21/44] Update gitignore --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 37cc1ae..1755f3a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,12 @@ /.project /.settings /bin/ +VaultUnlockedAPI.iml +.idea/vcs.xml +.idea/workspace.xml +.idea/compiler.xml +.idea/discord.xml +.idea/jarRepositories.xml +.idea/misc.xml +.idea/modules.xml +.idea/encodings.xml From 6a88d39a7c0a994ac344bec46b26789818e582ea Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 12:28:41 -0400 Subject: [PATCH 22/44] Cleanup code from vault2. --- .../net/milkbowl/vault2/economy/Economy.java | 70 +++++++++---------- .../vault2/economy/EconomyResponse.java | 2 +- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index 0212c5a..4e5bc00 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -38,21 +38,21 @@ public interface Economy { * * @return true if the server's economy plugin has properly enabled. */ - public boolean isEnabled(); + boolean isEnabled(); /** * Gets name of the economy plugin. * * @return Name of the active economy plugin on the server. */ - public String getName(); + String getName(); /** * Returns true if the economy plugin supports banks. * * @return true if the economy plugin supports banks. */ - public boolean hasBankSupport(); + boolean hasBankSupport(); /* * Currency-related methods follow. @@ -66,7 +66,7 @@ public interface Economy { * @return number of digits after the decimal point this plugin supports or -1 * if no rounding occurs. */ - public int fractionalDigits(); + int fractionalDigits(); /** * Plugins use this method to format a given BigDecimal amount into a human @@ -75,7 +75,7 @@ public interface Economy { * @param amount to format. * @return Human readable string describing amount, ie 5 Dollars or 5.55 Pounds. */ - public String format(BigDecimal amount); + String format(BigDecimal amount); /** * Returns the name of the currency in plural form. If the economy being used @@ -83,7 +83,7 @@ public interface Economy { * * @return name of the currency (plural) ie: Dollars or Pounds. */ - public String currencyNamePlural(); + String currencyNamePlural(); /** * Returns the name of the currency in singular form. If the economy being used @@ -91,7 +91,7 @@ public interface Economy { * * @return name of the currency (singular) ie: Dollar or Pound. */ - public String currencyNameSingular(); + String currencyNameSingular(); /* * Account-related methods follow. @@ -104,7 +104,7 @@ public interface Economy { * @param name UUID associated with the account. * @return true if the account creation was successful. */ - public boolean createAccount(UUID uuid, String name); + boolean createAccount(UUID uuid, String name); /** * Attempts to create an account for the given UUID on the specified world @@ -116,7 +116,7 @@ public interface Economy { * @param worldName String name of the world. * @return if the account creation was successful */ - public boolean createAccount(UUID uuid, String name, String worldName); + boolean createAccount(UUID uuid, String name, String worldName); /** * Returns a map that represents all of the UUIDs which have accounts in the @@ -126,7 +126,7 @@ public interface Economy { * @return a {@link Map} composed of the accounts keyed by their UUID, along * with their associated last-known-name. */ - public Map getUUIDNameMap(); + Map getUUIDNameMap(); /** * Gets the last known name of an account owned by the given UUID. Required for @@ -135,7 +135,7 @@ public interface Economy { * @param uuid UUID associated with the account. * @return name of the account owner. */ - public String getAccountName(UUID uuid); + String getAccountName(UUID uuid); /** * Checks if this UUID has an account yet. @@ -143,7 +143,7 @@ public interface Economy { * @param uuid UUID to check for an existing account. * @return true if the UUID has an account. */ - public boolean hasAccount(UUID uuid); + boolean hasAccount(UUID uuid); /** * Checks if this UUID has an account yet on the given world. @@ -152,7 +152,7 @@ public interface Economy { * @param worldName world-specific account. * @return if the UUID has an account. */ - public boolean hasAccount(UUID uuid, String worldName); + boolean hasAccount(UUID uuid, String worldName); /** * A method which changes the name associated with the given UUID in the @@ -163,7 +163,7 @@ public interface Economy { * Map map. * @return true if the name change is successful. */ - public boolean renameAccount(UUID uuid, String name); + boolean renameAccount(UUID uuid, String name); /* * Account balance related methods follow. @@ -175,7 +175,7 @@ public interface Economy { * @param uuid UUID of the account to get a balance for. * @return Amount currently held in account associated with the given UUID. */ - public BigDecimal getBalance(UUID uuid); + BigDecimal getBalance(UUID uuid); /** * Gets balance of a UUID on the specified world. IMPLEMENTATION SPECIFIC - if @@ -185,7 +185,7 @@ public interface Economy { * @param world name of the world. * @return Amount currently held in account associated with the given UUID. */ - public BigDecimal getBalance(UUID uuid, String world); + BigDecimal getBalance(UUID uuid, String world); /** * Checks if the account associated with the given UUID has the amount - DO NOT @@ -195,7 +195,7 @@ public interface Economy { * @param amount the amount to check for. * @return True if UUID has amount, False else wise. */ - public boolean has(UUID uuid, BigDecimal amount); + boolean has(UUID uuid, BigDecimal amount); /** * Checks if the account associated with the given UUID has the amount in the @@ -208,7 +208,7 @@ public interface Economy { * @return True if UUID has amount in the given world, * False else wise. */ - public boolean has(UUID uuid, String worldName, BigDecimal amount); + boolean has(UUID uuid, String worldName, BigDecimal amount); /** * Withdraw an amount from an account associated with a UUID - DO NOT USE @@ -220,7 +220,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - public EconomyResponse withdraw(UUID uuid, BigDecimal amount); + EconomyResponse withdraw(UUID uuid, BigDecimal amount); /** * Withdraw an amount from an account associated with a UUID on a given world - @@ -234,7 +234,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - public EconomyResponse withdraw(UUID uuid, String worldName, BigDecimal amount); + EconomyResponse withdraw(UUID uuid, String worldName, BigDecimal amount); /** * Deposit an amount to an account associated with the given UUID - DO NOT USE @@ -246,7 +246,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - public EconomyResponse deposit(UUID uuid, BigDecimal amount); + EconomyResponse deposit(UUID uuid, BigDecimal amount); /** * Deposit an amount to an account associated with a UUID on a given world - @@ -260,7 +260,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - public EconomyResponse deposit(UUID uuid, String worldName, BigDecimal amount); + EconomyResponse deposit(UUID uuid, String worldName, BigDecimal amount); /* * Bank methods follow. @@ -274,7 +274,7 @@ public interface Economy { * @param uuid UUID of the account should be linked to. * @return true if bank creation is successful. */ - public boolean createBank(String name, UUID uuid); + boolean createBank(String name, UUID uuid); /** * Deletes a bank account with the specified UUID. @@ -282,7 +282,7 @@ public interface Economy { * @param uuid UUID of the bank to be deleted. * @return true if the operation completed successfully */ - public boolean deleteBank(UUID uuid); + boolean deleteBank(UUID uuid); /** * Returns a map that represents all of the UUIDs which have banks in the @@ -292,7 +292,7 @@ public interface Economy { * @return a {@link Map} composed of the accounts keyed by their UUID, along * with their associated last-known-name. */ - public Map getBankUUIDNameMap(); + Map getBankUUIDNameMap(); /** * Gets the last known name of an bank with the given UUID. Required for @@ -301,7 +301,7 @@ public interface Economy { * @param uuid UUID to look up. * @return name of the bank. */ - public String getBankAccountName(UUID uuid); + String getBankAccountName(UUID uuid); /** * Checks if this UUID has a bank yet. @@ -309,7 +309,7 @@ public interface Economy { * @param uuid UUID to check. * @return true if the UUID has an account. */ - public boolean hasBankAccount(UUID uuid); + boolean hasBankAccount(UUID uuid); /** * A method which changes the name associated with the given UUID in the @@ -320,7 +320,7 @@ public interface Economy { * Map map. * @return true if the name change is successful. */ - public boolean renameBankAccount(UUID uuid, String name); + boolean renameBankAccount(UUID uuid, String name); /** * Returns the amount the bank has. @@ -328,7 +328,7 @@ public interface Economy { * @param uuid UUID of the account. * @return amount which the bank holds as a balance. */ - public BigDecimal bankBalance(UUID uuid); + BigDecimal bankBalance(UUID uuid); /** * Returns true or false whether the bank has the amount specified - DO NOT USE @@ -338,7 +338,7 @@ public interface Economy { * @param amount to check for * @return true if the bank has the given amount. */ - public boolean bankHas(UUID uuid, BigDecimal amount); + boolean bankHas(UUID uuid, BigDecimal amount); /** * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS. @@ -349,7 +349,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - public EconomyResponse bankWithdraw(String name, BigDecimal amount); + EconomyResponse bankWithdraw(String name, BigDecimal amount); /** * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS. @@ -360,7 +360,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - public EconomyResponse bankDeposit(String name, BigDecimal amount); + EconomyResponse bankDeposit(String name, BigDecimal amount); /** * Check if a UUID is the owner of a bank account. @@ -369,7 +369,7 @@ public interface Economy { * @param bankUUID UUID of the bank account to check ownership of. * @return true if the uuid is the owner of the bank associated with bankUUID. */ - public boolean isBankOwner(UUID uuid, UUID bankUUID); + boolean isBankOwner(UUID uuid, UUID bankUUID); /** * Check if the UUID is a member of the bank account @@ -378,12 +378,12 @@ public interface Economy { * @param bankUUID UUID of the bank account to check membership of. * @return @return true if the uuid is a member of the bank associated with bankUUID. */ - public boolean isBankMember(UUID uuid, UUID bankUUID); + boolean isBankMember(UUID uuid, UUID bankUUID); /** * Gets the list of banks' UUIDs. * * @return the List of Banks' UUIDs. */ - public List getBanks(); + List getBanks(); } diff --git a/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java b/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java index 7e00634..6b6a881 100644 --- a/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java +++ b/src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java @@ -29,7 +29,7 @@ public class EconomyResponse { /** * Enum for types of Responses indicating the status of a method call. */ - public static enum ResponseType { + public enum ResponseType { SUCCESS(1), FAILURE(2), NOT_IMPLEMENTED(3); From eb5b5c64965c6c794411819815346ba341a21fe4 Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 12:55:11 -0400 Subject: [PATCH 23/44] Multicurrency support, and plugin name for transactions to attach source to them. --- .../net/milkbowl/vault2/economy/Economy.java | 255 ++++++++++++++---- 1 file changed, 210 insertions(+), 45 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index 4e5bc00..9565fd4 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -54,6 +54,13 @@ public interface Economy { */ boolean hasBankSupport(); + /** + * Returns true if the economy plugin supports multiple currencies. + * + * @return true if the economy plugin supports multiple currencies. + */ + boolean hasMultiCurrencySupport(); + /* * Currency-related methods follow. */ @@ -69,29 +76,56 @@ public interface Economy { int fractionalDigits(); /** - * Plugins use this method to format a given BigDecimal amount into a human - * readable amount using your economy plugin's currency names/conventions. + * Plugins use this method to format a given BigDecimal amount into a human-readable + * amount using your economy plugin's currency names/conventions. * * @param amount to format. - * @return Human readable string describing amount, ie 5 Dollars or 5.55 Pounds. + * @param currency the currency to use for the format. + * + * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. */ - String format(BigDecimal amount); + String format(BigDecimal amount, String currency); /** - * Returns the name of the currency in plural form. If the economy being used - * does not support currency names then an empty string will be returned. + * Returns true if a currency with the specified name exists. + * + * @param currency the currency to use. + * + * @return true if a currency with the specified name exists. + */ + boolean hasCurrency(String currency); + + /** + * Returns the default currency that is able to be used in API operations. May not be human-readable. * + * @return name of the currency i.e.: USD + */ + String defaultCurrency(); + + /** + * Returns the name of the default currency in plural form. If the economy being used + * does not support currency names then an empty string will be returned. + * * @return name of the currency (plural) ie: Dollars or Pounds. */ - String currencyNamePlural(); + String defaultCurrencyNamePlural(); /** - * Returns the name of the currency in singular form. If the economy being used + * Returns the name of the default currency in singular form. If the economy being used * does not support currency names then an empty string will be returned. * * @return name of the currency (singular) ie: Dollar or Pound. */ - String currencyNameSingular(); + String defaultCurrencyNameSingular(); + + /** + * Returns a list of currencies used by the economy plugin. These are able to be used + * in the calls in the methods of the API. May not be human-readable. + * + * @return list of currencies used by the economy plugin. These are able to be used + * in the calls in the methods of the API. + */ + List currencies(); /* * Account-related methods follow. @@ -119,7 +153,7 @@ public interface Economy { boolean createAccount(UUID uuid, String name, String worldName); /** - * Returns a map that represents all of the UUIDs which have accounts in the + * Returns a map that represents all the UUIDs which have accounts in the * plugin, as well as their last-known-name. This is used for Vault's economy * converter and should be given every account available. * @@ -171,96 +205,163 @@ public interface Economy { /** * Gets balance of an account associated with a UUID. - * + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid UUID of the account to get a balance for. * @return Amount currently held in account associated with the given UUID. */ - BigDecimal getBalance(UUID uuid); + BigDecimal getBalance(String pluginName, 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 pluginName The name of the plugin that is calling the method. + * @param uuid 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. + */ + BigDecimal getBalance(String pluginName, UUID uuid, 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 pluginName The name of the plugin that is calling the method. * @param uuid UUID of the account to get a balance for. * @param world name of the world. + * @param currency the currency to use. * @return Amount currently held in account associated with the given UUID. */ - BigDecimal getBalance(UUID uuid, String world); + BigDecimal getBalance(String pluginName, UUID uuid, String world, String currency); /** * Checks if the account associated with the given UUID has the amount - DO NOT * USE NEGATIVE AMOUNTS. - * + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid the UUID associated with the account to check the balance of. * @param amount the amount to check for. * @return True if UUID has amount, False else wise. */ - boolean has(UUID uuid, BigDecimal amount); + boolean has(String pluginName, UUID uuid, BigDecimal 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 pluginName The name of the plugin that is calling the method. * @param uuid the UUID associated with the account to check the balance of. * @param worldName the name of the world to check in. * @param amount the amount to check for. * @return True if UUID has amount in the given world, * False else wise. */ - boolean has(UUID uuid, String worldName, BigDecimal amount); + boolean has(String pluginName, UUID uuid, String worldName, BigDecimal 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 pluginName The name of the plugin that is calling the method. + * @param uuid the UUID associated with the account to check the balance of. + * @param worldName the name of the world to check in. + * @param currency the currency to use. + * @param amount the amount to check for. + * @return True if UUID has amount in the given world, + * False else wise. + */ + boolean has(String pluginName, UUID uuid, String worldName, String currency, BigDecimal amount); /** * Withdraw an amount from an account associated with a UUID - DO NOT USE * NEGATIVE AMOUNTS. - * + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid the UUID associated with the account to withdraw from. * @param amount Amount to withdraw. * @return {@link EconomyResponse} which includes the Economy plugin's * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - EconomyResponse withdraw(UUID uuid, BigDecimal amount); + EconomyResponse withdraw(String pluginName, UUID uuid, BigDecimal 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 pluginName The name of the plugin that is calling the method. + * @param uuid the UUID associated with the account to withdraw from. + * @param worldName the name of the world to check in. + * @param amount Amount to withdraw. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. + */ + EconomyResponse withdraw(String pluginName, UUID uuid, String worldName, BigDecimal 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 pluginName The name of the plugin that is calling the method. * @param uuid the UUID associated with the account to withdraw from. * @param worldName the name of the world to check in. + * @param currency the currency to use. * @param amount Amount to withdraw. * @return {@link EconomyResponse} which includes the Economy plugin's * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - EconomyResponse withdraw(UUID uuid, String worldName, BigDecimal amount); + EconomyResponse withdraw(String pluginName, UUID uuid, String worldName, String currency, BigDecimal amount); /** * Deposit an amount to an account associated with the given UUID - DO NOT USE * NEGATIVE AMOUNTS. - * + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid the UUID associated with the account to deposit to. * @param amount Amount to deposit. * @return {@link EconomyResponse} which includes the Economy plugin's * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - EconomyResponse deposit(UUID uuid, BigDecimal amount); + EconomyResponse deposit(String pluginName, UUID uuid, BigDecimal amount); /** * Deposit an amount to 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 pluginName The name of the plugin that is calling the method. + * @param uuid the UUID associated with the account to deposit to. + * @param worldName the name of the world to check in. + * @param amount Amount to deposit. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. + */ + EconomyResponse deposit(String pluginName, UUID uuid, String worldName, BigDecimal amount); + + /** + * Deposit an amount to 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 pluginName The name of the plugin that is calling the method. * @param uuid the UUID associated with the account to deposit to. * @param worldName the name of the world to check in. + * @param currency the currency to use. * @param amount Amount to deposit. * @return {@link EconomyResponse} which includes the Economy plugin's * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - EconomyResponse deposit(UUID uuid, String worldName, BigDecimal amount); + EconomyResponse deposit(String pluginName, UUID uuid, String worldName, String currency, BigDecimal amount); /* * Bank methods follow. @@ -269,20 +370,22 @@ public interface Economy { /** * Creates a bank account with the specified name and the given UUID as the * owner. - * + * + * @param pluginName The name of the plugin that is calling the method. * @param name Name of account. * @param uuid UUID of the account should be linked to. * @return true if bank creation is successful. */ - boolean createBank(String name, UUID uuid); + boolean createBank(String pluginName, String name, UUID uuid); /** * Deletes a bank account with the specified UUID. - * + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid UUID of the bank to be deleted. * @return true if the operation completed successfully */ - boolean deleteBank(UUID uuid); + boolean deleteBank(String pluginName, UUID uuid); /** * Returns a map that represents all of the UUIDs which have banks in the @@ -297,7 +400,7 @@ public interface Economy { /** * Gets the last known name of an bank with the given UUID. Required for * messages to be more human-readable than UUIDs alone can provide. - * + * * @param uuid UUID to look up. * @return name of the bank. */ @@ -305,66 +408,128 @@ public interface Economy { /** * Checks if this UUID has a bank yet. - * + * * @param uuid UUID to check. * @return true if the UUID has an account. */ boolean hasBankAccount(UUID uuid); + /** + * Checks if the specified bank account supports the specified currency. + * + * @param uuid UUID of the account. + * @param currency the currency to use. + * @return true if the bank supports the currency + */ + boolean bankSupportsCurrency(UUID uuid, String currency); + /** * A method which changes the name associated with the given UUID in the * Map received from {@link #getBankUUIDNameMap()}. - * + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid 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. */ - boolean renameBankAccount(UUID uuid, String name); + boolean renameBankAccount(String pluginName, UUID uuid, String name); /** * Returns the amount the bank has. - * + * + * @param pluginName The name of the plugin that is calling the method. + * @param uuid UUID of the account. + * @return amount which the bank holds as a balance. + */ + BigDecimal bankBalance(String pluginName, UUID uuid); + + /** + * Returns the amount the bank has. + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid UUID of the account. + * @param currency the currency to use. * @return amount which the bank holds as a balance. */ - BigDecimal bankBalance(UUID uuid); + BigDecimal bankBalance(String pluginName, UUID uuid, String currency); /** * Returns true or false whether the bank has the amount specified - DO NOT USE * NEGATIVE AMOUNTS. - * + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid UUID of the account. * @param amount to check for * @return true if the bank has the given amount. */ - boolean bankHas(UUID uuid, BigDecimal amount); + boolean bankHas(String pluginName, UUID uuid, BigDecimal amount); + + /** + * Returns true or false whether the bank has the amount specified - DO NOT USE + * NEGATIVE AMOUNTS. + * + * @param pluginName The name of the plugin that is calling the method. + * @param uuid UUID of the account. + * @param currency the currency to use. + * @param amount to check for + * @return true if the bank has the given amount. + */ + boolean bankHas(String pluginName, UUID uuid, String currency, BigDecimal amount); /** * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS. - * + * + * @param pluginName The name of the plugin that is calling the method. + * @param uuid UUID of the account. + * @param amount to withdraw. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. + */ + EconomyResponse bankWithdraw(String pluginName, UUID uuid, BigDecimal amount); + + /** + * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS. + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid UUID of the account. + * @param currency the currency to use. * @param amount to withdraw. * @return {@link EconomyResponse} which includes the Economy plugin's * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - EconomyResponse bankWithdraw(String name, BigDecimal amount); + EconomyResponse bankWithdraw(String pluginName, UUID uuid, String currency, BigDecimal amount); /** * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS. - * + * + * @param pluginName The name of the plugin that is calling the method. + * @param uuid UUID of the account. + * @param amount to deposit. + * @return {@link EconomyResponse} which includes the Economy plugin's + * {@link ResponseType} as to whether the transaction was a Success, + * Failure, Unsupported. + */ + EconomyResponse bankDeposit(String pluginName, UUID uuid, BigDecimal amount); + + /** + * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS. + * + * @param pluginName The name of the plugin that is calling the method. * @param uuid UUID of the account. + * @param currency the currency to use. * @param amount to deposit. * @return {@link EconomyResponse} which includes the Economy plugin's * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ - EconomyResponse bankDeposit(String name, BigDecimal amount); + EconomyResponse bankDeposit(String pluginName, UUID uuid, String currency, BigDecimal amount); /** * Check if a UUID is the owner of a bank account. - * + * * @param uuid UUID of the player/object who might be an owner. * @param bankUUID UUID of the bank account to check ownership of. * @return true if the uuid is the owner of the bank associated with bankUUID. @@ -373,8 +538,8 @@ public interface Economy { /** * Check if the UUID is a member of the bank account - * - * @param uuid UUID of the player/object who might be a member.. + * + * @param uuid UUID of the player/object who might be a member. * @param bankUUID UUID of the bank account to check membership of. * @return @return true if the uuid is a member of the bank associated with bankUUID. */ From b4ff40974d9100074e129df0f3ea1d94ee92651c Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 13:34:42 -0400 Subject: [PATCH 24/44] List -> collection. --- src/main/java/net/milkbowl/vault2/economy/Economy.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index 9565fd4..f2bd0d8 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -17,6 +17,7 @@ package net.milkbowl.vault2.economy; import java.math.BigDecimal; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.UUID; @@ -125,7 +126,7 @@ public interface Economy { * @return list of currencies used by the economy plugin. These are able to be used * in the calls in the methods of the API. */ - List currencies(); + Collection currencies(); /* * Account-related methods follow. @@ -550,5 +551,5 @@ public interface Economy { * * @return the List of Banks' UUIDs. */ - List getBanks(); + Collection getBanks(); } From 9f70379f9f501a61dd27a6375b8fa89d930694ea Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 13:45:36 -0400 Subject: [PATCH 25/44] Optional for last known name since it could not exist depending on calls done before. --- src/main/java/net/milkbowl/vault2/economy/Economy.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index f2bd0d8..b76b467 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; import net.milkbowl.vault2.economy.EconomyResponse.ResponseType; @@ -168,9 +169,10 @@ public interface Economy { * messages to be more human-readable than UUIDs alone can provide. * * @param uuid UUID associated with the account. - * @return name of the account owner. + * @return An optional containing the last known name if the account exists, otherwise an empty + * optional. */ - String getAccountName(UUID uuid); + Optional getAccountName(UUID uuid); /** * Checks if this UUID has an account yet. From 41028bee0a1768bbec96420a6ceac2f125be2b27 Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 14:13:03 -0400 Subject: [PATCH 26/44] Add alt format method. --- src/main/java/net/milkbowl/vault2/economy/Economy.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index b76b467..6dbba51 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -77,6 +77,16 @@ public interface Economy { */ int fractionalDigits(); + /** + * Plugins use this method to format a given BigDecimal amount into a human-readable + * amount using your economy plugin's currency names/conventions. + * + * @param amount to format. + * + * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. + */ + String format(BigDecimal amount); + /** * Plugins use this method to format a given BigDecimal amount into a human-readable * amount using your economy plugin's currency names/conventions. From b4267e3cc118aa97928ad197653402d9e4e969bd Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 14:19:18 -0400 Subject: [PATCH 27/44] Update pom. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a45a3b1..9c84348 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.milkbowl.vault VaultUnlockedAPI - 2.0 + 2.1 VaultUnlockedAPI From a36fcb4dd2fde5f5ba2f3fd2c63631a0561b5eb0 Mon Sep 17 00:00:00 2001 From: Daniel V Date: Wed, 12 Jun 2024 14:19:40 -0400 Subject: [PATCH 28/44] Update pom. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ba58d7..896f824 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ How to include the API with Maven: net.milkbowl.vault VaultUnlockedAPI - 2.0 + 2.1 provided @@ -24,7 +24,7 @@ repositories { maven { url 'https://repo.codemc.org/repository/maven-public' } } dependencies { - compileOnly "net.milkbowl.vault:VaultUnlockedAPI:2.0" + compileOnly "net.milkbowl.vault:VaultUnlockedAPI:2.1" } ``` From 4f68b49ed59f48a67dc0249a5f4d7fe02236001b Mon Sep 17 00:00:00 2001 From: Daniel V Date: Thu, 13 Jun 2024 09:56:33 -0400 Subject: [PATCH 29/44] Add NotNull to specific methods for clarity. --- pom.xml | 8 ++++- .../net/milkbowl/vault2/economy/Economy.java | 36 ++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 9c84348..3b04f6a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.milkbowl.vault VaultUnlockedAPI - 2.1 + 2.2 VaultUnlockedAPI @@ -83,6 +83,12 @@ test true + + org.jetbrains + annotations + 24.0.0 + compile + diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index 6dbba51..cad75df 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -24,6 +24,7 @@ import java.util.UUID; import net.milkbowl.vault2.economy.EconomyResponse.ResponseType; +import org.jetbrains.annotations.NotNull; /** * The main economy API @@ -47,6 +48,7 @@ public interface Economy { * * @return Name of the active economy plugin on the server. */ + @NotNull String getName(); /** @@ -75,6 +77,7 @@ public interface Economy { * @return number of digits after the decimal point this plugin supports or -1 * if no rounding occurs. */ + @NotNull int fractionalDigits(); /** @@ -85,6 +88,7 @@ public interface Economy { * * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. */ + @NotNull String format(BigDecimal amount); /** @@ -96,6 +100,7 @@ public interface Economy { * * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. */ + @NotNull String format(BigDecimal amount, String currency); /** @@ -108,11 +113,14 @@ public interface Economy { boolean hasCurrency(String currency); /** - * Returns the default currency that is able to be used in API operations. May not be human-readable. - * - * @return name of the currency i.e.: USD + * Used to get the default currency. This could be the default currency for the server globally or + * for the default world if the implementation supports multi-world. + * @return The currency that is the default for the server if multi-world support is not available + * otherwise the default for the default world. + * */ - String defaultCurrency(); + @NotNull + String getDefaultCurrency(); /** * Returns the name of the default currency in plural form. If the economy being used @@ -120,6 +128,7 @@ public interface Economy { * * @return name of the currency (plural) ie: Dollars or Pounds. */ + @NotNull String defaultCurrencyNamePlural(); /** @@ -128,6 +137,7 @@ public interface Economy { * * @return name of the currency (singular) ie: Dollar or Pound. */ + @NotNull String defaultCurrencyNameSingular(); /** @@ -223,6 +233,7 @@ public interface Economy { * @param uuid UUID of the account to get a balance for. * @return Amount currently held in account associated with the given UUID. */ + @NotNull BigDecimal getBalance(String pluginName, UUID uuid); /** @@ -234,6 +245,7 @@ public interface Economy { * @param world name of the world. * @return Amount currently held in account associated with the given UUID. */ + @NotNull BigDecimal getBalance(String pluginName, UUID uuid, String world); /** @@ -246,6 +258,7 @@ public interface Economy { * @param currency the currency to use. * @return Amount currently held in account associated with the given UUID. */ + @NotNull BigDecimal getBalance(String pluginName, UUID uuid, String world, String currency); /** @@ -299,6 +312,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse withdraw(String pluginName, UUID uuid, BigDecimal amount); /** @@ -314,6 +328,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse withdraw(String pluginName, UUID uuid, String worldName, BigDecimal amount); /** @@ -330,6 +345,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse withdraw(String pluginName, UUID uuid, String worldName, String currency, BigDecimal amount); /** @@ -343,6 +359,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse deposit(String pluginName, UUID uuid, BigDecimal amount); /** @@ -358,6 +375,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse deposit(String pluginName, UUID uuid, String worldName, BigDecimal amount); /** @@ -374,6 +392,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse deposit(String pluginName, UUID uuid, String worldName, String currency, BigDecimal amount); /* @@ -401,7 +420,7 @@ public interface Economy { boolean deleteBank(String pluginName, UUID uuid); /** - * Returns a map that represents all of the UUIDs which have banks in the + * Returns a map that represents all the UUIDs which have banks in the * plugin, as well as their last-known-name. This is used for Vault's economy * converter and should be given every account available. * @@ -417,6 +436,7 @@ public interface Economy { * @param uuid UUID to look up. * @return name of the bank. */ + @NotNull String getBankAccountName(UUID uuid); /** @@ -455,6 +475,7 @@ public interface Economy { * @param uuid UUID of the account. * @return amount which the bank holds as a balance. */ + @NotNull BigDecimal bankBalance(String pluginName, UUID uuid); /** @@ -465,6 +486,7 @@ public interface Economy { * @param currency the currency to use. * @return amount which the bank holds as a balance. */ + @NotNull BigDecimal bankBalance(String pluginName, UUID uuid, String currency); /** @@ -500,6 +522,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse bankWithdraw(String pluginName, UUID uuid, BigDecimal amount); /** @@ -513,6 +536,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse bankWithdraw(String pluginName, UUID uuid, String currency, BigDecimal amount); /** @@ -525,6 +549,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse bankDeposit(String pluginName, UUID uuid, BigDecimal amount); /** @@ -538,6 +563,7 @@ public interface Economy { * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ + @NotNull EconomyResponse bankDeposit(String pluginName, UUID uuid, String currency, BigDecimal amount); /** From f60ac4f3a26ef260a2b241a2b5a2de25959de6b8 Mon Sep 17 00:00:00 2001 From: Daniel V Date: Thu, 13 Jun 2024 10:03:16 -0400 Subject: [PATCH 30/44] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 896f824..ce3d0f3 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ How to include the API with Maven: net.milkbowl.vault VaultUnlockedAPI - 2.1 + 2.2 provided From f158f980faa7b16b3665725d4c63d8e420d89f51 Mon Sep 17 00:00:00 2001 From: Daniel V Date: Sat, 10 Aug 2024 23:15:27 -0400 Subject: [PATCH 31/44] Update version. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b04f6a..d61402b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.milkbowl.vault VaultUnlockedAPI - 2.2 + 2.3 VaultUnlockedAPI From 92bc7ae92a75584bf1ca1a491f008fd1cb948cea Mon Sep 17 00:00:00 2001 From: Daniel V Date: Sun, 25 Aug 2024 08:13:36 -0400 Subject: [PATCH 32/44] Update Version; Readd AbstractEconomy to old source branch. --- README.md | 4 +- pom.xml | 2 +- .../vault/economy/AbstractEconomy.java | 87 +++++++++++++++++++ 3 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java diff --git a/README.md b/README.md index ce3d0f3..366f881 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ How to include the API with Maven: net.milkbowl.vault VaultUnlockedAPI - 2.2 + 2.4 provided @@ -24,7 +24,7 @@ repositories { maven { url 'https://repo.codemc.org/repository/maven-public' } } dependencies { - compileOnly "net.milkbowl.vault:VaultUnlockedAPI:2.1" + compileOnly "net.milkbowl.vault:VaultUnlockedAPI:2.4" } ``` diff --git a/pom.xml b/pom.xml index d61402b..bd6ef4b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.milkbowl.vault VaultUnlockedAPI - 2.3 + 2.4 VaultUnlockedAPI diff --git a/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java b/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java new file mode 100644 index 0000000..00a1523 --- /dev/null +++ b/src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java @@ -0,0 +1,87 @@ +package net.milkbowl.vault.economy; + +import org.bukkit.OfflinePlayer; + +@SuppressWarnings("deprecation") +public abstract class AbstractEconomy implements Economy { + + @Override + public boolean hasAccount(OfflinePlayer player) { + if (player.getName() == null) return false; + return hasAccount(player.getName()); + } + + @Override + public boolean hasAccount(OfflinePlayer player, String worldName) { + if (player.getName() == null) return false; + return hasAccount(player.getName(), worldName); + } + + @Override + public double getBalance(OfflinePlayer player) { + return getBalance(player.getName()); + } + + @Override + public double getBalance(OfflinePlayer player, String world) { + return getBalance(player.getName(), world); + } + + @Override + public boolean has(OfflinePlayer player, double amount) { + if (player.getName() == null) return false; + return has(player.getName(), amount); + } + + @Override + public boolean has(OfflinePlayer player, String worldName, double amount) { + if (player.getName() == null) return false; + return has(player.getName(), worldName, amount); + } + + @Override + public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) { + return withdrawPlayer(player.getName(), amount); + } + + @Override + public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount) { + return withdrawPlayer(player.getName(), worldName, amount); + } + + @Override + public EconomyResponse depositPlayer(OfflinePlayer player, double amount) { + return depositPlayer(player.getName(), amount); + } + + @Override + public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount) { + return depositPlayer(player.getName(), worldName, amount); + } + + @Override + public EconomyResponse createBank(String name, OfflinePlayer player) { + return createBank(name, player.getName()); + } + + @Override + public EconomyResponse isBankOwner(String name, OfflinePlayer player) { + return isBankOwner(name, player.getName()); + } + + @Override + public EconomyResponse isBankMember(String name, OfflinePlayer player) { + return isBankMember(name, player.getName()); + } + + @Override + public boolean createPlayerAccount(OfflinePlayer player) { + return createPlayerAccount(player.getName()); + } + + @Override + public boolean createPlayerAccount(OfflinePlayer player, String worldName) { + return createPlayerAccount(player.getName(), worldName); + } + +} \ No newline at end of file From 741f317f4bde909365f0e7d33bf75ff00e07aa9a Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Fri, 30 Aug 2024 10:38:27 -0400 Subject: [PATCH 33/44] Replace banks with accounts that have members and permissions. --- pom.xml | 2 +- .../vault2/economy/AccountPermission.java | 37 ++ .../net/milkbowl/vault2/economy/Economy.java | 336 +++++++----------- 3 files changed, 168 insertions(+), 207 deletions(-) create mode 100644 src/main/java/net/milkbowl/vault2/economy/AccountPermission.java diff --git a/pom.xml b/pom.xml index bd6ef4b..0ebc17e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.milkbowl.vault VaultUnlockedAPI - 2.4 + 2.5 VaultUnlockedAPI diff --git a/src/main/java/net/milkbowl/vault2/economy/AccountPermission.java b/src/main/java/net/milkbowl/vault2/economy/AccountPermission.java new file mode 100644 index 0000000..b604263 --- /dev/null +++ b/src/main/java/net/milkbowl/vault2/economy/AccountPermission.java @@ -0,0 +1,37 @@ +package net.milkbowl.vault2.economy; +/* + * The New Kings + * Copyright (C) 2022 - 2024 Daniel "creatorfromhell" Vidmar + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/** + * AccountPermission + * + * @author creatorfromhell + * @since 0.0.1.0 + */ +public enum AccountPermission { + + DEPOSIT, + WITHDRAW, + BALANCE, + TRANSFER_OWNERSHIP, + INVITE_MEMBER, + REMOVE_MEMBER, + CHANGE_MEMBER_PERMISSION, + OWNER, + DELETE +} \ No newline at end of file diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index cad75df..24e07b7 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -16,16 +16,15 @@ package net.milkbowl.vault2.economy; +import net.milkbowl.vault2.economy.EconomyResponse.ResponseType; +import org.jetbrains.annotations.NotNull; + import java.math.BigDecimal; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.Optional; import java.util.UUID; -import net.milkbowl.vault2.economy.EconomyResponse.ResponseType; -import org.jetbrains.annotations.NotNull; - /** * The main economy API * @@ -52,11 +51,11 @@ public interface Economy { String getName(); /** - * Returns true if the economy plugin supports banks. - * - * @return true if the economy plugin supports banks. + * Returns true if the economy plugin supports shared accounts. + * + * @return true if the economy plugin supports shared accounts. */ - boolean hasBankSupport(); + boolean hasSharedAccountSupport(); /** * Returns true if the economy plugin supports multiple currencies. @@ -101,7 +100,7 @@ public interface Economy { * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. */ @NotNull - String format(BigDecimal amount, String currency); + String format(BigDecimal amount, final String currency); /** * Returns true if a currency with the specified name exists. @@ -110,7 +109,7 @@ public interface Economy { * * @return true if a currency with the specified name exists. */ - boolean hasCurrency(String currency); + boolean hasCurrency(final String currency); /** * Used to get the default currency. This could be the default currency for the server globally or @@ -156,23 +155,23 @@ public interface Economy { /** * Attempts to create a account for the given UUID. * - * @param uuid UUID associated with the account. + * @param accountID UUID associated with the account. * @param name UUID associated with the account. * @return true if the account creation was successful. */ - boolean createAccount(UUID uuid, String name); + boolean createAccount(UUID accountID, final 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 UUID associated with the account. + * @param accountID UUID associated with the account. * @param name UUID associated with the account. * @param worldName String name of the world. * @return if the account creation was successful */ - boolean createAccount(UUID uuid, String name, String worldName); + boolean createAccount(UUID accountID, final String name, final String worldName); /** * Returns a map that represents all the UUIDs which have accounts in the @@ -188,89 +187,110 @@ public interface Economy { * 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 associated with the account. + * @param accountID UUID associated with the account. * @return An optional containing the last known name if the account exists, otherwise an empty * optional. */ - Optional getAccountName(UUID uuid); + Optional getAccountName(UUID accountID); /** * Checks if this UUID has an account yet. * - * @param uuid UUID to check for an existing account. + * @param accountID UUID to check for an existing account. * @return true if the UUID has an account. */ - boolean hasAccount(UUID uuid); + boolean hasAccount(UUID accountID); /** * Checks if this UUID has an account yet on the given world. * - * @param uuid UUID to check for an existing account. + * @param accountID UUID to check for an existing account. * @param worldName world-specific account. * @return if the UUID has an account. */ - boolean hasAccount(UUID uuid, String worldName); + boolean hasAccount(UUID accountID, final String worldName); /** * A method which changes the name associated with the given UUID in the - * Map received from {@link #getUUIDNameMap()}. + * Map received from {@link #getUUIDNameMap()}. * - * @param uuid UUID whose account is having a name change. + * @param accountID UUID whose account is having a name change. * @param name String name that will be associated with the UUID in the - * Map map. + * Map map. * @return true if the name change is successful. */ - boolean renameAccount(UUID uuid, String name); + boolean renameAccount(UUID accountID, final String name); /* * Account balance related methods follow. */ + /** + * Determines whether an account supports a specific currency. + * + * @param plugin the name of the plugin + * @param accountID the UUID of the account + * @param currency the currency to check support for + * @return true if the account supports the currency, false otherwise + */ + boolean accountSupportsCurrency(final String plugin, final UUID accountID, final String currency); + + /** + * Checks if the given account supports the specified currency in the given world. + * + * @param plugin the name of the plugin requesting the check + * @param accountID the UUID of the player account + * @param currency the currency code to check support for + * @param world the name of the world to check in + * @return true if the account supports the currency in the world, false otherwise + */ + boolean accountSupportsCurrency(final String plugin, final UUID accountID, final String currency, final String world); + /** * Gets balance of an account associated with a UUID. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account to get a balance for. + * @param accountID UUID of the account to get a balance for. * @return Amount currently held in account associated with the given UUID. */ @NotNull - BigDecimal getBalance(String pluginName, UUID uuid); + BigDecimal getBalance(final String pluginName, final UUID accountID); /** * 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 pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account to get a balance for. + * @param accountID 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. */ @NotNull - BigDecimal getBalance(String pluginName, UUID uuid, String world); + BigDecimal getBalance(final String pluginName, final UUID accountID, final 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 pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account to get a balance for. + * @param accountID UUID of the account to get a balance for. * @param world name of the world. * @param currency the currency to use. * @return Amount currently held in account associated with the given UUID. */ @NotNull - BigDecimal getBalance(String pluginName, UUID uuid, String world, String currency); + BigDecimal getBalance(final String pluginName, final UUID accountID, final String world, final String currency); /** * Checks if the account associated with the given UUID has the amount - DO NOT * USE NEGATIVE AMOUNTS. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to check the balance of. + * @param accountID the UUID associated with the account to check the balance of. * @param amount the amount to check for. * @return True if UUID has amount, False else wise. */ - boolean has(String pluginName, UUID uuid, BigDecimal amount); + boolean has(final String pluginName, final UUID accountID, final BigDecimal amount); /** * Checks if the account associated with the given UUID has the amount in the @@ -278,13 +298,13 @@ public interface Economy { * economy plugin does not support this the global balance will be returned. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to check the balance of. + * @param accountID the UUID associated with the account to check the balance of. * @param worldName the name of the world to check in. * @param amount the amount to check for. * @return True if UUID has amount in the given world, * False else wise. */ - boolean has(String pluginName, UUID uuid, String worldName, BigDecimal amount); + boolean has(final String pluginName, final UUID accountID, final String worldName, final BigDecimal amount); /** * Checks if the account associated with the given UUID has the amount in the @@ -292,28 +312,28 @@ public interface Economy { * economy plugin does not support this the global balance will be returned. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to check the balance of. + * @param accountID the UUID associated with the account to check the balance of. * @param worldName the name of the world to check in. * @param currency the currency to use. * @param amount the amount to check for. * @return True if UUID has amount in the given world, * False else wise. */ - boolean has(String pluginName, UUID uuid, String worldName, String currency, BigDecimal amount); + boolean has(final String pluginName, final UUID accountID, final String worldName, final String currency, final BigDecimal amount); /** * Withdraw an amount from an account associated with a UUID - DO NOT USE * NEGATIVE AMOUNTS. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to withdraw from. + * @param accountID the UUID associated with the account to withdraw from. * @param amount Amount to withdraw. * @return {@link EconomyResponse} which includes the Economy plugin's * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ @NotNull - EconomyResponse withdraw(String pluginName, UUID uuid, BigDecimal amount); + EconomyResponse withdraw(final String pluginName, final UUID accountID, final BigDecimal amount); /** * Withdraw an amount from an account associated with a UUID on a given world - @@ -321,7 +341,7 @@ public interface Economy { * does not support this the global balance will be returned. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to withdraw from. + * @param accountID the UUID associated with the account to withdraw from. * @param worldName the name of the world to check in. * @param amount Amount to withdraw. * @return {@link EconomyResponse} which includes the Economy plugin's @@ -329,7 +349,7 @@ public interface Economy { * Failure, Unsupported. */ @NotNull - EconomyResponse withdraw(String pluginName, UUID uuid, String worldName, BigDecimal amount); + EconomyResponse withdraw(final String pluginName, final UUID accountID, final String worldName, final BigDecimal amount); /** * Withdraw an amount from an account associated with a UUID on a given world - @@ -337,7 +357,7 @@ public interface Economy { * does not support this the global balance will be returned. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to withdraw from. + * @param accountID the UUID associated with the account to withdraw from. * @param worldName the name of the world to check in. * @param currency the currency to use. * @param amount Amount to withdraw. @@ -346,21 +366,21 @@ public interface Economy { * Failure, Unsupported. */ @NotNull - EconomyResponse withdraw(String pluginName, UUID uuid, String worldName, String currency, BigDecimal amount); + EconomyResponse withdraw(final String pluginName, final UUID accountID, final String worldName, final String currency, final BigDecimal amount); /** * Deposit an amount to an account associated with the given UUID - DO NOT USE * NEGATIVE AMOUNTS. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to deposit to. + * @param accountID the UUID associated with the account to deposit to. * @param amount Amount to deposit. * @return {@link EconomyResponse} which includes the Economy plugin's * {@link ResponseType} as to whether the transaction was a Success, * Failure, Unsupported. */ @NotNull - EconomyResponse deposit(String pluginName, UUID uuid, BigDecimal amount); + EconomyResponse deposit(final String pluginName, final UUID accountID, final BigDecimal amount); /** * Deposit an amount to an account associated with a UUID on a given world - @@ -368,7 +388,7 @@ public interface Economy { * does not support this the global balance will be returned. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to deposit to. + * @param accountID the {@link UUID} associated with the account to deposit to. * @param worldName the name of the world to check in. * @param amount Amount to deposit. * @return {@link EconomyResponse} which includes the Economy plugin's @@ -376,7 +396,7 @@ public interface Economy { * Failure, Unsupported. */ @NotNull - EconomyResponse deposit(String pluginName, UUID uuid, String worldName, BigDecimal amount); + EconomyResponse deposit(final String pluginName, final UUID accountID, final String worldName, final BigDecimal amount); /** * Deposit an amount to an account associated with a UUID on a given world - @@ -384,7 +404,7 @@ public interface Economy { * does not support this the global balance will be returned. * * @param pluginName The name of the plugin that is calling the method. - * @param uuid the UUID associated with the account to deposit to. + * @param accountID the {@link UUID} associated with the account to deposit to. * @param worldName the name of the world to check in. * @param currency the currency to use. * @param amount Amount to deposit. @@ -393,201 +413,105 @@ public interface Economy { * Failure, Unsupported. */ @NotNull - EconomyResponse deposit(String pluginName, UUID uuid, String worldName, String currency, BigDecimal amount); + EconomyResponse deposit(final String pluginName, final UUID accountID, final String worldName, final String currency, final BigDecimal amount); /* - * Bank methods follow. + * Shared Account Methods */ /** - * Creates a bank account with the specified name and the given UUID as the - * owner. + * Creates a shared account with the specified parameters. * - * @param pluginName The name of the plugin that is calling the method. - * @param name Name of account. - * @param uuid UUID of the account should be linked to. - * @return true if bank creation is successful. + * @param pluginName the name of the plugin + * @param accountID the {@link UUID} of the account + * @param name the name of the account + * @param owner the {@link UUID} of the account owner + * @return true if the shared account is successfully created, false otherwise */ - boolean createBank(String pluginName, String name, UUID uuid); + boolean createSharedAccount(final String pluginName, final UUID accountID, final String name, final UUID owner); /** - * Deletes a bank account with the specified UUID. + * Determines whether the specified owner ID is the owner of the account associated with the given account ID and plugin name. * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the bank to be deleted. - * @return true if the operation completed successfully + * @param pluginName the name of the plugin + * @param accountID the {@link UUID} of the account + * @param uuid the {@link UUID} to check for ownership of the account + * @return true if the owner ID is the owner of the account, false otherwise */ - boolean deleteBank(String pluginName, UUID uuid); + boolean isAccountOwner(final String pluginName, final UUID accountID, final UUID uuid); /** - * Returns a map that represents all the UUIDs which have banks in the - * plugin, as well as their last-known-name. This is used for Vault's economy - * converter and should be given every account available. - * - * @return a {@link Map} composed of the accounts keyed by their UUID, along - * with their associated last-known-name. - */ - Map getBankUUIDNameMap(); - - /** - * Gets the last known name of an bank with the given UUID. Required for - * messages to be more human-readable than UUIDs alone can provide. - * - * @param uuid UUID to look up. - * @return name of the bank. - */ - @NotNull - String getBankAccountName(UUID uuid); - - /** - * Checks if this UUID has a bank yet. + * Sets the owner of a specified plugin to the given accountID. * - * @param uuid UUID to check. - * @return true if the UUID has an account. + * @param pluginName The name of the plugin. + * @param accountID The {@link UUID} of the account + * @param uuid The {@link UUID} of the account to set as the owner. + * @return true if the owner is successfully set, false otherwise. */ - boolean hasBankAccount(UUID uuid); + boolean setOwner(final String pluginName, final UUID accountID, final UUID uuid); /** - * Checks if the specified bank account supports the specified currency. + * Determines whether a specific member is an account member of a given plugin. * - * @param uuid UUID of the account. - * @param currency the currency to use. - * @return true if the bank supports the currency + * @param pluginName The name of the plugin. + * @param accountID The {@link UUID} of the account. + * @param uuid The {@link UUID} to check for membership. + * @return true if the member is an account member, false otherwise. */ - boolean bankSupportsCurrency(UUID uuid, String currency); + boolean isAccountMember(final String pluginName, final UUID accountID, final UUID uuid); /** - * A method which changes the name associated with the given UUID in the - * Map received from {@link #getBankUUIDNameMap()}. + * Adds a member to an account. * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid 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. + * @param pluginName The name of the plugin. + * @param accountID The {@link UUID} of the account. + * @param uuid The {@link UUID} of the member to be added. + * @return true if the member was successfully added, false otherwise. */ - boolean renameBankAccount(String pluginName, UUID uuid, String name); + boolean addAccountMember(final String pluginName, final UUID accountID, final UUID uuid); /** - * Returns the amount the bank has. + * Adds a member to an account with the specified initial permissions. * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account. - * @return amount which the bank holds as a balance. + * @param pluginName The name of the plugin. + * @param accountID The {@link UUID} of the account. + * @param uuid The {@link UUID} of the member to be added. + * @param initialPermissions The initial permissions to be assigned to the member. The values for + * these should be assumed to be "true." + * @return true if the member was added successfully, false otherwise. */ - @NotNull - BigDecimal bankBalance(String pluginName, UUID uuid); + boolean addAccountMember(final String pluginName, final UUID accountID, final UUID uuid, final AccountPermission... initialPermissions); /** - * Returns the amount the bank has. + * Removes a member from an account. * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account. - * @param currency the currency to use. - * @return amount which the bank holds as a balance. + * @param pluginName the name of the plugin managing the account + * @param accountID the {@link UUID} of the account + * @param uuid the {@link UUID} of the member to be removed + * @return true if the member was successfully removed, false otherwise */ - @NotNull - BigDecimal bankBalance(String pluginName, UUID uuid, String currency); + boolean removeAccountMember(final String pluginName, final UUID accountID, final UUID uuid); /** - * Returns true or false whether the bank has the amount specified - DO NOT USE - * NEGATIVE AMOUNTS. + * Checks if the specified account has the given permission for the given plugin. * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account. - * @param amount to check for - * @return true if the bank has the given amount. + * @param pluginName the name of the plugin to check permission for + * @param accountID the {@link UUID} of the account + * @param uuid the {@link UUID} to check for the permission + * @param permission the permission to check for + * @return true if the account has the specified permission, false otherwise */ - boolean bankHas(String pluginName, UUID uuid, BigDecimal amount); + boolean hasAccountPermission(final String pluginName, final UUID accountID, final UUID uuid, final AccountPermission permission); /** - * Returns true or false whether the bank has the amount specified - DO NOT USE - * NEGATIVE AMOUNTS. + * Updates the account permission for a specific plugin and user. * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account. - * @param currency the currency to use. - * @param amount to check for - * @return true if the bank has the given amount. - */ - boolean bankHas(String pluginName, UUID uuid, String currency, BigDecimal amount); - - /** - * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS. - * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account. - * @param amount to withdraw. - * @return {@link EconomyResponse} which includes the Economy plugin's - * {@link ResponseType} as to whether the transaction was a Success, - * Failure, Unsupported. - */ - @NotNull - EconomyResponse bankWithdraw(String pluginName, UUID uuid, BigDecimal amount); - - /** - * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS. - * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account. - * @param currency the currency to use. - * @param amount to withdraw. - * @return {@link EconomyResponse} which includes the Economy plugin's - * {@link ResponseType} as to whether the transaction was a Success, - * Failure, Unsupported. - */ - @NotNull - EconomyResponse bankWithdraw(String pluginName, UUID uuid, String currency, BigDecimal amount); - - /** - * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS. - * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account. - * @param amount to deposit. - * @return {@link EconomyResponse} which includes the Economy plugin's - * {@link ResponseType} as to whether the transaction was a Success, - * Failure, Unsupported. - */ - @NotNull - EconomyResponse bankDeposit(String pluginName, UUID uuid, BigDecimal amount); - - /** - * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS. - * - * @param pluginName The name of the plugin that is calling the method. - * @param uuid UUID of the account. - * @param currency the currency to use. - * @param amount to deposit. - * @return {@link EconomyResponse} which includes the Economy plugin's - * {@link ResponseType} as to whether the transaction was a Success, - * Failure, Unsupported. - */ - @NotNull - EconomyResponse bankDeposit(String pluginName, UUID uuid, String currency, BigDecimal amount); - - /** - * Check if a UUID is the owner of a bank account. - * - * @param uuid UUID of the player/object who might be an owner. - * @param bankUUID UUID of the bank account to check ownership of. - * @return true if the uuid is the owner of the bank associated with bankUUID. - */ - boolean isBankOwner(UUID uuid, UUID bankUUID); - - /** - * Check if the UUID is a member of the bank account - * - * @param uuid UUID of the player/object who might be a member. - * @param bankUUID UUID of the bank account to check membership of. - * @return @return true if the uuid is a member of the bank associated with bankUUID. - */ - boolean isBankMember(UUID uuid, UUID bankUUID); - - /** - * Gets the list of banks' UUIDs. - * - * @return the List of Banks' UUIDs. + * @param pluginName the name of the plugin + * @param accountID the {@link UUID} of the account + * @param uuid the {@link UUID} to update the permission for + * @param permission the new account permissions to set + * @param value the new permission value to set for this value + * @return true if the account permission was successfully updated, false otherwise */ - Collection getBanks(); -} + boolean updateAccountPermission(final String pluginName, final UUID accountID, final UUID uuid, final AccountPermission permission, final boolean value); +} \ No newline at end of file From ff7904525bb9229795d13936be40c6d5d814ff89 Mon Sep 17 00:00:00 2001 From: Fedjoyd <53665065+Fedjoyd@users.noreply.github.com> Date: Sun, 6 Oct 2024 07:51:13 +0200 Subject: [PATCH 34/44] Added "String pluginName" parameter to display function I added the "String pluginName" parameter to the function: fractionalDigits, format, getDefaultCurrency, defaultCurrencyNamePlural and defaultCurrencyNameSingular for the creation of an economy plugin that redirects the calls of these functions to different currencies depending on the plugin that calls them (for example in my multi-currency economy plugin I created a possibility to define a currency on a plugin the modifications I made allow these plugins to display the amounts in the right currency (in case the calling plugin does not support multi-currency)) --- .../net/milkbowl/vault2/economy/Economy.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index 24e07b7..d5fce03 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -73,34 +73,37 @@ public interface Economy { * function returns the number of digits the plugin keeps or -1 if no rounding * occurs. * + * @param pluginName The name of the plugin that is calling the method. * @return number of digits after the decimal point this plugin supports or -1 * if no rounding occurs. */ @NotNull - int fractionalDigits(); + int fractionalDigits(final String pluginName); /** * Plugins use this method to format a given BigDecimal amount into a human-readable * amount using your economy plugin's currency names/conventions. * + * @param pluginName The name of the plugin that is calling the method. * @param amount to format. * * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. */ @NotNull - String format(BigDecimal amount); + String format(final String pluginName, BigDecimal amount); /** * Plugins use this method to format a given BigDecimal amount into a human-readable * amount using your economy plugin's currency names/conventions. * + * @param pluginName The name of the plugin that is calling the method. * @param amount to format. * @param currency the currency to use for the format. * * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. */ @NotNull - String format(BigDecimal amount, final String currency); + String format(final String pluginName, BigDecimal amount, final String currency); /** * Returns true if a currency with the specified name exists. @@ -114,30 +117,34 @@ public interface Economy { /** * Used to get the default currency. This could be the default currency for the server globally or * for the default world if the implementation supports multi-world. + * + * @param pluginName The name of the plugin that is calling the method. * @return The currency that is the default for the server if multi-world support is not available * otherwise the default for the default world. * */ @NotNull - String getDefaultCurrency(); + String getDefaultCurrency(final String pluginName); /** * Returns the name of the default currency in plural form. If the economy being used * does not support currency names then an empty string will be returned. * + * @param pluginName The name of the plugin that is calling the method. * @return name of the currency (plural) ie: Dollars or Pounds. */ @NotNull - String defaultCurrencyNamePlural(); + String defaultCurrencyNamePlural(final String pluginName); /** * Returns the name of the default currency in singular form. If the economy being used * does not support currency names then an empty string will be returned. * + * @param pluginName The name of the plugin that is calling the method. * @return name of the currency (singular) ie: Dollar or Pound. */ @NotNull - String defaultCurrencyNameSingular(); + String defaultCurrencyNameSingular(final String pluginName); /** * Returns a list of currencies used by the economy plugin. These are able to be used @@ -514,4 +521,4 @@ public interface Economy { * @return true if the account permission was successfully updated, false otherwise */ boolean updateAccountPermission(final String pluginName, final UUID accountID, final UUID uuid, final AccountPermission permission, final boolean value); -} \ No newline at end of file +} From c6c69d667b7f85b7d84fee5c3ff08376c7d9c4f0 Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Sun, 6 Oct 2024 18:34:24 -0400 Subject: [PATCH 35/44] Update maven.yml --- .github/workflows/maven.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f5abe21..9896c86 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -15,13 +15,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 1.8 - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} @@ -32,7 +32,7 @@ jobs: run: mvn -B javadoc:jar --file pom.xml - name: Stage the artifact run: mkdir staging && cp target/*.jar staging - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: VaultUnlockedAPI path: staging From f781fc9756c628bb8cf04f8f1b0d2261d987e372 Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Sun, 6 Oct 2024 18:37:13 -0400 Subject: [PATCH 36/44] Update maven.yml --- .github/workflows/maven.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9896c86..dfdafab 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,6 +20,7 @@ jobs: uses: actions/setup-java@v3 with: java-version: 1.8 + distribution: 'temurin' - name: Cache Maven packages uses: actions/cache@v4 with: From b5e6492e1fcb451030b3c9a685886d69dc624c0f Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Sun, 6 Oct 2024 19:07:02 -0400 Subject: [PATCH 37/44] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index dfdafab..541c027 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -19,7 +19,7 @@ jobs: - name: Set up JDK 1.8 uses: actions/setup-java@v3 with: - java-version: 1.8 + java-version: '8' distribution: 'temurin' - name: Cache Maven packages uses: actions/cache@v4 From 85f828896265e8cd6287a25b717b146286afae45 Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Sun, 6 Oct 2024 19:09:01 -0400 Subject: [PATCH 38/44] Update maven.yml --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 541c027..95111fb 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -29,8 +29,8 @@ jobs: restore-keys: ${{ runner.os }}-m2 - name: Build Release run: mvn -B package --file pom.xml - - name: Build javadoc - run: mvn -B javadoc:jar --file pom.xml + #- name: Build javadoc + # run: mvn -B javadoc:jar --file pom.xml - name: Stage the artifact run: mkdir staging && cp target/*.jar staging - uses: actions/upload-artifact@v3 From 69b46bf05cbbbdab4a077f5088033fbe4173892c Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Sun, 6 Oct 2024 19:54:46 -0400 Subject: [PATCH 39/44] Update Version, Add Component for format methods, add deprecation. --- pom.xml | 8 ++++- .../net/milkbowl/vault2/economy/Economy.java | 32 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 0ebc17e..e4fedb3 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.milkbowl.vault VaultUnlockedAPI - 2.5 + 2.6 VaultUnlockedAPI @@ -89,6 +89,12 @@ 24.0.0 compile + + net.kyori + adventure-text-minimessage + 4.17.0 + provided + diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index d5fce03..6e4c5e9 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -16,6 +16,7 @@ package net.milkbowl.vault2.economy; +import net.kyori.adventure.text.Component; import net.milkbowl.vault2.economy.EconomyResponse.ResponseType; import org.jetbrains.annotations.NotNull; @@ -84,13 +85,13 @@ public interface Economy { * Plugins use this method to format a given BigDecimal amount into a human-readable * amount using your economy plugin's currency names/conventions. * - * @param pluginName The name of the plugin that is calling the method. * @param amount to format. * * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. + * @deprecated Use {@link #format(String, BigDecimal)} instead. */ @NotNull - String format(final String pluginName, BigDecimal amount); + String format(BigDecimal amount); /** * Plugins use this method to format a given BigDecimal amount into a human-readable @@ -98,12 +99,37 @@ public interface Economy { * * @param pluginName The name of the plugin that is calling the method. * @param amount to format. + * + * @return Human-readable {@link Component text component} describing amount, ie 5 Dollars or 5.55 Pounds. + */ + @NotNull + Component format(final String pluginName, BigDecimal amount); + + /** + * Plugins use this method to format a given BigDecimal amount into a human-readable + * amount using your economy plugin's currency names/conventions. + * + * @param amount to format. * @param currency the currency to use for the format. * * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. + * @deprecated Use {@link #format(String, BigDecimal, String)} instead. + */ + @NotNull + String format(BigDecimal amount, final String currency); + + /** + * Plugins use this method to format a given BigDecimal amount into a human-readable + * amount using your economy plugin's currency names/conventions. + * + * @param pluginName The name of the plugin that is calling the method. + * @param amount to format. + * @param currency the currency to use for the format. + * + * @return Human-readable {@link Component text component} describing amount, ie 5 Dollars or 5.55 Pounds. */ @NotNull - String format(final String pluginName, BigDecimal amount, final String currency); + Component format(final String pluginName, BigDecimal amount, final String currency); /** * Returns true if a currency with the specified name exists. From a6107cb993adea8f797c29f9b8058c8441feef7a Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Fri, 11 Oct 2024 18:25:17 -0400 Subject: [PATCH 40/44] Add parameters config to the compiler configs. --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index e4fedb3..08b75d5 100644 --- a/pom.xml +++ b/pom.xml @@ -107,6 +107,9 @@ 8 8 + + -parameters + From ebdabeb190daf125e1f7427c882a57baef6c3666 Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Wed, 23 Oct 2024 17:32:42 -0400 Subject: [PATCH 41/44] Bump to 2.7, remove Component requirement. --- pom.xml | 8 +------- .../java/net/milkbowl/vault2/economy/Economy.java | 11 ++++++----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 08b75d5..4aa7318 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.milkbowl.vault VaultUnlockedAPI - 2.6 + 2.7 VaultUnlockedAPI @@ -89,12 +89,6 @@ 24.0.0 compile - - net.kyori - adventure-text-minimessage - 4.17.0 - provided - diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index 6e4c5e9..dbdf114 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -16,7 +16,6 @@ package net.milkbowl.vault2.economy; -import net.kyori.adventure.text.Component; import net.milkbowl.vault2.economy.EconomyResponse.ResponseType; import org.jetbrains.annotations.NotNull; @@ -91,6 +90,7 @@ public interface Economy { * @deprecated Use {@link #format(String, BigDecimal)} instead. */ @NotNull + @Deprecated String format(BigDecimal amount); /** @@ -100,10 +100,10 @@ public interface Economy { * @param pluginName The name of the plugin that is calling the method. * @param amount to format. * - * @return Human-readable {@link Component text component} describing amount, ie 5 Dollars or 5.55 Pounds. + * @return Human-readable String describing amount, ie 5 Dollars or 5.55 Pounds. */ @NotNull - Component format(final String pluginName, BigDecimal amount); + String format(final String pluginName, BigDecimal amount); /** * Plugins use this method to format a given BigDecimal amount into a human-readable @@ -116,6 +116,7 @@ public interface Economy { * @deprecated Use {@link #format(String, BigDecimal, String)} instead. */ @NotNull + @Deprecated String format(BigDecimal amount, final String currency); /** @@ -126,10 +127,10 @@ public interface Economy { * @param amount to format. * @param currency the currency to use for the format. * - * @return Human-readable {@link Component text component} describing amount, ie 5 Dollars or 5.55 Pounds. + * @return Human-readable String describing amount, ie 5 Dollars or 5.55 Pounds. */ @NotNull - Component format(final String pluginName, BigDecimal amount, final String currency); + String format(final String pluginName, BigDecimal amount, final String currency); /** * Returns true if a currency with the specified name exists. From fc0f108972be6e825c2b00c8308ac5fece232fc5 Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Wed, 23 Oct 2024 17:37:17 -0400 Subject: [PATCH 42/44] Update license header to LGPL for AccountPermission. --- .../vault2/economy/AccountPermission.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/AccountPermission.java b/src/main/java/net/milkbowl/vault2/economy/AccountPermission.java index b604263..18668b2 100644 --- a/src/main/java/net/milkbowl/vault2/economy/AccountPermission.java +++ b/src/main/java/net/milkbowl/vault2/economy/AccountPermission.java @@ -1,27 +1,26 @@ package net.milkbowl.vault2.economy; -/* - * The New Kings - * Copyright (C) 2022 - 2024 Daniel "creatorfromhell" Vidmar - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + +/* 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 . */ /** * AccountPermission * * @author creatorfromhell - * @since 0.0.1.0 + * @since 2.7 */ public enum AccountPermission { From 6579ca3f9630a43ba6c94b6d5a48f6d878e39882 Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Wed, 23 Oct 2024 17:51:53 -0400 Subject: [PATCH 43/44] Add deleteAccount method, and update parameters to be final for consistency. --- .../net/milkbowl/vault2/economy/Economy.java | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index dbdf114..14185ff 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -91,7 +91,7 @@ public interface Economy { */ @NotNull @Deprecated - String format(BigDecimal amount); + String format(final BigDecimal amount); /** * Plugins use this method to format a given BigDecimal amount into a human-readable @@ -103,7 +103,7 @@ public interface Economy { * @return Human-readable String describing amount, ie 5 Dollars or 5.55 Pounds. */ @NotNull - String format(final String pluginName, BigDecimal amount); + String format(final String pluginName, final BigDecimal amount); /** * Plugins use this method to format a given BigDecimal amount into a human-readable @@ -117,7 +117,7 @@ public interface Economy { */ @NotNull @Deprecated - String format(BigDecimal amount, final String currency); + String format(final BigDecimal amount, final String currency); /** * Plugins use this method to format a given BigDecimal amount into a human-readable @@ -130,7 +130,7 @@ public interface Economy { * @return Human-readable String describing amount, ie 5 Dollars or 5.55 Pounds. */ @NotNull - String format(final String pluginName, BigDecimal amount, final String currency); + String format(final String pluginName, final BigDecimal amount, final String currency); /** * Returns true if a currency with the specified name exists. @@ -193,7 +193,7 @@ public interface Economy { * @param name UUID associated with the account. * @return true if the account creation was successful. */ - boolean createAccount(UUID accountID, final String name); + boolean createAccount(final UUID accountID, final String name); /** * Attempts to create an account for the given UUID on the specified world @@ -205,7 +205,7 @@ public interface Economy { * @param worldName String name of the world. * @return if the account creation was successful */ - boolean createAccount(UUID accountID, final String name, final String worldName); + boolean createAccount(final UUID accountID, final String name, final String worldName); /** * Returns a map that represents all the UUIDs which have accounts in the @@ -225,7 +225,7 @@ public interface Economy { * @return An optional containing the last known name if the account exists, otherwise an empty * optional. */ - Optional getAccountName(UUID accountID); + Optional getAccountName(final UUID accountID); /** * Checks if this UUID has an account yet. @@ -233,7 +233,7 @@ public interface Economy { * @param accountID UUID to check for an existing account. * @return true if the UUID has an account. */ - boolean hasAccount(UUID accountID); + boolean hasAccount(final UUID accountID); /** * Checks if this UUID has an account yet on the given world. @@ -242,7 +242,7 @@ public interface Economy { * @param worldName world-specific account. * @return if the UUID has an account. */ - boolean hasAccount(UUID accountID, final String worldName); + boolean hasAccount(final UUID accountID, final String worldName); /** * A method which changes the name associated with the given UUID in the @@ -253,7 +253,27 @@ public interface Economy { * Map map. * @return true if the name change is successful. */ - boolean renameAccount(UUID accountID, final String name); + boolean renameAccount(final UUID accountID, final String name); + + /** + * Renames the account with the specified ID in the given plugin to the new name. + * + * @param plugin The plugin name where the account exists + * @param accountID The unique identifier of the account to be renamed + * @param name The new name to assign to the account + * + * @return true if the rename operation was successful, false otherwise + */ + boolean renameAccount(final String plugin, final UUID accountID, final String name); + + /** + * Deletes the account associated with the specified UUID. + * + * @param plugin the name of the plugin managing the account + * @param accountID the UUID of the account to be deleted + * @return true if the account was successfully deleted, false otherwise + */ + boolean deleteAccount(final String plugin, final UUID accountID); /* * Account balance related methods follow. From 5725fb027da003677a5f7a2df1daaf50ac7e811c Mon Sep 17 00:00:00 2001 From: "Daniel V." Date: Tue, 17 Dec 2024 20:13:53 -0500 Subject: [PATCH 44/44] Add new createAccount methods with parameter to indicate if player account or not. --- .../net/milkbowl/vault2/economy/Economy.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/milkbowl/vault2/economy/Economy.java b/src/main/java/net/milkbowl/vault2/economy/Economy.java index 14185ff..0b88114 100644 --- a/src/main/java/net/milkbowl/vault2/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault2/economy/Economy.java @@ -187,7 +187,7 @@ public interface Economy { */ /** - * Attempts to create a account for the given UUID. + * Attempts to create an account for the given UUID. * * @param accountID UUID associated with the account. * @param name UUID associated with the account. @@ -195,6 +195,17 @@ public interface Economy { */ boolean createAccount(final UUID accountID, final String name); + /** + * Creates a new account with the provided information. + * + * @param accountID The UUID of the account to be created. + * @param name The name associated with the account. + * @param player A flag indicating if the account is a player account. + * + * @return true if the account was successfully created, false otherwise. + */ + boolean createAccount(final UUID accountID, final String name, final boolean player); + /** * Attempts to create an account for the given UUID on the specified world * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then @@ -207,6 +218,18 @@ public interface Economy { */ boolean createAccount(final UUID accountID, final String name, final String worldName); + /** + * Creates a new account with the given parameters. + * + * @param accountID The UUID of the account to be created. + * @param name The name of the account holder. + * @param worldName The world name associated with the account. + * @param player A boolean indicating if the account belongs to a player. + * + * @return True if the account was successfully created, false otherwise. + */ + boolean createAccount(final UUID accountID, final String name, final String worldName, final boolean player); + /** * Returns a map that represents all the UUIDs which have accounts in the * plugin, as well as their last-known-name. This is used for Vault's economy