From 5c61077842c0a0f781f554dedd09959ad693bf0e Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Sun, 4 Apr 2021 10:32:25 -0500 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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 b3bbcddff4af37d17288ea1c59c06fbc0327d90b Mon Sep 17 00:00:00 2001 From: lbenav8095 Date: Sat, 1 Apr 2023 14:34:54 -0600 Subject: [PATCH 4/5] Splitted @LlmDl Economy proposal in IdentityEconomy in order to support economy providers that are already able to hook into Vault. Added MultiEconomy which considers an economy as a currency, granting a multi-currency abstraction. Provided wrappers that help registering/hooking all three types of layers into Vault. --- .../net/milkbowl/vault/economy/Economy.java | 160 +------- .../vault/economy/IdentityEconomy.java | 324 ++++++++++++++++ .../milkbowl/vault/economy/LegacyEconomy.java | 345 ++++++++++++++++++ .../milkbowl/vault/economy/MultiEconomy.java | 114 ++++++ .../economy/wrappers/EconomyWrapper.java | 55 +++ .../wrappers/IdentityEconomyWrapper.java | 44 +++ .../economy/wrappers/MultiEconomyWrapper.java | 48 +++ 7 files changed, 942 insertions(+), 148 deletions(-) create mode 100644 src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java create mode 100644 src/main/java/net/milkbowl/vault/economy/LegacyEconomy.java create mode 100644 src/main/java/net/milkbowl/vault/economy/MultiEconomy.java create mode 100644 src/main/java/net/milkbowl/vault/economy/wrappers/EconomyWrapper.java create mode 100644 src/main/java/net/milkbowl/vault/economy/wrappers/IdentityEconomyWrapper.java create mode 100644 src/main/java/net/milkbowl/vault/economy/wrappers/MultiEconomyWrapper.java diff --git a/src/main/java/net/milkbowl/vault/economy/Economy.java b/src/main/java/net/milkbowl/vault/economy/Economy.java index a1b3ed9..ccb3740 100644 --- a/src/main/java/net/milkbowl/vault/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault/economy/Economy.java @@ -17,7 +17,6 @@ package net.milkbowl.vault.economy; import java.util.List; -import java.util.UUID; import org.bukkit.OfflinePlayer; @@ -97,15 +96,7 @@ public interface Economy { public boolean hasAccount(OfflinePlayer player); /** - * Checks if this uuid has an account yet - * - * @param uuid to check - * @return if the uuid has an account - */ - public boolean hasAccount(UUID uuid); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} or {@link #hasAccount(UUID, String)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} instead. */ @Deprecated public boolean hasAccount(String playerName, String worldName); @@ -122,16 +113,7 @@ public interface Economy { public boolean hasAccount(OfflinePlayer player, String worldName); /** - * Checks if this uuid has an account yet on the given world - * - * @param uuid to check - * @param worldName world-specific account - * @return if the uuid has an account - */ - public boolean hasAccount(UUID uuid, String worldName); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} or {@link #getBalance(UUID)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} instead. */ @Deprecated public double getBalance(String playerName); @@ -145,15 +127,7 @@ public interface Economy { public double getBalance(OfflinePlayer player); /** - * Gets balance of a UUID - * - * @param uuid of the account to get a balance for - * @return Amount currently held in account associated with the given UUID - */ - public double getBalance(UUID uuid); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} or {@link #getBalance(UUID, String)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} instead. */ @Deprecated public double getBalance(String playerName, String world); @@ -168,16 +142,7 @@ public interface Economy { public double getBalance(OfflinePlayer player, String world); /** - * Gets balance of a UUID on the specified world. - * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. - * @param uuid of the account to get a balance for - * @param world name of the world - * @return Amount currently held in account associated with the given UUID - */ - public double getBalance(UUID uuid, String world); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} or {@link #has(UUID, double)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} instead. */ @Deprecated public boolean has(String playerName, double amount); @@ -192,16 +157,7 @@ public interface Economy { public boolean has(OfflinePlayer player, double amount); /** - * Checks if the account associated with the given UUID has the amount - DO NOT USE NEGATIVE AMOUNTS - * - * @param uuid to check - * @param amount to check for - * @return True if UUID has amount, False else wise - */ - public boolean has(UUID uuid, double amount); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, String, double)} or {@link #has(UUID, String, double)} instead. + * @deprecated As of VaultAPI 1.4 use @{link {@link #has(OfflinePlayer, String, double)} instead. */ @Deprecated public boolean has(String playerName, String worldName, double amount); @@ -218,18 +174,7 @@ public interface Economy { public boolean has(OfflinePlayer player, String worldName, double amount); /** - * Checks if the account associated with the given UUID has the amount in the given world - DO NOT USE NEGATIVE AMOUNTS - * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. - * - * @param uuid to check - * @param worldName to check with - * @param amount to check for - * @return True if UUID has amount in the given world, False else wise - */ - public boolean has(UUID uuid, String worldName, double amount); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} or {@link #withdrawPlayer(UUID, double)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} instead. */ @Deprecated public EconomyResponse withdrawPlayer(String playerName, double amount); @@ -244,16 +189,7 @@ public interface Economy { public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount); /** - * Withdraw an amount from an account associated with a UUID - DO NOT USE NEGATIVE AMOUNTS - * - * @param uuid to withdraw from - * @param amount Amount to withdraw - * @return Detailed response of transaction - */ - public EconomyResponse withdraw(UUID uuid, double amount); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} or {@link #withdrawPlayer(UUID, String, double)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} instead. */ @Deprecated public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount); @@ -269,17 +205,7 @@ public interface Economy { public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount); /** - * Withdraw an amount from an account associated with a UUID on a given world - DO NOT USE NEGATIVE AMOUNTS - * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. - * @param uuid to withdraw from - * @param worldName - name of the world - * @param amount Amount to withdraw - * @return Detailed response of transaction - */ - public EconomyResponse withdraw(UUID uuid, String worldName, double amount); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} or {@link #depositPlayer(UUID, double)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} instead. */ @Deprecated public EconomyResponse depositPlayer(String playerName, double amount); @@ -294,16 +220,7 @@ public interface Economy { public EconomyResponse depositPlayer(OfflinePlayer player, double amount); /** - * Deposit an amount to an account associated with the given UUID - DO NOT USE NEGATIVE AMOUNTS - * - * @param uuid to deposit to - * @param amount Amount to deposit - * @return Detailed response of transaction - */ - public EconomyResponse deposit(UUID uuid, double amount); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} or {@link #depositPlayer(UUID, String, double)} instead. + * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} instead. */ @Deprecated public EconomyResponse depositPlayer(String playerName, String worldName, double amount); @@ -320,18 +237,7 @@ public interface Economy { public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount); /** - * Deposit an amount from an account associated with a UUID on a given world - DO NOT USE NEGATIVE AMOUNTS - * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. - * - * @param uuid to deposit to - * @param worldName name of the world - * @param amount Amount to deposit - * @return Detailed response of transaction - */ - public EconomyResponse deposit(UUID uuid, String worldName, double amount); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #createBank(String, OfflinePlayer)} or {@link #createBank(String, UUID)} instead. + * @deprecated As of VaultAPI 1.4 use {{@link #createBank(String, OfflinePlayer)} instead. */ @Deprecated public EconomyResponse createBank(String name, String player); @@ -343,14 +249,6 @@ public interface Economy { * @return EconomyResponse Object */ public EconomyResponse createBank(String name, OfflinePlayer player); - - /** - * Creates a bank account with the specified name and the given UUID as the owner - * @param name of account - * @param uuid the account should be linked to - * @return EconomyResponse Object - */ - public EconomyResponse createBank(String name, UUID uuid); /** * Deletes a bank account with the specified name. @@ -409,16 +307,7 @@ public interface Economy { public EconomyResponse isBankOwner(String name, OfflinePlayer player); /** - * Check if a uuid is the owner of a bank account - * - * @param name of the account - * @param uuid to check for ownership - * @return EconomyResponse Object - */ - public EconomyResponse isBankOwner(String name, UUID uuid); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #isBankMember(String, OfflinePlayer)} or {@link #isBankMember(String, UUID)} instead. + * @deprecated As of VaultAPI 1.4 use {{@link #isBankMember(String, OfflinePlayer)} instead. */ @Deprecated public EconomyResponse isBankMember(String name, String playerName); @@ -431,15 +320,6 @@ public interface Economy { * @return EconomyResponse Object */ public EconomyResponse isBankMember(String name, OfflinePlayer player); - - /** - * Check if the uuid is a member of the bank account - * - * @param name of the account - * @param uuid to check membership - * @return EconomyResponse Object - */ - public EconomyResponse isBankMember(String name, UUID uuid); /** * Gets the list of banks @@ -461,14 +341,7 @@ public interface Economy { public boolean createPlayerAccount(OfflinePlayer player); /** - * Attempts to create a account for the given uuid - * @param uuid associated with the account - * @return if the account creation was successful - */ - public boolean createAccount(UUID uuid); - - /** - * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer, String)} or {@link #createPlayerAccount(UUID, String)} instead. + * @deprecated As of VaultAPI 1.4 use {{@link #createPlayerAccount(OfflinePlayer, String)} instead. */ @Deprecated public boolean createPlayerAccount(String playerName, String worldName); @@ -481,13 +354,4 @@ public interface Economy { * @return if the account creation was successful */ public boolean createPlayerAccount(OfflinePlayer player, String worldName); - - /** - * Attempts to create an account for the given UUID on the specified world - * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then false will always be returned. - * @param uuid associated with the account - * @param worldName String name of the world - * @return if the account creation was successful - */ - public boolean createAccount(UUID uuid, String worldName); } diff --git a/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java b/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java new file mode 100644 index 0000000..f3bfa5b --- /dev/null +++ b/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java @@ -0,0 +1,324 @@ +/* This file is part of Vault. + + Vault is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Vault is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Vault. If not, see . + */ + +package net.milkbowl.vault.economy; + +import net.milkbowl.vault.economy.wrappers.IdentityEconomyWrapper; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * Adds UUID support to the Economy interface. + * In case of {@link #supportsAllRecordsOperation()} or {@link #supportsAllOnlineOperation()} + * returning true, methods such as + * {@link #getAllRecords()} and {@link #getAllOnline()} + * should not be expected to work. + *

+ * In order to register/provide it, you should use {@link IdentityEconomyWrapper#registerProviders()} + */ +public interface IdentityEconomy extends Economy{ + /** + * Used to determine if IdentityEconomy was built through + * the EconomyWrapper as a LegacyEconomy. + * If false, method {@link #getAllRecords()} will not be work. + * This was made in order to support plugins which use older versions of VaultAPI/Vault. + * You can also use it / override it to disable previous mentioned methods! + * @return true if operation is supported + */ + public boolean supportsAllRecordsOperation(); + + /** + * Used to determine if IdentityEconomy was built through + * the EconomyWrapper as a LegacyEconomy. + * If false, the method {@link #getAllOnline()} (UUID)} will not be work. + * This was made in order to support plugins which use older versions of VaultAPI/Vault. + * You can also use it / override it to disable previous mentioned methods! + * @return true if operation is supported + */ + public boolean supportsAllOnlineOperation(); + + /** + * Used to determine if IdentityEconomy was built through + * the EconomyWrapper as a LegacyEconomy. + * If false, all operations must be done with players that + * are online/connected to the server in real time. + * If true, you should expect to call these operations + * asynchronously. + * @return true if operation is supported + */ + public boolean supportsOfflineOperations(); + + /** + * Used to determine if IdentityEconomy was built through + * the EconomyWrapper as a LegacyEconomy. + * If false, you should expect UnsupportedOperationException + * being thrown when calling these methods. + * @return true if operation is supported + */ + public boolean supportsUUIDOperations(); + + /* + * Account-related methods follow. + */ + + /** + * Attempts to create a account for the given uuid + * + * @param uuid associated with the account + * @param name associated with the account. + * @return if the account creation was successful + */ + public boolean createAccount(UUID uuid, String name); + + /** + * Attempts to create an account for the given UUID on the specified world + * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then + * false will always be returned. + * + * @param uuid associated with the account + * @param name associated with the account. + * @param worldName String name of the world + * @return if the account creation was successful + */ + public boolean createAccount(UUID uuid, String name, String worldName); + + /** + * Returns a map that represents all of the stored UUIDs which have accounts in the + * plugin (in the database, not memory), as well as their last-known-name. This is used for Vault's economy + * converter and should be given every account available. + * Needs IdentityEconomy#hasUUIDSupport() to be true. + * + * @return a {@link Map} composed of the accounts keyed by their UUID, along + * with their associated last-known-name. + */ + public Map getAllRecords(); + + /** + * Returns a collection of all UUIDs which have accounts in the plugin and are currently + * online/connected to the server. + * This is used for Vault's economy converter and should + * Needs IdentityEconomy#hasUUIDSupport() to be true. + * @return a {@link Collection} of all UUIDs which have accounts in the plugin + */ + public Collection getAllOnline(); + + /** + * Gets the last known name of an account owned by the given UUID. Required for + * messages to be more human-readable than UUIDs alone can provide. + * + * @param uuid UUID to look up. + */ + public String getAccountName(UUID uuid); + + /** + * Checks if this uuid has an account yet + * + * @param uuid to check + * @return if the uuid has an account + */ + public boolean hasAccount(UUID uuid); + + /** + * Checks if this uuid has an account yet on the given world + * + * @param uuid to check + * @param worldName world-specific account + * @return if the uuid has an account + */ + public boolean hasAccount(UUID uuid, String worldName); + + /** + * A method which changes the name associated with the given UUID in the + * Map received from {@link #getAllRecords()} + * + * @param uuid which is having a name change. + * @param name name that will be associated with the UUID in the + * Map map. + * @return true if the name change is successful. + */ + public boolean renameAccount(UUID uuid, String name); + + /** + * Gets balance of a UUID + * + * @param uuid of the account to get a balance for + * @return Amount currently held in account associated with the given UUID + */ + public double getBalance(UUID uuid); + + /** + * Gets balance of a UUID on the specified world. IMPLEMENTATION SPECIFIC - if + * an economy plugin does not support this the global balance will be returned. + * + * @param uuid of the account to get a balance for + * @param world name of the world + * @return Amount currently held in account associated with the given UUID + */ + public double getBalance(UUID uuid, String world); + + /** + * Checks if the account associated with the given UUID has the amount - DO NOT + * USE NEGATIVE AMOUNTS + * + * @param uuid to check + * @param amount to check for + * @return True if UUID has amount, False else wise + */ + public boolean has(UUID uuid, double amount); + + /** + * Checks if the account associated with the given UUID has the amount in the + * given world - DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an + * economy plugin does not support this the global balance will be returned. + * + * @param uuid to check + * @param worldName to check with + * @param amount to check for + * @return True if UUID has amount in the given world, + * False else wise + */ + public boolean has(UUID uuid, String worldName, double amount); + + /** + * Withdraw an amount from an account associated with a UUID - DO NOT USE + * NEGATIVE AMOUNTS + * + * @param uuid to withdraw from + * @param amount Amount to withdraw + * @return Detailed response of transaction + */ + public EconomyResponse withdraw(UUID uuid, double amount); + + /** + * Withdraw an amount from an account associated with a UUID on a given world - + * DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an economy plugin + * does not support this the global balance will be returned. + * + * @param uuid to withdraw from + * @param worldName - name of the world + * @param amount Amount to withdraw + * @return Detailed response of transaction + */ + public EconomyResponse withdraw(UUID uuid, String worldName, double amount); + + /** + * Deposit an amount to an account associated with the given UUID - DO NOT USE + * NEGATIVE AMOUNTS + * + * @param uuid to deposit to + * @param amount Amount to deposit + * @return Detailed response of transaction + */ + public EconomyResponse deposit(UUID uuid, double amount); + + /** + * Deposit an amount from an account associated with a UUID on a given world - + * DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an economy plugin + * does not support this the global balance will be returned. + * + * @param uuid to deposit to + * @param worldName name of the world + * @param amount Amount to deposit + * @return Detailed response of transaction + */ + public EconomyResponse deposit(UUID uuid, String worldName, double amount); + + /* + * Bank methods follow. + */ + + /** + * Creates a bank account with the specified name and the given UUID as the + * owner + * + * @param name of account + * @param uuid the account should be linked to + * @return EconomyResponse Object + */ + public EconomyResponse createBank(String name, UUID uuid); + + /** + * Deletes a bank account with the specified name. + * + * @param name of the back to delete + * @return if the operation completed successfully + */ + public EconomyResponse deleteBank(String name); + + /** + * Returns the amount the bank has + * + * @param name of the account + * @return EconomyResponse Object + */ + public EconomyResponse bankBalance(String name); + + /** + * Returns true or false whether the bank has the amount specified - DO NOT USE + * NEGATIVE AMOUNTS + * + * @param name of the account + * @param amount to check for + * @return EconomyResponse Object + */ + public EconomyResponse bankHas(String name, double amount); + + /** + * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS + * + * @param name of the account + * @param amount to withdraw + * @return EconomyResponse Object + */ + public EconomyResponse bankWithdraw(String name, double amount); + + /** + * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS + * + * @param name of the account + * @param amount to deposit + * @return EconomyResponse Object + */ + public EconomyResponse bankDeposit(String name, double amount); + + /** + * Check if a uuid is the owner of a bank account + * + * @param name of the account + * @param uuid to check for ownership + * @return EconomyResponse Object + */ + public EconomyResponse isBankOwner(String name, UUID uuid); + + /** + * Check if the uuid is a member of the bank account + * + * @param name of the account + * @param uuid to check membership + * @return EconomyResponse Object + */ + public EconomyResponse isBankMember(String name, UUID uuid); + + /** + * Gets the list of banks + * + * @return the List of Banks + */ + public List getBanks(); +} diff --git a/src/main/java/net/milkbowl/vault/economy/LegacyEconomy.java b/src/main/java/net/milkbowl/vault/economy/LegacyEconomy.java new file mode 100644 index 0000000..cfedf6c --- /dev/null +++ b/src/main/java/net/milkbowl/vault/economy/LegacyEconomy.java @@ -0,0 +1,345 @@ +package net.milkbowl.vault.economy; + +import org.bukkit.OfflinePlayer; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class LegacyEconomy implements IdentityEconomy { + private final Economy economy; + public LegacyEconomy(Economy economy){ + this.economy = economy; + } + + @Override + public boolean supportsAllRecordsOperation() { + return false; + } + + @Override + public boolean supportsAllOnlineOperation() { + return false; + } + + @Override + public boolean supportsOfflineOperations(){ + return false; + } + + @Override + public boolean supportsUUIDOperations(){ + return false; + } + + @Override + public boolean isEnabled() { + return economy.isEnabled(); + } + + @Override + public String getName() { + return economy.getName(); + } + + @Override + public boolean hasBankSupport() { + return economy.hasBankSupport(); + } + + @Override + public int fractionalDigits() { + return economy.fractionalDigits(); + } + + @Override + public String format(double amount) { + return economy.format(amount); + } + + @Override + public String currencyNamePlural() { + return economy.currencyNamePlural(); + } + + @Override + public String currencyNameSingular() { + return economy.currencyNameSingular(); + } + + @Override + public boolean hasAccount(String playerName) { + return economy.hasAccount(playerName); + } + + @Override + public boolean hasAccount(OfflinePlayer player) { + return economy.hasAccount(player); + } + + @Override + public boolean hasAccount(String playerName, String worldName) { + return economy.hasAccount(playerName, worldName); + } + + @Override + public boolean hasAccount(OfflinePlayer player, String worldName) { + return economy.hasAccount(player, worldName); + } + + @Override + public double getBalance(String playerName) { + return economy.getBalance(playerName); + } + + @Override + public double getBalance(OfflinePlayer player) { + return economy.getBalance(player); + } + + @Override + public double getBalance(String playerName, String world) { + return economy.getBalance(playerName, world); + } + + @Override + public double getBalance(OfflinePlayer player, String world) { + return economy.getBalance(player, world); + } + + @Override + public boolean has(String playerName, double amount) { + return economy.has(playerName, amount); + } + + @Override + public boolean has(OfflinePlayer player, double amount) { + return economy.has(player, amount); + } + + @Override + public boolean has(String playerName, String worldName, double amount) { + return economy.has(playerName, worldName, amount); + } + + @Override + public boolean has(OfflinePlayer player, String worldName, double amount) { + return economy.has(player, worldName, amount); + } + + @Override + public EconomyResponse withdrawPlayer(String playerName, double amount) { + return economy.withdrawPlayer(playerName, amount); + } + + @Override + public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) { + return economy.withdrawPlayer(player, amount); + } + + @Override + public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) { + return economy.withdrawPlayer(playerName, worldName, amount); + } + + @Override + public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount) { + return economy.withdrawPlayer(player, worldName, amount); + } + + @Override + public EconomyResponse depositPlayer(String playerName, double amount) { + return economy.depositPlayer(playerName, amount); + } + + @Override + public EconomyResponse depositPlayer(OfflinePlayer player, double amount) { + return economy.depositPlayer(player, amount); + } + + @Override + public EconomyResponse depositPlayer(String playerName, String worldName, double amount) { + return economy.depositPlayer(playerName, worldName, amount); + } + + @Override + public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount) { + return economy.depositPlayer(player, worldName, amount); + } + + @Override + public EconomyResponse createBank(String name, String player) { + return economy.createBank(name, player); + } + + @Override + public EconomyResponse createBank(String name, OfflinePlayer player) { + return economy.createBank(name, player); + } + + @Override + public EconomyResponse isBankOwner(String name, String playerName) { + return economy.isBankOwner(name, playerName); + } + + @Override + public EconomyResponse isBankOwner(String name, OfflinePlayer player) { + return economy.isBankOwner(name, player); + } + + @Override + public EconomyResponse isBankMember(String name, String playerName) { + return economy.isBankMember(name, playerName); + } + + @Override + public EconomyResponse isBankMember(String name, OfflinePlayer player) { + return economy.isBankMember(name, player); + } + + @Override + public boolean createPlayerAccount(String playerName) { + return economy.createPlayerAccount(playerName); + } + + @Override + public boolean createPlayerAccount(OfflinePlayer player) { + return economy.createPlayerAccount(player); + } + + @Override + public boolean createPlayerAccount(String playerName, String worldName) { + return economy.createPlayerAccount(playerName, worldName); + } + + @Override + public boolean createPlayerAccount(OfflinePlayer player, String worldName) { + return economy.createPlayerAccount(player, worldName); + } + + @Override + public boolean createAccount(UUID uuid, String name) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public boolean createAccount(UUID uuid, String name, String worldName) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public Map getAllRecords() { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public Collection getAllOnline() { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public String getAccountName(UUID uuid) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public boolean hasAccount(UUID uuid) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public boolean hasAccount(UUID uuid, String worldName) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public boolean renameAccount(UUID uuid, String name) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public double getBalance(UUID uuid) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public double getBalance(UUID uuid, String world) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public boolean has(UUID uuid, double amount) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public boolean has(UUID uuid, String worldName, double amount) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public EconomyResponse withdraw(UUID uuid, double amount) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public EconomyResponse withdraw(UUID uuid, String worldName, double amount) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public EconomyResponse deposit(UUID uuid, double amount) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public EconomyResponse deposit(UUID uuid, String worldName, double amount) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public EconomyResponse createBank(String name, UUID uuid) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public EconomyResponse deleteBank(String name) { + return economy.deleteBank(name); + } + + @Override + public EconomyResponse bankBalance(String name) { + return economy.bankBalance(name); + } + + @Override + public EconomyResponse bankHas(String name, double amount) { + return economy.bankHas(name, amount); + } + + @Override + public EconomyResponse bankWithdraw(String name, double amount) { + return economy.bankWithdraw(name, amount); + } + + @Override + public EconomyResponse bankDeposit(String name, double amount) { + return economy.bankDeposit(name, amount); + } + + @Override + public EconomyResponse isBankOwner(String name, UUID uuid) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public EconomyResponse isBankMember(String name, UUID uuid) { + throw new UnsupportedOperationException("LegacyEconomy! Not supported."); + } + + @Override + public List getBanks() { + return economy.getBanks(); + } +} diff --git a/src/main/java/net/milkbowl/vault/economy/MultiEconomy.java b/src/main/java/net/milkbowl/vault/economy/MultiEconomy.java new file mode 100644 index 0000000..1328e9a --- /dev/null +++ b/src/main/java/net/milkbowl/vault/economy/MultiEconomy.java @@ -0,0 +1,114 @@ +package net.milkbowl.vault.economy; + +import net.milkbowl.vault.economy.wrappers.MultiEconomyWrapper; +import org.bukkit.World; + +import java.util.Collection; + +/** + * This interface is used to provide multi-world, multi-currency support for the economy. + * It allows disabling currencies/economies. + * It forces currencies to support UUIDs. + *

+ * In order to register/provide it, you should use {@link MultiEconomyWrapper#registerProviders()} + * Inside this interface, we make use of the term "implementation" to refer to an actual currency. + * You should expect that these currencies/implementations might + * return false for both {@link IdentityEconomy#supportsAllRecordsOperation()} and + * {@link IdentityEconomy#supportsAllOnlineOperation()} in case of plugin's author preference! + */ +public interface MultiEconomy { + + /** + * Checks if MultiEconomy method is enabled. + * + * @return Success or Failure + */ + public boolean isEnabled(); + + /** + * Gets name of MultiEconomy method + * + * @return Name of Economy Method + */ + public String getName(); + + /** + * Checks to see if a name of the implementation exists with this name. + * + * @param name The name of the name of the implementation to search for. + * @return True if the implementation exists, else false. + */ + public boolean existsImplementation(String name); + + /** + * Checks to see if a name of the implementation exists with this name. + * + * @param name The name of the name of the implementation to search for. + * @param world The name of the {@link World} to check for this name of the implementation in. + * @return True if the implementation exists, else false. + */ + public boolean existsImplementation(String name, String world); + + /** + * Used to get the implementation with the specified name. + * + * @param name The name of the implementation to get. + * @return The implementation with the specified name. + */ + public IdentityEconomy getImplementation(String name); + + /** + * Used to get the default implementation. This could be the default implementation for the server globally or + * for the default world if the implementation supports multi-world. + * + * @return The implementation that is the default for the server if multi-world support is not available + * otherwise the default for the default world. + */ + public IdentityEconomy getDefault(); + + /** + * Checks to see if the default implementation is not null. + * + * @return True if the default implementation is not null, else false. + */ + public default boolean hasDefault() { + return getDefault() != null; + } + + /** + * Used to get the default implementation for the specified world if this implementation has multi-world + * support, otherwise the default implementation for the server. + * + * @param world The world to get the default implementation for. + * @return The default implementation for the specified world if this implementation has multi-world + * support, otherwise the default implementation for the server. + */ + public IdentityEconomy getDefault(String world); + + /** + * Checks to see if the default implementation for the specified world is not null. + * + * @param world The world to check the default implementation for. + * @return True if the default implementation for the specified world is not null, else false. + */ + public default boolean hasDefault(String world) { + return getDefault(world) != null; + } + + /** + * Used to get a collection of every implementation identifier for the server. + * + * @return A collection of every implementation identifier that is available for the server. + */ + public Collection getAllImplementations(); + + /** + * Used to get a collection of every {@link IdentityEconomy} object that is available in the specified world if + * this implementation has multi-world support, otherwise all {@link IdentityEconomy} objects for the server. + * + * @param world The world we want to get the {@link IdentityEconomy} objects for. + * @return A collection of every implementation identifier that is available in the specified world if + * this implementation has multi-world support, otherwise all implementation identifiers for the server. + */ + public Collection getAllImplementations(String world); +} \ No newline at end of file diff --git a/src/main/java/net/milkbowl/vault/economy/wrappers/EconomyWrapper.java b/src/main/java/net/milkbowl/vault/economy/wrappers/EconomyWrapper.java new file mode 100644 index 0000000..271f112 --- /dev/null +++ b/src/main/java/net/milkbowl/vault/economy/wrappers/EconomyWrapper.java @@ -0,0 +1,55 @@ +package net.milkbowl.vault.economy.wrappers; + +import net.milkbowl.vault.economy.Economy; +import net.milkbowl.vault.economy.IdentityEconomy; +import net.milkbowl.vault.economy.LegacyEconomy; +import org.bukkit.Bukkit; +import org.bukkit.plugin.ServicePriority; +import org.bukkit.plugin.ServicesManager; + +public class EconomyWrapper { + private final Economy economy; + public EconomyWrapper(Economy economy){ + this.economy = economy; + } + + /** + * Will convert the Economy to a new IdentityEconomy + * which IdentityEconomy#isLegacy() returns true. + * Methods regarding UUID will fail fast. + * @return a legacy economy + */ + public LegacyEconomy legacy(){ + return new LegacyEconomy(economy); + } + + /** + * Will register IdentityEconomy and legacy Economy to Vault + * @param force if true, will override existing Economy and IdentityEconomy providers + * @return true if registered successfully, false if already registered + */ + public boolean registerProviders(boolean force){ + ServicesManager manager = Bukkit.getServicesManager(); + if (!force){ + if (manager.isProvidedFor(IdentityEconomy.class)) + return false; + if (manager.isProvidedFor(Economy.class)) + return false; + } + LegacyEconomy legacy = legacy(); + manager.register(IdentityEconomy.class, legacy, + Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal); + manager.register(Economy.class, economy, + Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal); + return true; + } + + /** + * Will register IdentityEconomy and legacy Economy to Vault + * If any provider is already registered, it won't proceed + * @return true if registered successfully, false if already registered + */ + public boolean registerProviders(){ + return registerProviders(false); + } +} diff --git a/src/main/java/net/milkbowl/vault/economy/wrappers/IdentityEconomyWrapper.java b/src/main/java/net/milkbowl/vault/economy/wrappers/IdentityEconomyWrapper.java new file mode 100644 index 0000000..7ba8ce1 --- /dev/null +++ b/src/main/java/net/milkbowl/vault/economy/wrappers/IdentityEconomyWrapper.java @@ -0,0 +1,44 @@ +package net.milkbowl.vault.economy.wrappers; + +import net.milkbowl.vault.economy.Economy; +import net.milkbowl.vault.economy.IdentityEconomy; +import org.bukkit.Bukkit; +import org.bukkit.plugin.ServicePriority; +import org.bukkit.plugin.ServicesManager; + +public class IdentityEconomyWrapper { + private final IdentityEconomy economy; + + public IdentityEconomyWrapper(IdentityEconomy economy){ + this.economy = economy; + } + + /** + * Will register IdentityEconomy and legacy Economy to Vault + * @param force if true, will override existing Economy and IdentityEconomy providers + * @return true if registered successfully, false if already registered + */ + public boolean registerProviders(boolean force){ + ServicesManager manager = Bukkit.getServicesManager(); + if (!force){ + if (manager.isProvidedFor(IdentityEconomy.class)) + return false; + if (manager.isProvidedFor(Economy.class)) + return false; + } + manager.register(IdentityEconomy.class, economy, + Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal); + manager.register(Economy.class, economy, + Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal); + return true; + } + + /** + * Will register IdentityEconomy and legacy Economy to Vault + * If any provider is already registered, it won't proceed + * @return true if registered successfully, false if already registered + */ + public boolean registerProviders(){ + return registerProviders(false); + } +} diff --git a/src/main/java/net/milkbowl/vault/economy/wrappers/MultiEconomyWrapper.java b/src/main/java/net/milkbowl/vault/economy/wrappers/MultiEconomyWrapper.java new file mode 100644 index 0000000..f4988dc --- /dev/null +++ b/src/main/java/net/milkbowl/vault/economy/wrappers/MultiEconomyWrapper.java @@ -0,0 +1,48 @@ +package net.milkbowl.vault.economy.wrappers; + +import net.milkbowl.vault.economy.Economy; +import net.milkbowl.vault.economy.IdentityEconomy; +import net.milkbowl.vault.economy.MultiEconomy; +import org.bukkit.Bukkit; +import org.bukkit.plugin.ServicePriority; +import org.bukkit.plugin.ServicesManager; + +public class MultiEconomyWrapper { + private final MultiEconomy economy; + + public MultiEconomyWrapper(MultiEconomy economy){ + this.economy = economy; + } + + /** + * Will register MultiEconomy, IdentityEconomy and legacy Economy to Vault + * @param force if true, will override existing Economy, IdentityEconomy and MultiEconomy providers + * @return true if registered successfully, false if already registered + */ + public boolean registerProviders(boolean force){ + ServicesManager manager = Bukkit.getServicesManager(); + if (!force){ + if (manager.isProvidedFor(MultiEconomy.class)) + return false; + if (manager.isProvidedFor(IdentityEconomy.class)) + return false; + if (manager.isProvidedFor(Economy.class)) + return false; + } + manager.register(MultiEconomy.class, economy, + Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal); + manager.register(IdentityEconomy.class, economy.getDefault(), + Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal); + manager.register(Economy.class, economy.getDefault(), + Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal); + return true; + } + /** + * Will register MultiEconomy, IdentityEconomy and legacy Economy to Vault + * If any provider is already registered, it won't proceed + * @return true if registered successfully, false if already registered + */ + public boolean registerProviders(){ + return registerProviders(false); + } +} From 1496c69fa0d6836865507b65d42b27fcedb83759 Mon Sep 17 00:00:00 2001 From: lbenav8095 Date: Sun, 2 Apr 2023 03:45:25 -0600 Subject: [PATCH 5/5] Improves and fixes JavaDocs for Economy, IdentityEconomy and Permission --- .../net/milkbowl/vault/economy/Economy.java | 131 +++++-- .../vault/economy/IdentityEconomy.java | 66 ++-- .../milkbowl/vault/permission/Permission.java | 349 ++++++++++-------- 3 files changed, 334 insertions(+), 212 deletions(-) diff --git a/src/main/java/net/milkbowl/vault/economy/Economy.java b/src/main/java/net/milkbowl/vault/economy/Economy.java index ccb3740..bb7cc02 100644 --- a/src/main/java/net/milkbowl/vault/economy/Economy.java +++ b/src/main/java/net/milkbowl/vault/economy/Economy.java @@ -16,10 +16,10 @@ package net.milkbowl.vault.economy; -import java.util.List; - import org.bukkit.OfflinePlayer; +import java.util.List; + /** * The main economy API * @@ -28,18 +28,21 @@ public interface Economy { /** * Checks if economy method is enabled. + * * @return Success or Failure */ public boolean isEnabled(); /** * Gets name of economy method + * * @return Name of Economy Method */ public String getName(); /** * Returns true if the given implementation supports banks. + * * @return true if the implementation supports banks */ public boolean hasBankSupport(); @@ -48,6 +51,7 @@ public interface Economy { * 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(); @@ -79,8 +83,9 @@ public interface Economy { public String currencyNameSingular(); /** - * - * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} or {@link #hasAccount(UUID)} instead. + * @param playerName Name of the player. + * @return True if specified player name has an account, otherwise false. + * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} */ @Deprecated public boolean hasAccount(String playerName); @@ -94,8 +99,12 @@ public interface Economy { * @return if the player has an account */ public boolean hasAccount(OfflinePlayer player); - + /** + * @param playerName Name of the player. + * @param worldName Name of the world. + * @return True if specified player name has an account in specific world, + * otherwise false. * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} instead. */ @Deprecated @@ -105,14 +114,16 @@ public interface Economy { * Checks if this player has an account on the server yet on the given world * This will always return true if the player has joined the server at least once * as all major economy plugins auto-generate a player account when the player joins the server - * - * @param player to check in the world + * + * @param player to check in the world * @param worldName world-specific account * @return if the player has an account */ public boolean hasAccount(OfflinePlayer player, String worldName); /** + * @param playerName Name of the player. + * @return Amount currently held in players account * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} instead. */ @Deprecated @@ -127,6 +138,9 @@ public interface Economy { public double getBalance(OfflinePlayer player); /** + * @param playerName Name of the player. + * @param world Name of the world. + * @return Amount/balance currently held in players account * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} instead. */ @Deprecated @@ -135,13 +149,17 @@ public interface Economy { /** * Gets balance of a player on the specified world. * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. + * * @param player to check - * @param world name of the world + * @param world name of the world * @return Amount currently held in players account */ public double getBalance(OfflinePlayer player, String world); /** + * @param playerName Name of the player. + * @param amount Amount to set balance to. + * @return true if the transaction was successful, false otherwise. * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} instead. */ @Deprecated @@ -157,6 +175,10 @@ public interface Economy { public boolean has(OfflinePlayer player, double amount); /** + * @param playerName Name of the player. + * @param worldName Name of the world. + * @param amount Amount to check for. + * @return True if the player has the amount in the given world, False else wise. * @deprecated As of VaultAPI 1.4 use @{link {@link #has(OfflinePlayer, String, double)} instead. */ @Deprecated @@ -165,15 +187,18 @@ public interface Economy { /** * Checks if the player account has the amount in 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 check + * + * @param player to check * @param worldName to check with - * @param amount to check for + * @param amount to check for * @return True if player has amount in the given world, False else wise */ public boolean has(OfflinePlayer player, String worldName, double amount); /** + * @param playerName Name of the player + * @param amount Amount to withdraw + * @return Detailed response of transaction * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} instead. */ @Deprecated @@ -189,6 +214,10 @@ public interface Economy { public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount); /** + * @param playerName Name of the player. + * @param worldName Name of the world. + * @param amount Amount to withdraw + * @return Detailed response of transaction * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} instead. */ @Deprecated @@ -197,14 +226,18 @@ public interface Economy { /** * Withdraw an amount from 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 withdraw from + * + * @param player to withdraw from * @param worldName - name of the world - * @param amount Amount to withdraw + * @param amount Amount to withdraw * @return Detailed response of transaction */ public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount); /** + * @param playerName Name of the player. + * @param amount Amount to deposit + * @return Detailed response of transaction * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} instead. */ @Deprecated @@ -220,6 +253,10 @@ public interface Economy { public EconomyResponse depositPlayer(OfflinePlayer player, double amount); /** + * @param playerName Name of the player. + * @param worldName Name of the world. + * @param amount Amount to deposit + * @return Detailed response of transaction * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} instead. */ @Deprecated @@ -228,15 +265,18 @@ public interface Economy { /** * 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 + * + * @param player to deposit to * @param worldName name of the world - * @param amount Amount to deposit + * @param amount Amount to deposit * @return Detailed response of transaction */ public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount); /** + * @param name of the account + * @param player to check + * @return Detailed response of transaction * @deprecated As of VaultAPI 1.4 use {{@link #createBank(String, OfflinePlayer)} instead. */ @Deprecated @@ -244,14 +284,16 @@ public interface Economy { /** * Creates a bank account with the specified name and the player as the owner - * @param name of account + * + * @param name of account * @param player the account should be linked to - * @return EconomyResponse Object + * @return Detailed response of transaction */ public 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 */ @@ -259,54 +301,61 @@ public interface Economy { /** * Returns the amount the bank has + * * @param name of the account - * @return EconomyResponse Object + * @return Detailed response of transaction */ 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 name of the account * @param amount to check for - * @return EconomyResponse Object + * @return Detailed response of transaction */ 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 name of the account * @param amount to withdraw - * @return EconomyResponse Object + * @return Detailed response of transaction */ 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 name of the account * @param amount to deposit - * @return EconomyResponse Object + * @return Detailed response of transaction */ public EconomyResponse bankDeposit(String name, double amount); /** - * @deprecated As of VaultAPI 1.4 use {@link #isBankOwner(String, OfflinePlayer)} or {@link #isBankOwner(String, UUID)} instead. + * @param name of the account + * @param playerName to check for ownership + * @return Detailed response of transaction + * @deprecated As of VaultAPI 1.4 use {@link #isBankOwner(String, OfflinePlayer)} instead. */ @Deprecated public EconomyResponse isBankOwner(String name, String playerName); /** * Check if a player is the owner of a bank account - * - * @param name of the account + * + * @param name of the account * @param player to check for ownership - * @return EconomyResponse Object + * @return Detailed response of transaction */ public EconomyResponse isBankOwner(String name, OfflinePlayer player); /** + * @param name of the account + * @param playerName to check for membership + * @return Detailed response of transaction * @deprecated As of VaultAPI 1.4 use {{@link #isBankMember(String, OfflinePlayer)} instead. */ @Deprecated @@ -314,33 +363,40 @@ public interface Economy { /** * Check if the player is a member of the bank account - * - * @param name of the account + * + * @param name of the account * @param player to check membership - * @return EconomyResponse Object + * @return Detailed response of transaction */ public EconomyResponse isBankMember(String name, OfflinePlayer player); /** * Gets the list of banks + * * @return the List of Banks */ public List getBanks(); /** - * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer)} or {@link #createPlayerAccount(UUID)} instead. + * @param playerName Name of the player + * @return if the account creation was successful + * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer)} instead. */ @Deprecated public 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); /** + * @param playerName Name of the player + * @param worldName Name of the world + * @return if the account creation was successful * @deprecated As of VaultAPI 1.4 use {{@link #createPlayerAccount(OfflinePlayer, String)} instead. */ @Deprecated @@ -349,7 +405,8 @@ public interface Economy { /** * Attempts to create a player account for the given player on the specified world * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then false will always be returned. - * @param player OfflinePlayer + * + * @param player OfflinePlayer * @param worldName String name of the world * @return if the account creation was successful */ diff --git a/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java b/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java index f3bfa5b..50591cc 100644 --- a/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java +++ b/src/main/java/net/milkbowl/vault/economy/IdentityEconomy.java @@ -32,13 +32,14 @@ *

* In order to register/provide it, you should use {@link IdentityEconomyWrapper#registerProviders()} */ -public interface IdentityEconomy extends Economy{ +public interface IdentityEconomy extends Economy { /** * Used to determine if IdentityEconomy was built through * the EconomyWrapper as a LegacyEconomy. * If false, method {@link #getAllRecords()} will not be work. * This was made in order to support plugins which use older versions of VaultAPI/Vault. * You can also use it / override it to disable previous mentioned methods! + * * @return true if operation is supported */ public boolean supportsAllRecordsOperation(); @@ -49,6 +50,7 @@ public interface IdentityEconomy extends Economy{ * If false, the method {@link #getAllOnline()} (UUID)} will not be work. * This was made in order to support plugins which use older versions of VaultAPI/Vault. * You can also use it / override it to disable previous mentioned methods! + * * @return true if operation is supported */ public boolean supportsAllOnlineOperation(); @@ -60,6 +62,7 @@ public interface IdentityEconomy extends Economy{ * are online/connected to the server in real time. * If true, you should expect to call these operations * asynchronously. + * * @return true if operation is supported */ public boolean supportsOfflineOperations(); @@ -69,6 +72,7 @@ public interface IdentityEconomy extends Economy{ * the EconomyWrapper as a LegacyEconomy. * If false, you should expect UnsupportedOperationException * being thrown when calling these methods. + * * @return true if operation is supported */ public boolean supportsUUIDOperations(); @@ -79,7 +83,7 @@ public interface IdentityEconomy extends 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 @@ -90,7 +94,7 @@ public interface IdentityEconomy extends Economy{ * Attempts to create an account for the given UUID on the specified world * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then * false will always be returned. - * + * * @param uuid associated with the account * @param name associated with the account. * @param worldName String name of the world @@ -103,9 +107,9 @@ public interface IdentityEconomy extends Economy{ * plugin (in the database, not memory), as well as their last-known-name. This is used for Vault's economy * converter and should be given every account available. * Needs IdentityEconomy#hasUUIDSupport() to be true. - * + * * @return a {@link Map} composed of the accounts keyed by their UUID, along - * with their associated last-known-name. + * with their associated last-known-name. */ public Map getAllRecords(); @@ -114,6 +118,7 @@ public interface IdentityEconomy extends Economy{ * online/connected to the server. * This is used for Vault's economy converter and should * Needs IdentityEconomy#hasUUIDSupport() to be true. + * * @return a {@link Collection} of all UUIDs which have accounts in the plugin */ public Collection getAllOnline(); @@ -121,14 +126,15 @@ public interface IdentityEconomy extends 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. + * @return the last known name of the account associated with the given UUID. */ public String getAccountName(UUID uuid); /** * Checks if this uuid has an account yet - * + * * @param uuid to check * @return if the uuid has an account */ @@ -136,7 +142,7 @@ public interface IdentityEconomy extends Economy{ /** * 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 @@ -145,18 +151,18 @@ public interface IdentityEconomy extends Economy{ /** * A method which changes the name associated with the given UUID in the - * Map received from {@link #getAllRecords()} - * + * Map<UUID, String> received from {@link #getAllRecords()} + * * @param uuid which is having a name change. - * @param name name that will be associated with the UUID in the - * Map map. + * @param name name that will be associated with the UUID in the + * Map<UUID, String> map. * @return true if the name change is successful. */ public boolean renameAccount(UUID uuid, String name); /** * Gets balance of a UUID - * + * * @param uuid of the account to get a balance for * @return Amount currently held in account associated with the given UUID */ @@ -165,7 +171,7 @@ public interface IdentityEconomy extends Economy{ /** * 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 @@ -175,7 +181,7 @@ public interface IdentityEconomy extends Economy{ /** * 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 @@ -186,19 +192,19 @@ public interface IdentityEconomy extends Economy{ * 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 + * 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 @@ -209,7 +215,7 @@ public interface IdentityEconomy extends Economy{ * 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 @@ -220,7 +226,7 @@ public interface IdentityEconomy extends Economy{ /** * 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 @@ -231,7 +237,7 @@ public interface IdentityEconomy extends Economy{ * 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 @@ -246,7 +252,7 @@ public interface IdentityEconomy extends Economy{ /** * 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 @@ -255,7 +261,7 @@ public interface IdentityEconomy extends Economy{ /** * Deletes a bank account with the specified name. - * + * * @param name of the back to delete * @return if the operation completed successfully */ @@ -263,7 +269,7 @@ public interface IdentityEconomy extends Economy{ /** * Returns the amount the bank has - * + * * @param name of the account * @return EconomyResponse Object */ @@ -272,7 +278,7 @@ public interface IdentityEconomy extends Economy{ /** * 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 @@ -281,7 +287,7 @@ public interface IdentityEconomy extends Economy{ /** * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS - * + * * @param name of the account * @param amount to withdraw * @return EconomyResponse Object @@ -290,7 +296,7 @@ public interface IdentityEconomy extends Economy{ /** * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS - * + * * @param name of the account * @param amount to deposit * @return EconomyResponse Object @@ -299,7 +305,7 @@ public interface IdentityEconomy extends Economy{ /** * 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 @@ -308,7 +314,7 @@ public interface IdentityEconomy extends Economy{ /** * Check if the uuid is a member of the bank account - * + * * @param name of the account * @param uuid to check membership * @return EconomyResponse Object @@ -317,7 +323,7 @@ public interface IdentityEconomy extends Economy{ /** * Gets the list of banks - * + * * @return the List of Banks */ public List getBanks(); diff --git a/src/main/java/net/milkbowl/vault/permission/Permission.java b/src/main/java/net/milkbowl/vault/permission/Permission.java index 0f68eba..4328164 100644 --- a/src/main/java/net/milkbowl/vault/permission/Permission.java +++ b/src/main/java/net/milkbowl/vault/permission/Permission.java @@ -15,8 +15,6 @@ */ package net.milkbowl.vault.permission; -import java.util.logging.Logger; - import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.command.CommandSender; @@ -25,34 +23,42 @@ import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.Plugin; +import java.util.logging.Logger; + /** * 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 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(); - + /** + * @param world World name + * @param player player name + * @param permission permission node + * @return true if player has permission node * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. */ @Deprecated @@ -64,6 +70,10 @@ public boolean has(String world, String player, String permission) { } /** + * @param world World object + * @param player player name + * @param permission permission node + * @return true if player has permission node * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. */ @Deprecated @@ -78,9 +88,10 @@ public boolean has(World world, String player, String 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 sender to check permissions on * @param permission to check for * @return true if the sender has the permission */ @@ -90,7 +101,8 @@ public boolean has(CommandSender sender, String permission) { /** * Checks if player has a permission node. (Short for playerHas(...) - * @param player Player Object + * + * @param player Player Object * @param permission Permission node * @return Success or Failure */ @@ -99,12 +111,20 @@ public boolean has(Player player, String permission) { } /** + * @param world world name + * @param player player name + * @param permission permission node + * @return true if player has permission, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. */ @Deprecated abstract public boolean playerHas(String world, String player, String permission); /** + * @param world World object + * @param player player name + * @param permission permission node + * @return true if player has permission, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. */ @Deprecated @@ -114,21 +134,21 @@ public boolean playerHas(World world, String player, String 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 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); - } + if (world == null) { + return has((String) null, player.getName(), permission); + } return has(world, player.getName(), permission); } @@ -136,8 +156,8 @@ public boolean playerHas(String world, OfflinePlayer player, String 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 player Player Object * @param permission Permission node * @return Success or Failure */ @@ -146,20 +166,23 @@ public boolean playerHas(Player player, String permission) { } /** + * @param world World name + * @param player Player name + * @param permission Permission node + * @return Success or Failure * @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); /** + * @param world World Object + * @param player Player name + * @param permission Permission node + * @return true if successful, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerAdd(String, OfflinePlayer, String)} instead. */ @Deprecated @@ -174,9 +197,9 @@ public boolean playerAdd(World world, String player, String 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 world String world name + * @param player to add to * @param permission Permission node * @return Success or Failure */ @@ -191,106 +214,110 @@ public boolean playerAdd(String world, OfflinePlayer player, String 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 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. + * 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 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!"); - } + 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 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; - } - } + 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); + PermissionAttachment attach = player.addAttachment(plugin); + attach.setPermission(permission, true); - return 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 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); + 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 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); + 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 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); + 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 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); + return playerRemoveTransient((OfflinePlayer) player, permission); } - + /** + * @param world World name + * @param player player name + * @param permission Permission node + * @return true if successful, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerRemove(String, OfflinePlayer, String)} instead. */ @Deprecated @@ -300,9 +327,9 @@ public boolean playerRemoveTransient(String worldName, Player player, String per * 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 world World name + * @param player OfflinePlayer * @param permission Permission node * @return Success or Failure */ @@ -317,9 +344,9 @@ public boolean playerRemove(String world, OfflinePlayer player, String permissio * 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 world World name + * @param player Player name * @param permission Permission node * @return Success or Failure */ @@ -334,58 +361,58 @@ public boolean playerRemove(World world, String player, String 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 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. + * 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 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; - } - } - + 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 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; + 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 world World name + * @param group Group name * @param permission Permission node * @return Success or Failure */ @@ -395,9 +422,9 @@ public boolean playerRemoveTransient(Player player, 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 world World Object + * @param group Group name * @param permission Permission node * @return Success or Failure */ @@ -412,9 +439,9 @@ public boolean groupHas(World 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 name - * @param group Group name + * + * @param world World name + * @param group Group name * @param permission Permission node * @return Success or Failure */ @@ -424,9 +451,9 @@ public boolean groupHas(World 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 world World Object + * @param group Group name * @param permission Permission node * @return Success or Failure */ @@ -441,9 +468,9 @@ public boolean groupAdd(World 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 name - * @param group Group name + * + * @param world World name + * @param group Group name * @param permission Permission node * @return Success or Failure */ @@ -453,9 +480,9 @@ public boolean groupAdd(World 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 world World Object + * @param group Group name * @param permission Permission node * @return Success or Failure */ @@ -467,12 +494,20 @@ public boolean groupRemove(World world, String group, String permission) { } /** + * @param world World name + * @param player player name + * @param group group name + * @return true if player is in group, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerInGroup(String, OfflinePlayer, String)} instead. */ @Deprecated abstract public boolean playerInGroup(String world, String player, String group); /** + * @param world World object + * @param player player name + * @param group group name + * @return true if player is in group, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerInGroup(String, OfflinePlayer, String)} instead. */ @Deprecated @@ -482,15 +517,15 @@ public boolean playerInGroup(World world, String player, String 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 world World Object * @param player to check - * @param group Group name + * @param group Group name * @return Success or Failure */ public boolean playerInGroup(String world, OfflinePlayer player, String group) { @@ -504,9 +539,9 @@ public boolean playerInGroup(String world, OfflinePlayer player, String 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 + * @param group Group name * @return Success or Failure */ public boolean playerInGroup(Player player, String group) { @@ -514,12 +549,20 @@ public boolean playerInGroup(Player player, String group) { } /** + * @param world World name + * @param player player name + * @param group group name + * @return true if successful, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerAddGroup(String, OfflinePlayer, String)} instead. */ @Deprecated abstract public boolean playerAddGroup(String world, String player, String group); /** + * @param world World Object + * @param player player name + * @param group group name + * @return true if successful, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerAddGroup(String, OfflinePlayer, String)} instead. */ @Deprecated @@ -534,10 +577,10 @@ public boolean playerAddGroup(World world, String player, String 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 world String world name * @param player to add - * @param group Group name + * @param group Group name * @return Success or Failure */ public boolean playerAddGroup(String world, OfflinePlayer player, String group) { @@ -546,14 +589,14 @@ public boolean playerAddGroup(String world, OfflinePlayer player, String 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 + * @param group Group name * @return Success or Failure */ public boolean playerAddGroup(Player player, String group) { @@ -561,12 +604,20 @@ public boolean playerAddGroup(Player player, String group) { } /** + * @param world world name + * @param player player name + * @param group group name + * @return true if successful, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerRemoveGroup(String, OfflinePlayer, String)} instead. */ @Deprecated abstract public boolean playerRemoveGroup(String world, String player, String group); /** + * @param world World Object + * @param player name + * @param group Group name + * @return true if successful, false otherwise * @deprecated As of VaultAPI 1.4 use {@link #playerRemoveGroup(String, OfflinePlayer, String)} instead. */ @Deprecated @@ -576,15 +627,15 @@ public boolean playerRemoveGroup(World world, String player, String 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 world World Object * @param player to remove - * @param group Group name + * @param group Group name * @return Success or Failure */ public boolean playerRemoveGroup(String world, OfflinePlayer player, String group) { @@ -598,9 +649,9 @@ public boolean playerRemoveGroup(String world, OfflinePlayer player, String grou * 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 + * @param group Group name * @return Success or Failure */ public boolean playerRemoveGroup(Player player, String group) { @@ -608,12 +659,18 @@ public boolean playerRemoveGroup(Player player, String group) { } /** + * @param world world name + * @param player player name + * @return Array of groups * @deprecated As of VaultAPI 1.4 use {@link #getPlayerGroups(String, OfflinePlayer)} instead. */ @Deprecated abstract public String[] getPlayerGroups(String world, String player); /** + * @param world World Object + * @param player player name + * @return Array of groups * @deprecated As of VaultAPI 1.4 use {@link #getPlayerGroups(String, OfflinePlayer)} instead. */ @Deprecated @@ -623,25 +680,25 @@ public String[] getPlayerGroups(World world, String 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 world String world name * @param player OfflinePlayer * @return Array of groups */ public String[] getPlayerGroups(String world, OfflinePlayer player) { - return getPlayerGroups(world, player.getName()); + 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 */ @@ -665,13 +722,13 @@ public String getPrimaryGroup(World world, String 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 world String world name * @param player to get from * @return Players primary group */ @@ -683,22 +740,24 @@ public String getPrimaryGroup(String world, OfflinePlayer player) { * 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();