Adds support for legacy Vault plugins

This commit is contained in:
lbenav8095 2023-03-22 01:57:21 -06:00
parent 29ad793ffc
commit 6034cb2132
1 changed files with 260 additions and 0 deletions

View File

@ -16,6 +16,8 @@
package net.milkbowl.vault.economy;
import org.bukkit.OfflinePlayer;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -137,6 +139,21 @@ public interface Economy {
*/
public boolean hasAccount(UUID uuid);
/**
* Checks if this player has an account yet
* @param player to check
*/
public default boolean hasAccount(OfflinePlayer player){
return hasAccount(player.getUniqueId());
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} instead.
*/
@Deprecated
public boolean hasAccount(String playerName);
/**
* Checks if this uuid has an account yet on the given world
*
@ -146,6 +163,22 @@ public interface Economy {
*/
public boolean hasAccount(UUID uuid, String worldName);
/**
* Checks if this player has an account yet on the given world
* @param player to check
* @param worldName world-specific account
*/
public default boolean hasAccount(OfflinePlayer player, String worldName){
return hasAccount(player.getUniqueId(), worldName);
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} instead.
*/
@Deprecated
public boolean hasAccount(String playerName, String worldName);
/**
* A method which changes the name associated with the given UUID in the
* Map<UUID, String> received from {@link #getUUIDNameMap()}.
@ -165,6 +198,21 @@ public interface Economy {
*/
public double getBalance(UUID uuid);
/**
* Gets balance of a player
* @param player to check
*/
public default double getBalance(OfflinePlayer player){
return getBalance(player.getUniqueId());
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} instead.
*/
@Deprecated
public double getBalance(String playerName);
/**
* 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.
@ -175,6 +223,23 @@ public interface Economy {
*/
public double getBalance(UUID uuid, String world);
/**
* 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
*/
public default double getBalance(OfflinePlayer player, String world){
return getBalance(player.getUniqueId(), world);
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} instead.
*/
@Deprecated
public double getBalance(String playerName, String world);
/**
* Checks if the account associated with the given UUID has the amount - DO NOT
* USE NEGATIVE AMOUNTS
@ -185,6 +250,23 @@ public interface Economy {
*/
public boolean has(UUID uuid, double amount);
/**
* Checks if the account associated with the given player has the amount - DO NOT
* USE NEGATIVE AMOUNTS
* @param player to check
* @param amount to check for
*/
public default boolean has(OfflinePlayer player, double amount){
return has(player.getUniqueId(), amount);
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} instead.
*/
@Deprecated
public boolean has(String playerName, 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
@ -198,6 +280,25 @@ public interface Economy {
*/
public boolean has(UUID uuid, String worldName, double amount);
/**
* Checks if the account associated with the given player 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 player to check
* @param worldName to check with
* @param amount to check for
*/
public default boolean has(OfflinePlayer player, String worldName, double amount){
return has(player.getUniqueId(), worldName, amount);
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, String, double)} instead.
*/
@Deprecated
public boolean has(String playerName, String worldName, double amount);
/**
* Withdraw an amount from an account associated with a UUID - DO NOT USE
* NEGATIVE AMOUNTS
@ -208,6 +309,23 @@ public interface Economy {
*/
public EconomyResponse withdraw(UUID uuid, double amount);
/**
* Withdraw an amount from an account associated with a player - DO NOT USE
* NEGATIVE AMOUNTS
* @param player to withdraw from
* @param amount Amount to withdraw
*/
public default EconomyResponse withdrawPlayer(OfflinePlayer player, double amount){
return withdraw(player.getUniqueId(), amount);
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} instead.
*/
@Deprecated
public EconomyResponse withdrawPlayer(String playerName, 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
@ -220,6 +338,25 @@ public interface Economy {
*/
public EconomyResponse withdraw(UUID uuid, String worldName, double amount);
/**
* Withdraw an amount from an account associated with 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 worldName - name of the world
* @param amount Amount to withdraw
*/
public default EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount){
return withdraw(player.getUniqueId(), worldName, amount);
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} instead.
*/
@Deprecated
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount);
/**
* Deposit an amount to an account associated with the given UUID - DO NOT USE
* NEGATIVE AMOUNTS
@ -230,6 +367,23 @@ public interface Economy {
*/
public EconomyResponse deposit(UUID uuid, double amount);
/**
* Deposit an amount to an account associated with the given player - DO NOT USE
* NEGATIVE AMOUNTS
* @param player to deposit to
* @param amount Amount to deposit
*/
public default EconomyResponse depositPlayer(OfflinePlayer player, double amount){
return deposit(player.getUniqueId(), amount);
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} instead.
*/
@Deprecated
public EconomyResponse depositPlayer(String playerName, 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
@ -242,6 +396,25 @@ public interface Economy {
*/
public EconomyResponse deposit(UUID uuid, String worldName, double amount);
/**
* Deposit an amount from an account associated with 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 worldName name of the world
* @param amount Amount to deposit
*/
public default EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount){
return deposit(player.getUniqueId(), worldName, amount);
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} instead.
*/
@Deprecated
public EconomyResponse depositPlayer(String playerName, String worldName, double amount);
/*
* Bank methods follow.
*/
@ -256,6 +429,25 @@ public interface Economy {
*/
public EconomyResponse createBank(String name, UUID uuid);
/**
* Creates a bank account with the specified name and the given player as the
* owner
*
* @param name of account
* @param player the account should be linked to
* @return EconomyResponse Object
*/
public default EconomyResponse createBank(String name, OfflinePlayer player){
return createBank(name, player.getUniqueId());
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #createBank(String, OfflinePlayer)} instead.
*/
@Deprecated
public EconomyResponse createBank(String name, String player);
/**
* Deletes a bank account with the specified name.
*
@ -309,6 +501,24 @@ public interface Economy {
*/
public EconomyResponse isBankOwner(String name, UUID uuid);
/**
* Check if a player is the owner of a bank account
*
* @param name of the account
* @param player to check for ownership
* @return EconomyResponse Object
*/
public default EconomyResponse isBankOwner(String name, OfflinePlayer player){
return isBankOwner(name, player.getUniqueId());
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #isBankOwner(String, OfflinePlayer)} instead.
*/
@Deprecated
public EconomyResponse isBankOwner(String name, String playerName);
/**
* Check if the uuid is a member of the bank account
*
@ -318,10 +528,60 @@ public interface Economy {
*/
public EconomyResponse isBankMember(String name, UUID uuid);
/**
* Check if the player is a member of the bank account
*
* @param name of the account
* @param player to check membership
* @return EconomyResponse Object
*/
public default EconomyResponse isBankMember(String name, OfflinePlayer player){
return isBankMember(name, player.getUniqueId());
}
/**
*
* @deprecated As of VaultAPI 1.4 use {@link #isBankMember(String, OfflinePlayer)} instead.
*/
@Deprecated
public EconomyResponse isBankMember(String name, String playerName);
/**
* Gets the list of banks
*
* @return the List of Banks
*/
public List<String> getBanks();
/**
* @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 default boolean createPlayerAccount(OfflinePlayer player){
return createAccount(player.getUniqueId(),player.getName());
}
/**
* @deprecated As of VaultAPI 1.4 use {{@link #createPlayerAccount(OfflinePlayer, String)} instead.
*/
@Deprecated
public boolean createPlayerAccount(String playerName, String worldName);
/**
* 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 worldName String name of the world
* @return if the account creation was successful
*/
public default boolean createPlayerAccount(OfflinePlayer player, String worldName){
return createAccount(player.getUniqueId(),player.getName(),worldName);
}
}