Package com.ultikits.ultitools.utils
Class EconomyUtils
java.lang.Object
com.ultikits.ultitools.utils.EconomyUtils
Utility class for economy operations using Vault.
Provides convenient static methods for common economy operations.
使用 Vault 进行经济操作的工具类。 提供常用经济操作的便捷静态方法。
- Since:
- 6.2.0
- Version:
- 1.0.0
- Author:
- wisdomme
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static net.milkbowl.vault.economy.Economyprivate static boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDeposits money into a player's account.static booleandeposit(org.bukkit.OfflinePlayer player, double amount) Deposits money into a player's account.static Stringformat(double amount) Formats an amount according to the economy's format.static doublegetBalance(UUID uuid) Gets the balance of a player by UUID.static doublegetBalance(org.bukkit.OfflinePlayer player) Gets the balance of a player.static StringGets the currency name (singular).static StringGets the currency name (plural).static net.milkbowl.vault.economy.EconomyGets the economy instance.static booleanChecks if a player has at least the specified amount.static booleanhas(org.bukkit.OfflinePlayer player, double amount) Checks if a player has at least the specified amount.static booleanChecks if Vault economy is available.static voidreset()Resets the economy setup state.static booleansetup()Sets up the economy provider from Vault.static booleanTransfers money from one player to another.static booleantransfer(org.bukkit.OfflinePlayer from, org.bukkit.OfflinePlayer to, double amount) Transfers money from one player to another.static booleanWithdraws money from a player's account.static booleanwithdraw(org.bukkit.OfflinePlayer player, double amount) Withdraws money from a player's account.
-
Field Details
-
economy
private static net.milkbowl.vault.economy.Economy economy -
setupAttempted
private static boolean setupAttempted
-
-
Constructor Details
-
EconomyUtils
private EconomyUtils()
-
-
Method Details
-
setup
public static boolean setup()Sets up the economy provider from Vault.从 Vault 设置经济提供者。
- Returns:
- true if economy was set up successfully
-
isAvailable
public static boolean isAvailable()Checks if Vault economy is available.检查 Vault 经济是否可用。
- Returns:
- true if economy is available
-
getEconomy
Gets the economy instance.获取经济实例。
- Returns:
- the economy instance, or null if not available
-
getBalance
public static double getBalance(org.bukkit.OfflinePlayer player) Gets the balance of a player.获取玩家余额。
- Parameters:
player- the player- Returns:
- the balance, or 0 if economy is not available
-
getBalance
Gets the balance of a player by UUID.通过 UUID 获取玩家余额。
- Parameters:
uuid- the player's UUID- Returns:
- the balance, or 0 if economy is not available
-
has
public static boolean has(org.bukkit.OfflinePlayer player, double amount) Checks if a player has at least the specified amount.检查玩家是否拥有至少指定数量的金钱。
- Parameters:
player- the playeramount- the amount to check- Returns:
- true if the player has at least the amount
-
has
Checks if a player has at least the specified amount.检查玩家是否拥有至少指定数量的金钱。
- Parameters:
uuid- the player's UUIDamount- the amount to check- Returns:
- true if the player has at least the amount
-
deposit
public static boolean deposit(org.bukkit.OfflinePlayer player, double amount) Deposits money into a player's account.向玩家账户存入金钱。
- Parameters:
player- the playeramount- the amount to deposit- Returns:
- true if the deposit was successful
-
deposit
Deposits money into a player's account.向玩家账户存入金钱。
- Parameters:
uuid- the player's UUIDamount- the amount to deposit- Returns:
- true if the deposit was successful
-
withdraw
public static boolean withdraw(org.bukkit.OfflinePlayer player, double amount) Withdraws money from a player's account.从玩家账户取出金钱。
- Parameters:
player- the playeramount- the amount to withdraw- Returns:
- true if the withdrawal was successful
-
withdraw
Withdraws money from a player's account.从玩家账户取出金钱。
- Parameters:
uuid- the player's UUIDamount- the amount to withdraw- Returns:
- true if the withdrawal was successful
-
transfer
public static boolean transfer(org.bukkit.OfflinePlayer from, org.bukkit.OfflinePlayer to, double amount) Transfers money from one player to another.在两个玩家之间转账。
- Parameters:
from- the player to withdraw fromto- the player to deposit toamount- the amount to transfer- Returns:
- true if the transfer was successful
-
transfer
Transfers money from one player to another.在两个玩家之间转账。
- Parameters:
from- the UUID of the player to withdraw fromto- the UUID of the player to deposit toamount- the amount to transfer- Returns:
- true if the transfer was successful
-
format
Formats an amount according to the economy's format.根据经济插件的格式格式化金额。
- Parameters:
amount- the amount to format- Returns:
- the formatted amount string
-
getCurrencyName
Gets the currency name (singular).获取货币名称(单数形式)。
- Returns:
- the currency name
-
getCurrencyNamePlural
Gets the currency name (plural).获取货币名称(复数形式)。
- Returns:
- the currency name (plural)
-
reset
public static void reset()Resets the economy setup state. Used primarily for testing.重置经济设置状态。主要用于测试。
-