Package de.presti.ree6.utils.data
Class EconomyUtil
java.lang.Object
de.presti.ree6.utils.data.EconomyUtil
Utility class for Economy related stuff.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
formatMoney
(double amount) static de.presti.ree6.sql.entities.economy.MoneyHolder
getMoneyHolder
(long guildId, long memberId) Retrieve a MoneyHolder from the Database.static de.presti.ree6.sql.entities.economy.MoneyHolder
getMoneyHolder
(long guildId, long memberId, boolean createIfNotExists) Retrieve a MoneyHolder from the Database.static de.presti.ree6.sql.entities.economy.MoneyHolder
getMoneyHolder
(net.dv8tion.jda.api.entities.Member member) Retrieve a MoneyHolder from the Database.static boolean
hasCash
(long guildId, long memberId) Check if a MoneyHolder has any cash.static boolean
hasCash
(de.presti.ree6.sql.entities.economy.MoneyHolder moneyHolder) Check if a MoneyHolder has any cash.static boolean
hasCash
(net.dv8tion.jda.api.entities.Member member) Check if a MoneyHolder has any cash.static boolean
hasEnoughMoney
(de.presti.ree6.sql.entities.economy.MoneyHolder target, double amount, boolean checkBank) Check if the MoneyHolder has enough money.static boolean
pay
(de.presti.ree6.sql.entities.economy.MoneyHolder sender, de.presti.ree6.sql.entities.economy.MoneyHolder receiver, double amount, boolean fromBank, boolean toBank) Create a payment transaction between two MoneyHolders.static boolean
pay
(de.presti.ree6.sql.entities.economy.MoneyHolder sender, de.presti.ree6.sql.entities.economy.MoneyHolder receiver, double amount, boolean fromBank, boolean toBank, boolean isSystem) Create a payment transaction between two MoneyHolders.
-
Constructor Details
-
EconomyUtil
public EconomyUtil()
-
-
Method Details
-
hasCash
public static boolean hasCash(net.dv8tion.jda.api.entities.Member member) Check if a MoneyHolder has any cash.- Parameters:
member
- The Member.- Returns:
- If the MoneyHolder has any cash.
-
hasCash
public static boolean hasCash(long guildId, long memberId) Check if a MoneyHolder has any cash.- Parameters:
guildId
- The ID of the Guild.memberId
- The ID of the Member.- Returns:
- If the MoneyHolder has any cash.
-
hasCash
public static boolean hasCash(de.presti.ree6.sql.entities.economy.MoneyHolder moneyHolder) Check if a MoneyHolder has any cash.- Parameters:
moneyHolder
- The MoneyHolder to check.- Returns:
- If the MoneyHolder has any cash.
-
getMoneyHolder
public static de.presti.ree6.sql.entities.economy.MoneyHolder getMoneyHolder(net.dv8tion.jda.api.entities.Member member) Retrieve a MoneyHolder from the Database.- Parameters:
member
- The Member.- Returns:
- The MoneyHolder.
-
getMoneyHolder
public static de.presti.ree6.sql.entities.economy.MoneyHolder getMoneyHolder(long guildId, long memberId) Retrieve a MoneyHolder from the Database.- Parameters:
guildId
- The ID of the Guild.memberId
- The ID of the Member.- Returns:
- The MoneyHolder.
-
getMoneyHolder
public static de.presti.ree6.sql.entities.economy.MoneyHolder getMoneyHolder(long guildId, long memberId, boolean createIfNotExists) Retrieve a MoneyHolder from the Database.- Parameters:
guildId
- The ID of the Guild.memberId
- The ID of the Member.createIfNotExists
- If the MoneyHolder should be created if it does not exist.- Returns:
- The MoneyHolder.
-
hasEnoughMoney
public static boolean hasEnoughMoney(de.presti.ree6.sql.entities.economy.MoneyHolder target, double amount, boolean checkBank) Check if the MoneyHolder has enough money.- Parameters:
target
- The MoneyHolder to check.amount
- The amount to check.checkBank
- If the bank should be checked.- Returns:
- If the MoneyHolder has enough money.
-
pay
public static boolean pay(de.presti.ree6.sql.entities.economy.MoneyHolder sender, de.presti.ree6.sql.entities.economy.MoneyHolder receiver, double amount, boolean fromBank, boolean toBank) Create a payment transaction between two MoneyHolders.- Parameters:
sender
- The sender of the money.receiver
- The receiver of the money.amount
- The amount of money to send.fromBank
- If the money should be taken from the bank.toBank
- If the money should be sent to the bank.- Returns:
- If the payment was successful.
-
pay
public static boolean pay(de.presti.ree6.sql.entities.economy.MoneyHolder sender, de.presti.ree6.sql.entities.economy.MoneyHolder receiver, double amount, boolean fromBank, boolean toBank, boolean isSystem) Create a payment transaction between two MoneyHolders.- Parameters:
sender
- The sender of the money.receiver
- The receiver of the money.amount
- The amount of money to send.fromBank
- If the money should be taken from the bank.toBank
- If the money should be sent to the bank.isSystem
- If the payment is a system payment.- Returns:
- If the payment was successful.
-
formatMoney
-