Package com.earth2me.essentials.api
Class Economy
java.lang.Object
com.earth2me.essentials.api.Economy
- Direct Known Subclasses:
Economy
You should use Vault instead of directly using this class.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
add
(User user, BigDecimal amount) Adds money to the balance of a userstatic void
Deprecated.static void
add
(String name, BigDecimal amount) Deprecated.static void
add
(UUID uuid, BigDecimal amount) Adds money to the balance of a userstatic boolean
Creates dummy files for a npc, if there is no player yet with that name.static void
divide
(User user, BigDecimal amount) Divides the balance of a user by a valuestatic void
Deprecated.static void
divide
(String name, BigDecimal amount) Deprecated.Usernames can change, usedivide(UUID, BigDecimal)
ordivide(User, BigDecimal)
static void
divide
(UUID uuid, BigDecimal amount) Divides the balance of a user by a valuestatic String
format
(double amount) Deprecated.Useformat(BigDecimal)
if your input is already aBigDecimal
.static String
format
(BigDecimal amount) Formats the amount of money like all other Essentials functions.static double
Deprecated.static BigDecimal
getMoneyExact
(User user) Get the exact balance of the account with the given UUID.static BigDecimal
getMoneyExact
(String name) Deprecated.Usernames can change, usegetMoneyExact(UUID)
orgetMoneyExact(User)
static BigDecimal
getMoneyExact
(UUID uuid) Get the exact balance of the account with the given UUID.static boolean
hasEnough
(User user, BigDecimal amount) static boolean
Deprecated.static boolean
hasEnough
(String name, BigDecimal amount) Deprecated.Usernames can change, usehasEnough(UUID, BigDecimal)
orhasEnough(User, BigDecimal)
static boolean
hasEnough
(UUID uuid, BigDecimal amount) static boolean
hasLess
(User user, BigDecimal amount) static boolean
Deprecated.static boolean
hasLess
(String name, BigDecimal amount) Deprecated.Usernames can change, usehasLess(UUID, BigDecimal)
orhasLess(User, BigDecimal)
static boolean
hasLess
(UUID uuid, BigDecimal amount) static boolean
hasMore
(User user, BigDecimal amount) static boolean
Deprecated.static boolean
hasMore
(String name, BigDecimal amount) Deprecated.Usernames can change, usehasMore(UUID, BigDecimal)
orhasMore(User, BigDecimal)
static boolean
hasMore
(UUID uuid, BigDecimal amount) static boolean
isNegative
(User user) Test if the user has a negative balancestatic boolean
isNegative
(String name) Deprecated.Usernames can change, useisNegative(UUID)
orisNegative(User)
static boolean
isNegative
(UUID uuid) Test if the user has a negative balancestatic boolean
Test if a player is a npcstatic void
multiply
(User user, BigDecimal amount) Multiplies the balance of a user by a valuestatic void
Deprecated.static void
multiply
(String name, BigDecimal amount) Deprecated.Usernames can change, usemultiply(UUID, BigDecimal)
ormultiply(User, BigDecimal)
static void
multiply
(UUID uuid, BigDecimal amount) Multiplies the balance of a user by a valuestatic boolean
playerExists
(String name) Deprecated.Essentials is moving away from username based economy methods.static boolean
playerExists
(UUID uuid) Test if a player exists to avoid the UserDoesNotExistExceptionstatic void
Deletes a user, if it is marked as npc.static void
resetBalance
(User user) Resets the balance of a user to the starting balancestatic void
resetBalance
(String name) Deprecated.Usernames can change, useresetBalance(UUID)
orresetBalance(User)
static void
resetBalance
(UUID uuid) Resets the balance of a user to the starting balancestatic void
setEss
(IEssentials aEss) static void
setMoney
(User user, BigDecimal balance) Sets the balance of a userstatic void
Deprecated.static void
setMoney
(String name, BigDecimal balance) Deprecated.Usernames can change usesetMoney(UUID, BigDecimal)
orsetMoney(User, BigDecimal)
static void
setMoney
(UUID uuid, BigDecimal balance) Sets the balance of a userstatic void
substract
(String name, BigDecimal amount) Deprecated.Usernames can change, usesubtract(UUID, BigDecimal)
orsubtract(User, BigDecimal)
static void
subtract
(User user, BigDecimal amount) Subtracts money from the balance of a userstatic void
Deprecated.static void
subtract
(UUID uuid, BigDecimal amount) Subtracts money from the balance of a user
-
Field Details
-
MATH_CONTEXT
-
-
Constructor Details
-
Economy
protected Economy()
-
-
Method Details
-
setEss
- Parameters:
aEss
- the ess to set
-
getMoney
Deprecated.Returns the balance of a user- Parameters:
name
- Name of the user- Returns:
- balance
- Throws:
UserDoesNotExistException
-
getMoneyExact
Deprecated.Usernames can change, usegetMoneyExact(UUID)
orgetMoneyExact(User)
- Parameters:
name
- Name of user- Returns:
- Exact balance of user
- Throws:
UserDoesNotExistException
-
getMoneyExact
Get the exact balance of the account with the given UUID.- Parameters:
uuid
- The UUID of the user account to retrieve the balance for- Returns:
- The account's balance
- Throws:
UserDoesNotExistException
- If the user does not exist
-
getMoneyExact
Get the exact balance of the account with the given UUID.- Parameters:
user
- The user account to retrieve the balance for- Returns:
- The account's balance
-
setMoney
@Deprecated public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException Deprecated.Sets the balance of a user- Parameters:
name
- Name of the userbalance
- The balance you want to set- Throws:
UserDoesNotExistException
- If a user by that name does not existsNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
setMoney
@Deprecated public static void setMoney(String name, BigDecimal balance) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException Deprecated.Usernames can change usesetMoney(UUID, BigDecimal)
orsetMoney(User, BigDecimal)
Sets the balance of a user- Parameters:
name
- Name of userbalance
- The balance you want to set- Throws:
UserDoesNotExistException
- If a user by that name does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
setMoney
public static void setMoney(UUID uuid, BigDecimal balance) throws NoLoanPermittedException, UserDoesNotExistException, MaxMoneyException Sets the balance of a user- Parameters:
uuid
- UUID of userbalance
- The balance you want to set- Throws:
UserDoesNotExistException
- If a user by that uuid does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
setMoney
public static void setMoney(User user, BigDecimal balance) throws NoLoanPermittedException, MaxMoneyException Sets the balance of a user- Parameters:
user
- Userbalance
- The balance you want to set- Throws:
NoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
add
@Deprecated public static void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException Deprecated.Adds money to the balance of a user- Parameters:
name
- Name of the useramount
- The money you want to add- Throws:
UserDoesNotExistException
- If a user by that name does not existsNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
add
@Deprecated public static void add(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException, MaxMoneyException Deprecated.Usernames can change, useadd(UUID, BigDecimal)
oradd(User, BigDecimal)
Adds money to the balance of a user- Parameters:
name
- Name of the useramount
- The amount of money to be added to the user's account- Throws:
UserDoesNotExistException
- If a user by that name does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
add
public static void add(UUID uuid, BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, UserDoesNotExistException, MaxMoneyException Adds money to the balance of a user- Parameters:
uuid
- UUID of the useramount
- The money you want to add- Throws:
UserDoesNotExistException
- If a user by that uuid does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
add
public static void add(User user, BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, MaxMoneyException Adds money to the balance of a user- Parameters:
user
- Useramount
- The money you want to add- Throws:
NoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
subtract
@Deprecated public static void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException Deprecated.Subtracts money from the balance of a user- Parameters:
name
- Name of the useramount
- The money you want to subtract- Throws:
UserDoesNotExistException
- If a user by that name does not existsNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
substract
@Deprecated public static void substract(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException, MaxMoneyException Deprecated.Usernames can change, usesubtract(UUID, BigDecimal)
orsubtract(User, BigDecimal)
Subtracts money from the balance of a user- Parameters:
name
- Name of the useramount
- The money you want to subtract- Throws:
UserDoesNotExistException
- If a user by that name does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
subtract
public static void subtract(UUID uuid, BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, UserDoesNotExistException, MaxMoneyException Subtracts money from the balance of a user- Parameters:
uuid
- UUID of the useramount
- The money you want to subtract- Throws:
UserDoesNotExistException
- If a user by that UUID does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
subtract
public static void subtract(User user, BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, MaxMoneyException Subtracts money from the balance of a user- Parameters:
user
- Useramount
- The money you want to subtract- Throws:
NoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
divide
@Deprecated public static void divide(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException Deprecated.Divides the balance of a user by a value- Parameters:
name
- Name of the useramount
- The balance is divided by this value- Throws:
UserDoesNotExistException
- If a user by that name does not existsNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
divide
@Deprecated public static void divide(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException, MaxMoneyException Deprecated.Usernames can change, usedivide(UUID, BigDecimal)
ordivide(User, BigDecimal)
Divides the balance of a user by a value- Parameters:
name
- Name of the useramount
- The balance is divided by this value- Throws:
UserDoesNotExistException
- If a user by that name does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
divide
public static void divide(UUID uuid, BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, UserDoesNotExistException, MaxMoneyException Divides the balance of a user by a value- Parameters:
uuid
- Name of the useramount
- The balance is divided by this value- Throws:
UserDoesNotExistException
- If a user by that UUID does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
divide
public static void divide(User user, BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, MaxMoneyException Divides the balance of a user by a value- Parameters:
user
- Name of the useramount
- The balance is divided by this value- Throws:
NoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
multiply
@Deprecated public static void multiply(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException Deprecated.Multiplies the balance of a user by a value- Parameters:
name
- Name of the useramount
- The balance is multiplied by this value- Throws:
UserDoesNotExistException
- If a user by that name does not existsNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
multiply
@Deprecated public static void multiply(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException, MaxMoneyException Deprecated.Usernames can change, usemultiply(UUID, BigDecimal)
ormultiply(User, BigDecimal)
Multiplies the balance of a user by a value- Parameters:
name
- Name of the useramount
- The balance is multiplied by the this value- Throws:
UserDoesNotExistException
- If a user by that name does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
multiply
public static void multiply(UUID uuid, BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, UserDoesNotExistException, MaxMoneyException Multiplies the balance of a user by a value- Parameters:
uuid
- Name of the useramount
- The balance is multiplied by the this value- Throws:
UserDoesNotExistException
- If a user by that uuid does not existNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
multiply
public static void multiply(User user, BigDecimal amount) throws NoLoanPermittedException, ArithmeticException, MaxMoneyException Multiplies the balance of a user by a value- Parameters:
user
- Name of the useramount
- The balance is multiplied by the this value- Throws:
NoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of moneyArithmeticException
-
resetBalance
@Deprecated public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException, MaxMoneyException Deprecated.Usernames can change, useresetBalance(UUID)
orresetBalance(User)
Resets the balance of a user to the starting balance- Parameters:
name
- Name of the user- Throws:
UserDoesNotExistException
- If a user by that name does not existsNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
resetBalance
public static void resetBalance(UUID uuid) throws NoLoanPermittedException, UserDoesNotExistException, MaxMoneyException Resets the balance of a user to the starting balance- Parameters:
uuid
- UUID of the user- Throws:
UserDoesNotExistException
- If a user by that UUID does not existsNoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
resetBalance
Resets the balance of a user to the starting balance- Parameters:
user
- User- Throws:
NoLoanPermittedException
- If the user is not allowed to have a negative balanceMaxMoneyException
- If this transaction has but the user over the maximum amount of money
-
hasEnough
@Deprecated public static boolean hasEnough(String name, double amount) throws UserDoesNotExistException Deprecated.- Parameters:
name
- Name of the useramount
- The amount of money the user should have- Returns:
- true, if the user has more or an equal amount of money
- Throws:
UserDoesNotExistException
- If a user by that name does not exists
-
hasEnough
public static boolean hasEnough(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException Deprecated.Usernames can change, usehasEnough(UUID, BigDecimal)
orhasEnough(User, BigDecimal)
- Parameters:
name
- Name of the useramount
- The amount of money the user should have- Returns:
- true, if the user has more or an equal amount of money
- Throws:
UserDoesNotExistException
- If a user by that name does not existArithmeticException
-
hasEnough
public static boolean hasEnough(UUID uuid, BigDecimal amount) throws ArithmeticException, UserDoesNotExistException - Parameters:
uuid
- UUID of the useramount
- The amount of money the user should have- Returns:
- true, if the user has more or an equal amount of money
- Throws:
UserDoesNotExistException
- If a user by that UUID does not existArithmeticException
-
hasEnough
- Parameters:
user
- Useramount
- The amount of money the user should have- Returns:
- true, if the user has more or an equal amount of money
- Throws:
ArithmeticException
-
hasMore
@Deprecated public static boolean hasMore(String name, double amount) throws UserDoesNotExistException Deprecated.- Parameters:
name
- Name of the useramount
- The amount of money the user should have- Returns:
- true, if the user has more money
- Throws:
UserDoesNotExistException
- If a user by that name does not exists
-
hasMore
@Deprecated public static boolean hasMore(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException Deprecated.Usernames can change, usehasMore(UUID, BigDecimal)
orhasMore(User, BigDecimal)
- Parameters:
name
- Name of the useramount
- The amount of money the user should have- Returns:
- true, if the user has more money
- Throws:
UserDoesNotExistException
- If a user by that name does not existsArithmeticException
-
hasMore
public static boolean hasMore(UUID uuid, BigDecimal amount) throws ArithmeticException, UserDoesNotExistException - Parameters:
uuid
- UUID of the useramount
- The amount of money the user should have- Returns:
- true, if the user has more money
- Throws:
UserDoesNotExistException
- If a user by that UUID does not existsArithmeticException
-
hasMore
- Parameters:
user
- Useramount
- The amount of money the user should have- Returns:
- true, if the user has more money
- Throws:
ArithmeticException
-
hasLess
@Deprecated public static boolean hasLess(String name, double amount) throws UserDoesNotExistException Deprecated.- Parameters:
name
- Name of the useramount
- The amount of money the user should not have- Returns:
- true, if the user has less money
- Throws:
UserDoesNotExistException
- If a user by that name does not exists
-
hasLess
@Deprecated public static boolean hasLess(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException Deprecated.Usernames can change, usehasLess(UUID, BigDecimal)
orhasLess(User, BigDecimal)
- Parameters:
name
- Name of the useramount
- The amount of money the user should not have- Returns:
- true, if the user has less money
- Throws:
UserDoesNotExistException
- If a user by that name does not existArithmeticException
-
hasLess
public static boolean hasLess(UUID uuid, BigDecimal amount) throws ArithmeticException, UserDoesNotExistException - Parameters:
uuid
- UUID of the useramount
- The amount of money the user should not have- Returns:
- true, if the user has less money
- Throws:
UserDoesNotExistException
- If a user by that UUID does not existArithmeticException
-
hasLess
- Parameters:
user
- Useramount
- The amount of money the user should not have- Returns:
- true, if the user has less money
- Throws:
ArithmeticException
-
isNegative
Deprecated.Usernames can change, useisNegative(UUID)
orisNegative(User)
Test if the user has a negative balance- Parameters:
name
- Name of the user- Returns:
- true, if the user has a negative balance
- Throws:
UserDoesNotExistException
- If a user by that name does not exists
-
isNegative
Test if the user has a negative balance- Parameters:
uuid
- UUID of the user- Returns:
- true, if the user has a negative balance
- Throws:
UserDoesNotExistException
- If a user by that UUID does not exists
-
isNegative
Test if the user has a negative balance- Parameters:
user
- User- Returns:
- true, if the user has a negative balance
-
format
Deprecated.Useformat(BigDecimal)
if your input is already aBigDecimal
.Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67- Parameters:
amount
- The amount of money- Returns:
- Formatted money
-
format
Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67- Parameters:
amount
- The amount of money- Returns:
- Formatted money
-
playerExists
Deprecated.Essentials is moving away from username based economy methods. This may be removed in the future.Test if a player exists to avoid the UserDoesNotExistException- Parameters:
name
- Name of the user- Returns:
- true, if the user exists
-
playerExists
Test if a player exists to avoid the UserDoesNotExistException- Parameters:
uuid
- UUID of the user- Returns:
- true, if the user exists
-
isNPC
Test if a player is a npc- Parameters:
name
- Name of the player- Returns:
- true, if it's a npc
- Throws:
UserDoesNotExistException
-
createNPC
Creates dummy files for a npc, if there is no player yet with that name.- Parameters:
name
- Name of the player- Returns:
- true, if a new npc was created
-
removeNPC
Deletes a user, if it is marked as npc.- Parameters:
name
- Name of the player- Throws:
UserDoesNotExistException
-
add(UUID, BigDecimal)
oradd(User, BigDecimal)